#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long a[1002][1002][2];
long long dp[1002][1002][2];
void printSolve(int x, int y, int dir) {
  if (x == 1 && y == 1) return;
  if (x == 1)
    printSolve(x, y - 1, dir), cout << "R";
  else if (y == 1)
    printSolve(x - 1, y, dir), cout << "D";
  else if (dp[x - 1][y][dir] == dp[x][y][dir] - a[x][y][dir])
    printSolve(x - 1, y, dir), cout << "D";
  else
    printSolve(x, y - 1, dir), cout << "R";
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  memset(a, 0, sizeof(a));
  bool f = false;
  int mi, mj, ma = 0, t;
  for (typename decay<decltype((1) + (n + 1))>::type i = (1); i < (n + 1);
       ++i) {
    for (typename decay<decltype((1) + (n + 1))>::type j = (1); j < (n + 1);
         ++j) {
      cin >> t;
      ma = max(ma, t);
      if (t == 0) {
        f = true, mi = i, mj = j;
      } else {
        while (t % 2 == 0) {
          a[i][j][0]++;
          t /= 2;
        }
        while (t % 5 == 0) {
          a[i][j][1]++;
          t /= 5;
        }
      }
    }
  }
  memset(dp, 1e9 + 1, sizeof(dp));
  dp[1][0][0] = dp[0][1][0] = 0;
  dp[1][0][1] = dp[0][1][1] = 0;
  for (typename decay<decltype((1) + (n + 1))>::type i = (1); i < (n + 1);
       ++i) {
    for (typename decay<decltype((1) + (n + 1))>::type j = (1); j < (n + 1);
         ++j) {
      dp[i][j][0] = a[i][j][0] + min(dp[i - 1][j][0], dp[i][j - 1][0]);
      dp[i][j][1] = a[i][j][1] + min(dp[i][j - 1][1], dp[i - 1][j][1]);
    }
  }
  long long ans = min(dp[n][n][0], dp[n][n][1]);
  if (f && ans > 1) {
    cout << 1 << endl;
    for (typename decay<decltype((0) + (mi - 1))>::type i = (0); i < (mi - 1);
         ++i)
      cout << "D";
    for (typename decay<decltype((0) + (n - 1))>::type i = (0); i < (n - 1);
         ++i)
      cout << "R";
    for (typename decay<decltype((0) + (n - mi))>::type i = (0); i < (n - mi);
         ++i)
      cout << "D";
    return 0;
  }
  cout << ans << endl;
  printSolve(n, n, dp[n][n][0] > dp[n][n][1]);
  return 0;
}
