#include <bits/stdc++.h>
using namespace std;
int a[1003][1003][2], dp[1003][1003][2];
int n, ans, cnt, ep;
inline void read(int &x);
void print(int x, int y, int k, int t);
int main() {
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  int t, b, c;
  bool flag = false;
  read(n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      read(t);
      if (t == 0) {
        a[i][j][0] = a[i][j][1] = 1;
        c = i, b = j;
        flag = true;
        continue;
      }
      cnt = 0;
      while (t % 5 == 0) {
        ++cnt;
        t /= 5;
      }
      a[i][j][0] = cnt;
      cnt = 0;
      while ((t & 1) == 0) {
        ++cnt;
        t >>= 1;
      }
      a[i][j][1] = cnt;
    }
  }
  dp[1][1][0] = a[1][1][0];
  dp[1][1][1] = a[1][1][1];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i == 1 && j == 1) continue;
      if (i > 1) {
        dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j][0]);
        dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][1]);
      }
      if (j > 1) {
        dp[i][j][0] = min(dp[i][j][0], dp[i][j - 1][0]);
        dp[i][j][1] = min(dp[i][j][1], dp[i][j - 1][1]);
      }
      dp[i][j][0] += a[i][j][0];
      dp[i][j][1] += a[i][j][1];
    }
  }
  ans = min(dp[n][n][0], dp[n][n][1]);
  if (ans > 1 && flag) {
    printf("1\n");
    for (int i = 1; i < b; ++i) putchar('R');
    for (int j = 1; j < c; ++j) putchar('D');
    for (int i = b; i < n; ++i) putchar('R');
    for (int j = c; j < n; ++j) putchar('D');
    return 0;
  }
  printf("%d\n", ans);
  if (dp[n][n][0] < dp[n][n][1])
    print(n, n, 0, -1);
  else
    print(n, n, 1, -1);
  return 0;
}
void print(int x, int y, int k, int t) {
  if (x == 1 && y == 1)
    ;
  else if (x == 1)
    print(x, y - 1, k, 0);
  else if (y == 1)
    print(x - 1, y, k, 1);
  else {
    if (dp[x][y][k] == dp[x][y - 1][k] + a[x][y][k])
      print(x, y - 1, k, 0);
    else
      print(x - 1, y, k, 1);
  }
  if (t == -1) return;
  putchar(t == 1 ? 'D' : 'R');
}
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
}
