#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int N = 1010;
int dx[] = {-1, 0};
int dy[] = {0, -1};
char dc[] = {'D', 'R'};
int mn, n, a[N][N], mv[N][N], dp[N][N];
const int infi = 1000000000;
int desc(int x, int v, int tp) {
  if (x == 0) return tp;
  if (x % v == 0)
    return 1 + desc(x / v, v, tp);
  else
    return 0;
}
int solve(int v, int tp) {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      mv[i][j] = (dp[i - 1][j] > dp[i][j - 1]) ? 1 : 0;
      if (i == 1) mv[i][j] = 1;
      if (j == 1) mv[i][j] = 0;
      dp[i][j] = max(
          -infi, dp[i + dx[mv[i][j]]][j + dy[mv[i][j]]] + desc(a[i][j], v, tp));
    }
  int ans = dp[n][n];
  if (ans < 0) ans = 1;
  return ans;
}
string ans;
void build() {
  ans = "";
  int x = n, y = n;
  while (!(x == 1 && y == 1)) {
    int x2 = x + dx[mv[x][y]];
    int y2 = y + dy[mv[x][y]];
    ans += dc[mv[x][y]];
    x = x2;
    y = y2;
  }
  reverse(ans.begin(), ans.end());
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  if (min(solve(2, -infi), solve(2, 1)) < min(solve(5, -infi), solve(5, 1))) {
    if (solve(2, -infi) < solve(2, 1))
      solve(2, -infi);
    else
      solve(2, 1);
  } else {
    if (solve(5, -infi) < solve(5, 1))
      solve(5, -infi);
    else
      solve(5, 1);
  }
  build();
  mn = dp[n][n];
  if (mn < 0) mn = 1;
  cout << mn << '\n' << ans << '\n';
  return 0;
}
