#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, dp2[N][N], dp5[N][N], cnt2[N][N], cnt5[N][N], cnt[N][N], rem1, rem2;
bool zero, q2[N][N], q5[N][N];
void add(int i, int j) {
  if (cnt[i][j] == 0) {
    zero = true;
    rem1 = i;
    rem2 = j;
    return;
  }
  while (cnt[i][j] % 2 == 0) cnt[i][j] /= 2, cnt2[i][j]++;
  while (cnt[i][j] % 5 == 0) cnt[i][j] /= 5, cnt5[i][j]++;
  return;
}
void print2(int x, int y) {
  if (x == 0 && y == 0) return;
  if (q2[x][y]) {
    print2(x - 1, y);
    cout << "D";
  } else {
    print2(x, y - 1);
    cout << "R";
  }
}
void print5(int x, int y) {
  if (x == 0 && y == 0) return;
  if (q5[x][y]) {
    print5(x - 1, y);
    cout << "D";
  } else {
    print5(x, y - 1);
    cout << "R";
  }
}
void print0() {
  for (int i = 0; i < rem1; i++) cout << "D";
  for (int i = 0; i < rem2; i++) cout << "R";
  for (int i = rem1; i < n - 1; i++) cout << "D";
  for (int i = rem2; i < n - 1; i++) cout << "R";
}
void check() {
  cout << "指标2:\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << q2[i][j] << ' ';
    }
    cout << endl;
  }
  cout << "指标5:\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << q5[i][j] << ' ';
    }
    cout << endl;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> cnt[i][j];
      if (cnt[i][j] == 0) {
        zero = true;
        rem1 = i;
        rem2 = j;
      }
      add(i, j);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == 0)
        dp2[i][j] = cnt2[i][j] + dp2[i][j - 1];
      else if (j == 0)
        dp2[i][j] = cnt2[i][j] + dp2[i - 1][j];
      else
        dp2[i][j] = cnt2[i][j] + min(dp2[i - 1][j], dp2[i][j - 1]);
      if (i == 0)
        dp5[i][j] = cnt5[i][j] + dp5[i][j - 1];
      else if (j == 0)
        dp5[i][j] = cnt5[i][j] + dp5[i - 1][j];
      else
        dp5[i][j] = cnt5[i][j] + min(dp5[i - 1][j], dp5[i][j - 1]);
      if (i == 0 && j == 0) continue;
      if (j == 0)
        q2[i][j] = true;
      else if (i == 0)
        q2[i][j] = false;
      else if (dp2[i - 1][j] < dp2[i][j - 1])
        q2[i][j] = true;
      if (j == 0)
        q5[i][j] = true;
      else if (i == 0)
        q5[i][j] = false;
      else if (dp5[i - 1][j] < dp5[i][j - 1])
        q5[i][j] = true;
    }
  }
  if (min(dp2[n - 1][n - 1], dp5[n - 1][n - 1]) > 1 && zero) {
    cout << 1 << endl;
    print0();
  } else {
    if (dp2[n - 1][n - 1] > dp5[n - 1][n - 1]) {
      cout << dp5[n - 1][n - 1] << endl;
      print5(n - 1, n - 1);
    } else {
      cout << dp2[n - 1][n - 1] << endl;
      print2(n - 1, n - 1);
    }
  }
}
