#include <bits/stdc++.h>
using namespace std;
int mat[1001][1001][2];
int dp1[1001][1001];
int dp2[1001][1001];
int dx[2] = {0, 1};
int dy[2] = {1, 0};
vector<pair<int, int> > vx;
void findxx1(int i, int j);
void findxx2(int i, int j);
int chk(int x, int y, int n) {
  if (x >= n || y >= n || y < 0 || x < 0)
    return 0;
  else
    return 1;
}
struct parent {
  int x;
  int y;
};
struct parent par1[1001][1001], par2[1001][1001];
struct node {
  int x;
  int y;
};
void bfs2(int n) {
  int i, j, x, y;
  queue<node> q;
  node a;
  a.x = 0;
  a.y = 0;
  q.push(a);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) dp1[i][j] = 99999;
  dp1[0][0] = mat[0][0][0];
  while (!q.empty()) {
    x = q.front().x;
    y = q.front().y;
    q.pop();
    for (i = 0; i < 2; i++) {
      int x1, y1;
      x1 = x + dx[i];
      y1 = y + dy[i];
      if (chk(x1, y1, n)) {
        if (dp1[x1][y1] > dp1[x][y] + mat[x1][y1][0]) {
          dp1[x1][y1] = dp1[x][y] + mat[x1][y1][0];
          a.x = x1;
          a.y = y1;
          q.push(a);
          par1[x1][y1].x = x;
          par1[x1][y1].y = y;
        }
      }
    }
  }
}
void bfs5(int n) {
  int i, j, x, y;
  queue<node> q;
  node a;
  a.x = 0;
  a.y = 0;
  q.push(a);
  for (int i = 0; i < n; i++)
    for (j = 0; j < n; j++) dp2[i][j] = 99999;
  dp2[0][0] = mat[0][0][1];
  while (!q.empty()) {
    x = q.front().x;
    y = q.front().y;
    q.pop();
    for (i = 0; i < 2; i++) {
      int x1, y1;
      x1 = x + dx[i];
      y1 = y + dy[i];
      if (chk(x1, y1, n)) {
        if (dp2[x1][y1] > dp2[x][y] + mat[x1][y1][1]) {
          dp2[x1][y1] = dp2[x][y] + mat[x1][y1][1];
          a.x = x1;
          a.y = y1;
          q.push(a);
          par2[x1][y1].x = x;
          par2[x1][y1].y = y;
        }
      }
    }
  }
}
void zeroPrint(int x, int y, int n) {
  int i, j, k;
  for (i = 0; i < x; i++) cout << "D";
  for (i = 0; i < y; i++) cout << "R";
  for (i = x; i < n - 1; i++) cout << "D";
  for (i = y; i < n - 1; i++) cout << "R";
}
int main() {
  ios_base::sync_with_stdio(0);
  vx.reserve(10000);
  int n, i, j, k, x, xx, yy, zero = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> x;
      if (x == 0) {
        zero = 1;
        xx = i;
        yy = j;
      } else {
        int tmp = x;
        while (tmp && tmp % 2 == 0) {
          mat[i][j][0]++;
          tmp /= 2;
        }
        while (tmp && tmp % 5 == 0) {
          mat[i][j][1]++;
          tmp /= 5;
        }
      }
    }
  }
  bfs2(n);
  bfs5(n);
  int ret = min(dp1[n - 1][n - 1], dp2[n - 1][n - 1]);
  if (zero && ret > 1) {
    cout << 1 << endl;
    zeroPrint(xx, yy, n);
  } else {
    cout << ret << endl;
    vx.push_back({n - 1, n - 1});
    if (dp1[n - 1][n - 1] > dp2[n - 1][n - 1]) {
      findxx2(n - 1, n - 1);
    } else
      findxx1(n - 1, n - 1);
    reverse(vx.begin(), vx.end());
    for (i = 1; i < vx.size(); i++) {
      if (vx[i - 1].first == vx[i].first)
        cout << "R";
      else
        cout << "D";
    }
    cout << endl;
  }
}
void findxx1(int i, int j) {
  if (i == 0 && j == 0) {
    return;
  } else {
    vx.push_back({par1[i][j].x, par1[i][j].y});
    findxx1(par1[i][j].x, par1[i][j].y);
  }
}
void findxx2(int i, int j) {
  if (i == 0 && j == 0) {
    return;
  } else {
    vx.push_back({par2[i][j].x, par2[i][j].y});
    findxx2(par2[i][j].x, par2[i][j].y);
  }
}
