#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long exp, long long mod = (1000000007LL)) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2) {
      res = (res * base) % mod;
    }
    base = (base * base) % mod;
    exp /= 2;
  }
  return res;
}
const long long int N = 1e3 + 1, D = 18;
long long int n;
long long int a[N][N], par[2][N][N], f[2][N][N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long int i = 0; i < n; i++)
    for (long long int j = 0; j < n; j++)
      cin >> a[i][j], f[0][i][j] = f[1][i][j] = 1000000009;
  long long int zero = 0, zx = -1, zy = -1;
  for (long long int i = 0; i < n; i++)
    for (long long int j = 0; j < n; j++) {
      if (!a[i][j]) {
        zero = 1;
        zx = i, zy = j;
        a[i][j] = 10;
      }
    }
  long long int x = 0;
  while (a[0][0] % 2 == 0) a[0][0] /= 2, ++x;
  f[0][0][0] = x;
  x = 0;
  while (a[0][0] % 5 == 0) a[0][0] /= 5, ++x;
  f[1][0][0] = x;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (!i && !j) continue;
      long long int x = 0, cur = a[i][j];
      while (cur > 0 && cur % 2 == 0) cur /= 2, ++x;
      if (i >= 1) {
        if (x + f[0][i - 1][j] < f[0][i][j]) {
          f[0][i][j] = x + f[0][i - 1][j];
          par[0][i][j] = 0;
        }
      }
      if (j >= 1) {
        if (x + f[0][i][j - 1] < f[0][i][j]) {
          f[0][i][j] = x + f[0][i][j - 1];
          par[0][i][j] = 1;
        }
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (!i && !j) continue;
      long long int x = 0, cur = a[i][j];
      while (cur > 0 && cur % 5 == 0) cur /= 5, ++x;
      if (i >= 1) {
        if (x + f[1][i - 1][j] < f[1][i][j]) {
          f[1][i][j] = x + f[1][i - 1][j];
          par[1][i][j] = 0;
        }
      }
      if (j >= 1) {
        if (x + f[1][i][j - 1] < f[1][i][j]) {
          f[1][i][j] = x + f[1][i][j - 1];
          par[1][i][j] = 1;
        }
      }
    }
  }
  long long int res = 1000000009, id = -1;
  if (f[0][n - 1][n - 1] < res) res = f[0][n - 1][n - 1], id = 0;
  if (f[1][n - 1][n - 1] < res) res = f[1][n - 1][n - 1], id = 1;
  if (res == 0) {
    cout << 0 << '\n';
    string s = "";
    long long int px = n - 1, py = n - 1;
    while (px != 0 || py != 0) {
      if (par[id][px][py]) {
        s += "R";
        py--;
      } else {
        s += "D";
        px--;
      }
    }
    reverse((s).begin(), (s).end());
    cout << s << '\n';
  } else if (zero) {
    cout << 1 << '\n';
    long long int px = 0, py = 0;
    while (px < zx) cout << "D", px++;
    while (py < zy) cout << "R", py++;
    while (px < n - 1) cout << "D", px++;
    while (py < n - 1) cout << "R", py++;
  } else {
    cout << res << '\n';
    string s = "";
    long long int px = n - 1, py = n - 1;
    while (px != 0 || py != 0) {
      if (par[id][px][py]) {
        s += "R";
        py--;
      } else {
        s += "D";
        px--;
      }
    }
    reverse((s).begin(), (s).end());
    cout << s << '\n';
  }
  return 0;
}
