#include <bits/stdc++.h>
using namespace std;
int n, g[1100][1100], dp[1100][1100], now[1100][1100], best = 1000000007;
string ans;
void work(int x, int y) {
  if (x - 1 && dp[x - 1][y] + now[x][y] == dp[x][y]) {
    work(x - 1, y);
    ans.push_back('D');
  } else if (y - 1) {
    work(x, y - 1);
    ans.push_back('R');
  }
}
void go(int wh) {
  int i, j;
  memset(now, 0, sizeof(now));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      while (g[i][j] && g[i][j] % wh == 0) {
        now[i][j]++;
        g[i][j] /= wh;
      }
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = now[1][1];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      if (i - 1) dp[i][j] = min(dp[i][j], dp[i - 1][j] + now[i][j]);
      if (j - 1) dp[i][j] = min(dp[i][j], dp[i][j - 1] + now[i][j]);
    }
  if (dp[n][n] < best) {
    ans = "";
    best = dp[n][n];
    work(n, n);
  }
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) scanf("%d", &g[i][j]);
  go(2);
  go(5);
  if (best > 1) {
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        if (!g[i][j]) {
          best = 1;
          ans = "";
          for (k = 1; k < i; k++) ans.push_back('D');
          for (k = 1; k < j; k++) ans.push_back('R');
          for (k = i; k < n; k++) ans.push_back('D');
          for (k = j; k < n; k++) ans.push_back('R');
          break;
        }
  }
  cout << best << endl << ans << endl;
  return 0;
}
