#include <bits/stdc++.h>
using namespace std;
int min2(int x) {
  int i = 0;
  while (x && x % 2 == 0) {
    i++;
    x = x / 2;
  }
  return i;
}
int min5(int x) {
  int i = 0;
  while (x && x % 5 == 0) {
    i++;
    x = x / 5;
  }
  return i;
}
int main(void) {
  int n, m, l, zeroi = -1;
  cin >> n;
  m = n;
  vector<vector<int>> v(n, vector<int>(n, 0));
  vector<vector<vector<int>>> res(n, vector<vector<int>>(n, vector<int>(4, 0)));
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      cin >> v[i][j];
      if (v[i][j] == 0) {
        zeroi = i;
      }
    }
  res[0][0][0] = min2(v[0][0]);
  res[0][0][2] = min5(v[0][0]);
  n = m - 1;
  while (n) {
    res[m - n][0][0] = res[m - n - 1][0][0] + min2(v[m - n][0]);
    res[m - n][0][2] = res[m - n - 1][0][2] + min5(v[m - n][0]);
    res[m - n][0][1] = 'D';
    res[m - n][0][3] = 'D';
    n--;
  }
  n = m - 1;
  while (n) {
    res[0][m - n][0] = res[0][m - n - 1][0] + min2(v[0][m - n]);
    res[0][m - n][2] = res[0][m - n - 1][2] + min5(v[0][m - n]);
    res[0][m - n][1] = 'R';
    res[0][m - n][3] = 'R';
    n--;
  }
  n = m;
  l = m;
  for (int i = 1; i < m; i++)
    for (int j = 1; j < n; j++) {
      int res2 = min2(v[i][j]);
      int res5 = min5(v[i][j]);
      if (res[i - 1][j][0] < res[i][j - 1][0]) {
        res[i][j][0] = res[i - 1][j][0] + res2;
        res[i][j][1] = 'D';
      } else {
        res[i][j][0] = res[i][j - 1][0] + res2;
        res[i][j][1] = 'R';
      }
      if (res[i - 1][j][2] < res[i][j - 1][2]) {
        res[i][j][2] = res[i - 1][j][2] + res5;
        res[i][j][3] = 'D';
      } else {
        res[i][j][2] = res[i][j - 1][2] + res5;
        res[i][j][3] = 'R';
      }
    }
  int p;
  if (res[m - 1][m - 1][0] < res[m - 1][m - 1][2])
    p = 0;
  else
    p = 2;
  if (zeroi != -1 && res[m - 1][m - 1][p] > 1) {
    cout << "1" << endl;
    for (int i = 0; i < zeroi; i++) cout << "D";
    for (int i = 0; i < m - 1; i++) cout << "R";
    for (int i = zeroi; i < m - 1; i++) cout << "D";
    return 0;
  }
  cout << res[m - 1][m - 1][p] << endl;
  string s;
  int i = m - 1, j = m - 1;
  for (; i != 0 || j != 0;) {
    if (res[i][j][p + 1] == 'D') {
      s.insert(s.begin(), 'D');
      i--;
    } else {
      s.insert(s.begin(), 'R');
      j--;
    }
  }
  cout << s;
  return 0;
}
