#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238463;
const int N = 1010;
const long long INF = 1LL << 60;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
long long arr[N][N][2];
char path[N][N][2];
int kz;
void ppath(int x, int y) {
  if (x == 1 && y == 1) return;
  if (path[x][y][kz] == 'D')
    ppath(x - 1, y);
  else
    ppath(x, y - 1);
  cout << path[x][y][kz];
}
int main() {
  int n;
  cin >> n;
  int z = -1;
  for (int i = 0; i <= n; i++) arr[i][0][0] = arr[i][0][1] = INT_MAX;
  for (int i = 0; i <= n; i++) arr[0][i][0] = arr[0][i][1] = INT_MAX;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int x;
      cin >> x;
      if (x == 0)
        z = i;
      else {
        while (x % 2 == 0) arr[i][j][0]++, x /= 2;
        while (x % 5 == 0) arr[i][j][1]++, x /= 5;
      }
      if (i == 1 && j == 1) continue;
      for (int k = 0; k < 2; k++) {
        if (arr[i - 1][j][k] < arr[i][j - 1][k]) {
          path[i][j][k] = 'D';
          arr[i][j][k] += arr[i - 1][j][k];
        } else {
          path[i][j][k] = 'R';
          arr[i][j][k] += arr[i][j - 1][k];
        }
      }
    }
  kz = arr[n][n][0] > arr[n][n][1];
  if (z != -1 && arr[n][n][kz] > 1) {
    cout << 1 << endl;
    for (int i = 1; i < z; i++) cout << 'D';
    for (int i = 1; i < n; i++) cout << 'R';
    for (int i = z; i < n; i++) cout << 'D';
  } else {
    cout << arr[n][n][kz] << endl;
    ppath(n, n);
    cout << endl;
  }
}
