#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795;
const long double eps = 1e-9;
int n, x, y;
int A[1000][1000];
pair<int, int> F[1000][1000];
int DP1[1000][1000], DP2[1000][1000];
pair<int, int> P1[1000][1000], P2[1000][1000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &A[i][j]);
  int x = -1, y;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (A[i][j] == 0) {
        A[i][j] = 10;
        x = i;
        y = j;
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      F[i][j] = make_pair(0, 0);
      while (A[i][j] % 2 == 0) {
        A[i][j] /= 2;
        F[i][j].first++;
      }
      while (A[i][j] % 5 == 0) {
        A[i][j] /= 5;
        F[i][j].second++;
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == 0 && j == 0) {
        DP1[i][j] = F[i][j].first;
        continue;
      }
      DP1[i][j] = 99991007;
      if (i > 0) {
        if (DP1[i][j] > DP1[i - 1][j] + F[i][j].first) {
          DP1[i][j] = min(DP1[i][j], DP1[i - 1][j] + F[i][j].first);
          P1[i][j] = make_pair(i - 1, j);
        }
      }
      if (j > 0) {
        if (DP1[i][j] > DP1[i][j - 1] + F[i][j].first) {
          DP1[i][j] = min(DP1[i][j], DP1[i][j - 1] + F[i][j].first);
          P1[i][j] = make_pair(i, j - 1);
        }
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == 0 && j == 0) {
        DP2[i][j] = F[i][j].second;
        continue;
      }
      DP2[i][j] = 99991007;
      if (i > 0) {
        if (DP2[i][j] > DP2[i - 1][j] + F[i][j].second) {
          DP2[i][j] = min(DP2[i][j], DP2[i - 1][j] + F[i][j].second);
          P2[i][j] = make_pair(i - 1, j);
        }
      }
      if (j > 0) {
        if (DP2[i][j] > DP2[i][j - 1] + F[i][j].second) {
          DP2[i][j] = min(DP2[i][j], DP2[i][j - 1] + F[i][j].second);
          P2[i][j] = make_pair(i, j - 1);
        }
      }
    }
  int r = min(DP1[n - 1][n - 1], DP2[n - 1][n - 1]);
  if (x != -1 && r >= 1) {
    cout << 1 << endl;
    for (int i = 0; i < x; i++) cout << 'D';
    for (int i = 0; i < n - 1; i++) cout << 'R';
    for (int j = x; j < n - 1; j++) cout << 'D';
    cout << endl;
  } else {
    cout << r << endl;
    x = n - 1, y = n - 1;
    string res = "";
    if (DP1[n - 1][n - 1] < DP2[n - 1][n - 1]) {
      while (make_pair(x, y) != make_pair(0, 0)) {
        int tx = P1[x][y].first, ty = P1[x][y].second;
        if (tx != x)
          res = "D" + res;
        else
          res = "R" + res;
        x = tx;
        y = ty;
      }
    } else {
      while (make_pair(x, y) != make_pair(0, 0)) {
        int tx = P2[x][y].first, ty = P2[x][y].second;
        if (tx != x)
          res = "D" + res;
        else
          res = "R" + res;
        x = tx;
        y = ty;
      }
    }
    cout << res << endl;
  }
  return 0;
}
