#include <bits/stdc++.h>
using namespace std;
long long const nax = 1005;
long long v[nax][nax];
long long two[nax][nax];
long long five[nax][nax];
pair<long long, long long> pre[nax][nax];
long long two_count(long long n) {
  if (n == 0) return 1;
  long long cnt = 0;
  while (n % 2 == 0) cnt++, n /= 2;
  return cnt;
}
long long five_count(long long n) {
  if (n == 0) return 1;
  long long cnt = 0;
  while (n % 5 == 0) cnt++, n /= 5;
  return cnt;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n;
  m = n;
  for (long long i = 1; i < n + 1; ++i)
    for (long long j = 1; j < m + 1; ++j) cin >> v[i][j];
  for (long long i = 0; i < nax; ++i)
    for (long long j = 0; j < nax; ++j) two[i][j] = five[i][j] = 1e9;
  bool c = 0;
  long long in;
  for (long long i = 1; i < n + 1; ++i)
    for (long long j = 1; j < m + 1; ++j)
      if (v[i][j] == 0) c = 1, in = j;
  for (long long i = 1; i < n + 1; ++i) {
    for (long long j = 1; j < m + 1; ++j) {
      if (i == 1 && j == 1) {
        two[i][j] = two_count(v[i][j]);
        five[i][j] = five_count(v[i][j]);
        continue;
      }
      two[i][j] = min(two[i - 1][j], two[i][j - 1]) + two_count(v[i][j]);
      five[i][j] = min(five[i - 1][j], five[i][j - 1]) + five_count(v[i][j]);
    }
  }
  long long res = min(two[n][m], five[n][m]);
  if (c && res > 1) {
    cout << 1 << "\n";
    for (long long i = 1; i < in; ++i) cout << "R";
    for (long long i = 1; i < n; ++i) cout << "D";
    for (long long i = in + 1; i < m + 1; ++i) cout << "R";
    return 0;
  }
  cout << res << "\n";
  if (two[n][m] < five[n][m]) {
    for (long long i = 1; i < n + 1; ++i)
      for (long long j = 1; j < m + 1; ++j) two[i][j] = 1e9;
    for (long long i = 1; i < n + 1; ++i) {
      for (long long j = 1; j < m + 1; ++j) {
        if (i == 1 && j == 1) {
          pre[i][j] = {1, 1};
          two[i][j] = two_count(v[i][j]);
          continue;
        }
        if (two[i - 1][j] < two[i][j - 1]) {
          pre[i][j] = {i - 1, j};
        } else {
          pre[i][j] = {i, j - 1};
        }
        two[i][j] = min(two[i - 1][j], two[i][j - 1]) + two_count(v[i][j]);
      }
    }
  } else {
    for (long long i = 1; i < n + 1; ++i)
      for (long long j = 1; j < m + 1; ++j) five[i][j] = 1e9;
    for (long long i = 1; i < n + 1; ++i) {
      for (long long j = 1; j < m + 1; ++j) {
        if (i == 1 && j == 1) {
          pre[i][j] = {1, 1};
          five[i][j] = five_count(v[i][j]);
          continue;
        }
        if (five[i - 1][j] < five[i][j - 1]) {
          pre[i][j] = {i - 1, j};
        } else {
          pre[i][j] = {i, j - 1};
        }
        five[i][j] = min(five[i - 1][j], five[i][j - 1]) + five_count(v[i][j]);
      }
    }
  }
  long long x = n, y = m;
  string ans = "";
  while (x != pre[x][y].first || y != pre[x][y].second) {
    long long a = pre[x][y].first;
    long long b = pre[x][y].second;
    if (a < x) ans += "D";
    if (b < y) ans += "R";
    x = a;
    y = b;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";
}
