#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const int N = 1005;
int a[N][N];
int dp[N][N][2];
int d[] = {2, 5};
void print(int x, int y, int z) {
  if (x == 0 && y == 0) return;
  if (x == 0 || y && dp[x - 1][y][z] > dp[x][y - 1][z]) {
    print(x, y - 1, z);
    cout << "R";
  } else {
    print(x - 1, y, z);
    cout << "D";
  }
}
int main() {
  int n;
  cin >> n;
  int zx = -1, zy = -1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
      if (a[i][j] == 0) {
        zx = i;
        zy = j;
      }
    }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < 2; ++k) {
        if (i == 0 && j == 0)
          dp[i][j][k] = 0;
        else if (i == 0)
          dp[i][j][k] = dp[i][j - 1][k];
        else if (j == 0)
          dp[i][j][k] = dp[i - 1][j][k];
        else
          dp[i][j][k] = min(dp[i][j - 1][k], dp[i - 1][j][k]);
        if (a[i][j] == 0) dp[i][j][k] = 1;
        for (int x = a[i][j]; x && x % d[k] == 0; x /= d[k]) dp[i][j][k]++;
      }
  int z = dp[n - 1][n - 1][0] > dp[n - 1][n - 1][1];
  if (zx != -1 && dp[n - 1][n - 1][z] != 0) {
    cout << 1 << endl;
    for (int i = 0; i < zx; i++) cout << "D";
    for (int i = 0; i < zy; i++) cout << "R";
    for (int i = zx + 1; i < n; i++) cout << "D";
    for (int i = zy + 1; i < n; i++) cout << "R";
    return 0;
  }
  cout << dp[n - 1][n - 1][z] << endl;
  print(n - 1, n - 1, z);
}
