#include <bits/stdc++.h>
using namespace std;
int n;
int mat[1001][1001];
int dp[1003][1004];
int f;
int min(int i, int j) {
  if (i <= j) return i;
  return j;
}
int calc(int n) {
  int r = 0;
  while (n % f == 0 && n > 0) n /= f, r++;
  return r;
}
int getMin(int i, int j) {
  int &ret = dp[i][j];
  if (ret != -1) return ret;
  int t = calc(mat[i][j]);
  ret = 1e9;
  if (i == n - 1 && j == n - 1) {
    return ret = t;
  }
  if (j < n - 1) ret = min(ret, t + getMin(i, j + 1));
  if (i < n - 1) ret = min(ret, t + getMin(i + 1, j));
  return ret;
}
string r1 = "", r2 = "";
void build(int i, int j) {
  if (i == n - 1 && j == n - 1) return;
  int t = calc(mat[i][j]);
  int &ret = dp[i][j];
  if (i < n - 1 && ret == getMin(i + 1, j) + t) {
    if (f == 2)
      r1 += "D";
    else
      r2 += "D";
    build(i + 1, j);
  } else {
    if (f == 2)
      r1 += "R";
    else
      r2 += "R";
    build(i, j + 1);
  }
}
int main() {
  scanf("%d", &n);
  bool zero = 0;
  int I, J;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &mat[i][j]);
      zero |= mat[i][j] == 0;
      if (mat[i][j] == 0) {
        I = i;
        J = j;
      }
    }
  }
  memset(dp, -1, sizeof dp);
  f = 2;
  int two = getMin(0, 0);
  build(0, 0);
  memset(dp, -1, sizeof dp);
  f = 5;
  int five = getMin(0, 0);
  build(0, 0);
  int l = 0;
  if (min(two, five) > 1 && zero) {
    cout << 1 << endl;
    for (l = 0; l < I; ++l) cout << "D";
    for (l = 0; l < J; ++l) cout << "R";
    for (l = I + 1; l < n; ++l) cout << "D";
    for (l = J + 1; l < n; ++l) cout << "R";
  } else if (two < five)
    cout << two << endl << r1 << endl;
  else
    cout << five << endl << r2 << endl;
  return 0;
}
