#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
bool cmp(pair<long long int, long long int> a,
         pair<long long int, long long int> b) {
  if (a.first < b.first) return true;
  if (a.first == b.first) return a.second > b.second;
  return false;
}
long long int n, m, zero;
long long int dp[N][N][2], ar[N][N][2];
void backtrack(long long int r, long long int c, long long int k) {
  if (r == 1 && c == 1) return;
  if (dp[r - 1][c][k] < dp[r][c - 1][k]) {
    backtrack(r - 1, c, k);
    cout << "D";
  } else {
    backtrack(r, c - 1, k);
    cout << "R";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n; ++i) {
    for (long long int j = 1; j <= n; ++j) {
      cin >> m;
      if (m == 0) {
        ar[i][j][0] = ar[i][j][1] = 1;
        zero = i;
        continue;
      }
      long long int t = 0, f = 0;
      while (m && m % 2 == 0) m /= 2, t++;
      while (m && m % 5 == 0) m /= 5, f++;
      ar[i][j][0] = t;
      ar[i][j][1] = f;
    }
  }
  for (long long int i = 2; i <= n; ++i) {
    for (long long int k = 0; k <= 1; ++k) {
      dp[0][i][k] = dp[i][0][k] = 1000000000000000000LL;
    }
  }
  for (long long int i = 1; i <= n; ++i) {
    for (long long int j = 1; j <= n; ++j) {
      for (long long int k = 0; k <= 1; ++k) {
        dp[i][j][k] = min(dp[i - 1][j][k], dp[i][j - 1][k]) + ar[i][j][k];
      }
    }
  }
  long long int k = dp[n][n][1] < dp[n][n][0];
  if (zero && dp[n][n][k]) {
    cout << 1 << endl;
    for (long long int i = 2; i <= zero; ++i) cout << "D";
    for (long long int i = 2; i <= n; ++i) cout << "R";
    for (long long int i = zero + 1; i <= n; ++i) cout << "D";
    return 0;
  }
  cout << dp[n][n][k] << endl;
  backtrack(n, n, k);
  return 0;
}
