#include <bits/stdc++.h>
using namespace std;
long long n;
long long arr[1001][1001];
long long dp2[1001][1001];
long long dp5[1001][1001];
long long ch2(long long x) {
  long long count = 0;
  while (x % 2 == 0) {
    count++;
    x /= 2;
  }
  return count;
}
long long ch5(long long x) {
  long long count = 0;
  while (x % 5 == 0) {
    count++;
    x /= 5;
  }
  return count;
}
long long f2(long long i, long long j) {
  if (i >= n || j >= n) return 1e17;
  if (i == n - 1 && j == n - 1) return ch2(arr[n - 1][n - 1]);
  if (dp2[i][j] != -1) return dp2[i][j];
  dp2[i][j] = min(f2(i + 1, j), f2(i, j + 1)) + ch2(arr[i][j]);
  return dp2[i][j];
}
long long f5(long long i, long long j) {
  if (i >= n || j >= n) return 1e17;
  if (i == n - 1 && j == n - 1) return ch5(arr[n - 1][n - 1]);
  if (dp5[i][j] != -1) return dp5[i][j];
  dp5[i][j] = min(f5(i + 1, j), f5(i, j + 1)) + ch5(arr[i][j]);
  return dp5[i][j];
}
void path2(long long i, long long j) {
  if (i >= n || j >= n) return;
  if (i == n - 1 && j == n - 1) return;
  if (f2(i + 1, j) < f2(i, j + 1)) {
    cout << "D";
    path2(i + 1, j);
  } else {
    cout << "R";
    path2(i, j + 1);
  }
}
void path5(long long i, long long j) {
  if (i >= n || j >= n) return;
  if (i == n - 1 && j == n - 1) return;
  if (f5(i + 1, j) < f5(i, j + 1)) {
    cout << "D";
    path5(i + 1, j);
  } else {
    cout << "R";
    path5(i, j + 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  long long x = -1;
  long long y = -1;
  memset(dp2, -1, sizeof(dp2));
  memset(dp5, -1, sizeof(dp5));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == 0) {
        x = i;
        y = j;
        arr[i][j] = 10;
      }
    }
  }
  long long ans = min(f2(0, 0), f5(0, 0));
  if (ans > 1 && x != -1) {
    cout << 1 << '\n';
    for (long long i = 1; i <= x; i++) cout << "D";
    for (long long i = 1; i < n; i++) cout << "R";
    for (long long i = x + 1; i < n; i++) cout << "D";
    return 0;
  }
  cout << ans << '\n';
  if (f2(0, 0) < f5(0, 0))
    path2(0, 0);
  else
    path5(0, 0);
}
