#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int dp[N][N][3];
int n;
void pr() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      printf("dp[%d][%d] = %d dp[%d][%d] = %d\n", i, j, dp[i][j][0], i, j,
             dp[i][j][1]);
    }
  }
}
void dfs(int x, int y, int dir) {
  if (x == 1 && y == 1) return;
  if (x == 1) {
    dfs(x, y - 1, dir);
    printf("R");
    return;
  }
  if (y == 1) {
    dfs(x - 1, y, dir);
    printf("D");
    return;
  }
  if (dp[x - 1][y][dir] > dp[x][y - 1][dir]) {
    dfs(x, y - 1, dir);
    printf("R");
    return;
  } else {
    dfs(x - 1, y, dir);
    printf("D");
    return;
  }
}
int main() {
  scanf("%d", &n);
  int pos = -1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      if (x == 0) {
        pos = i;
        continue;
      }
      int t = x;
      while (t % 2 == 0) {
        t /= 2;
        dp[i][j][0]++;
      }
      t = x;
      while (t % 5 == 0) {
        t /= 5;
        dp[i][j][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] += dp[i][j - 1][0];
        dp[i][j][1] += dp[i][j - 1][1];
      } else {
        if (j == 1) {
          dp[i][j][0] += dp[i - 1][j][0];
          dp[i][j][1] += dp[i - 1][j][1];
        } else {
          dp[i][j][0] += min(dp[i - 1][j][0], dp[i][j - 1][0]);
          dp[i][j][1] += min(dp[i - 1][j][1], dp[i][j - 1][1]);
        }
      }
    }
  }
  int k = 0;
  if (dp[n][n][k] > dp[n][n][1]) k = 1;
  if (pos != -1 && dp[n][n][k] > 1) {
    printf("1\n");
    for (int i = 1; i < pos; i++) printf("D");
    for (int i = 1; i < n; i++) printf("R");
    for (int i = pos + 1; i <= n; i++) printf("D");
    return 0;
  }
  printf("%d\n", min(dp[n][n][0], dp[n][n][1]));
  dfs(n, n, k);
  return 0;
}
