#include <bits/stdc++.h>
using namespace std;
int dp2[1002][1002];
int dp5[1002][1002];
int a[1002][1002];
bool ans2[1005][1005];
bool ans5[1005][1005];
int n;
int main() {
  memset(dp2, 0, sizeof(dp2));
  memset(dp5, 0, sizeof(dp5));
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  int sp = -1;
  for (int i = 1; i <= n; i++) {
    if (a[1][i] == 0)
      sp = 1;
    else {
      int cpy = a[1][i];
      while (cpy % 5 == 0) dp5[1][i]++, cpy /= 5;
      while (cpy % 2 == 0) dp2[1][i]++, cpy /= 2;
      dp2[1][i] += dp2[1][i - 1];
      dp5[1][i] += dp5[1][i - 1];
    }
    ans2[1][i] = ans5[1][i] = 0;
  }
  for (int i = 2; i <= n; i++) {
    if (a[i][1] == 0)
      sp = i;
    else {
      int cpy = a[i][1];
      while (cpy % 5 == 0) dp5[i][1]++, cpy /= 5;
      while (cpy % 2 == 0) dp2[i][1]++, cpy /= 2;
      dp2[i][1] += dp2[i - 1][1];
      dp5[i][1] += dp5[i - 1][1];
    }
    ans2[i][1] = ans5[i][1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= n; j++) {
      int cpy = a[i][j];
      if (a[i][j] == 0) {
        sp = i;
      } else {
        while (cpy % 2 == 0) dp2[i][j]++, cpy /= 2;
        while (cpy % 5 == 0) dp5[i][j]++, cpy /= 5;
      }
      if (dp2[i - 1][j] < dp2[i][j - 1])
        dp2[i][j] += dp2[i - 1][j], ans2[i][j] = 1;
      else
        dp2[i][j] += dp2[i][j - 1], ans2[i][j] = 0;
      if (dp5[i - 1][j] < dp5[i][j - 1])
        dp5[i][j] += dp5[i - 1][j], ans5[i][j] = 1;
      else
        dp5[i][j] += dp5[i][j - 1], ans5[i][j] = 0;
    }
  }
  if (min(dp2[n][n], dp5[n][n]) > 1 && sp != -1) {
    cout << 1 << endl;
    for (int i = 2; i <= sp; i++) cout << "D";
    for (int i = 2; i <= n; i++) cout << "R";
    for (int i = sp + 1; i <= n; i++) cout << "D";
    return 0;
  }
  if (dp2[n][n] < dp5[n][n]) {
    cout << dp2[n][n] << endl;
    int x = n, y = n;
    string ans;
    while (x != 1 || y != 1) {
      if (ans2[x][y])
        ans += 'D', x--;
      else
        ans += 'R', y--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
  } else {
    cout << dp5[n][n] << endl;
    int x = n, y = n;
    string ans;
    while (x != 1 || y != 1) {
      if (ans5[x][y])
        ans += 'D', x--;
      else
        ans += 'R', y--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
  }
  return 0;
}
