#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7, M = (int)1e9 + 7, inf = INT_MAX;
const long long INF = LLONG_MAX;
int n;
int dp[N][N];
pair<int, int> nxt[N][N];
pair<short int, short int> mat[N][N];
int gp(int x, int i, int j) {
  if (x == 2)
    return mat[i][j].first;
  else
    return mat[i][j].second;
}
pair<string, int> product(int x) {
  string str = "";
  int val = 0, r = 0, c = 0;
  while (r != n and c != n) {
    val += gp(x, r, c);
    if (r == n - 1 and c == n - 1) break;
    if (nxt[r][c].first == r + 1)
      str += 'D', r++;
    else
      str += 'R', c++;
  }
  return {str, val};
}
pair<string, int> help(int x) {
  for (int r = n; r >= 0; r--) {
    for (int c = n; c >= 0; c--) {
      int &mafia = dp[r][c];
      pair<int, int> &p = nxt[r][c];
      if (r == n or c == n or mat[r][c].first == -1) {
        mafia = -1;
        p = {n, n};
        continue;
      }
      int val = gp(x, r, c);
      if (r == n - 1 and c == n - 1) {
        mafia = val;
        p = {n, n};
        continue;
      }
      int a1 = dp[r + 1][c], a2 = dp[r][c + 1];
      if (a1 == -1 and a2 == -1)
        mafia = a1, p = {n, n};
      else if (a1 == -1)
        mafia = val + a2, p = {r, c + 1};
      else if (a2 == -1)
        mafia = val + a1, p = {r + 1, c};
      else if (a1 < a2)
        mafia = val + a1, p = {r + 1, c};
      else
        mafia = val + a2, p = {r, c + 1};
    }
  }
  if (dp[0][0] == -1)
    return {"!!", -1};
  else
    return product(x);
}
void solve() {
  cin >> n;
  pair<int, int> p = {-1, -1};
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)n; j++) {
      int x;
      cin >> x;
      int p2 = 0, p5 = 0;
      while (x > 0 and x % 2 == 0) x /= 2, p2++;
      while (x > 0 and x % 5 == 0) x /= 5, p5++;
      mat[i][j] = {p2, p5};
      if (x == 0) p = {i, j}, mat[i][j] = {-1, -1};
    }
  pair<string, int> ans2 = help(2);
  pair<string, int> ans5 = help(5);
  int a2 = ans2.second, a5 = ans5.second;
  if (a5 == -1 and a2 == -1 or (a5 > 1 and a2 > 1 and p.first != -1)) {
    cout << 1 << endl;
    for (int i = 0; i < (int)p.first; i++) cout << 'D';
    for (int j = 0; j < (int)p.second; j++) cout << 'R';
    for (int i = 0; i < (int)n - 1 - p.first; i++) cout << 'D';
    for (int i = 0; i < (int)n - 1 - p.second; i++) cout << 'R';
    return;
  }
  if (a5 < a2) {
    cout << a5 << endl;
    cout << ans5.first << endl;
  } else {
    cout << a2 << endl;
    cout << ans2.first << endl;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) solve();
}
