#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010, inf = 1e9;
int n, m, ar[maxn][maxn], dp[maxn][maxn], dn[maxn][maxn];
bool b1[maxn][maxn], b2[maxn][maxn];
char ans[maxn << 1];
int main() {
  scanf("%d", &n);
  m = n;
  int zero = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &ar[i][j]);
      zero |= ar[i][j] == 0;
    }
  for (int i = 0; i <= n; i++) dn[0][i] = dn[i][0] = dp[0][i] = dp[i][0] = inf;
  dp[0][1] = dn[0][1] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      {
        int add = ar[i][j] == 0;
        while (ar[i][j] && !(ar[i][j] & 1)) {
          add++;
          ar[i][j] >>= 1;
        }
        b1[i][j] = dp[i - 1][j] < dp[i][j - 1];
        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + add;
      }
      {
        int add = ar[i][j] == 0;
        while (ar[i][j] && ar[i][j] % 5 == 0) {
          add++;
          ar[i][j] /= 5;
        }
        b2[i][j] = dn[i - 1][j] < dn[i][j - 1];
        dn[i][j] = min(dn[i - 1][j], dn[i][j - 1]) + add;
      }
    }
  if (zero && min(dp[n][m], dn[n][m]) > 1) {
    puts("1");
    int x1 = -1, x2;
    for (int i = 1; i <= n && x1 == -1; i++)
      for (int j = 1; j <= m; j++)
        if (ar[i][j] == 0) {
          x1 = i;
          x2 = j;
          break;
        }
    for (int i = 1; i < x1; i++) printf("D");
    for (int i = 1; i < x2; i++) printf("R");
    for (int i = x1; i < n; i++) printf("D");
    for (int i = x2; i < m; i++) printf("R");
    return 0;
  }
  if (dp[n][m] < dn[n][m]) {
    printf("%d\n", dp[n][m]);
    int p1 = n, p2 = m;
    int cnt = 0;
    while (p1 != 1 || p2 != 1) {
      if (b1[p1][p2])
        ans[cnt++] = 'D', p1--;
      else
        ans[cnt++] = 'R', p2--;
    }
  } else {
    printf("%d\n", dn[n][m]);
    int p1 = n, p2 = m;
    int cnt = 0;
    while (p1 != 1 || p2 != 1) {
      if (b2[p1][p2])
        ans[cnt++] = 'D', p1--;
      else
        ans[cnt++] = 'R', p2--;
    }
  }
  reverse(ans, ans + n + n - 2);
  printf("%s", ans);
  return 0;
}
