#include <bits/stdc++.h>
using namespace std;
long long int a[1000][1000], dp2[1000][1000], dp5[1000][1000], n;
string getpath(long long int b[1000][1000]) {
  string s = "";
  long long int i = n - 1, j = n - 1;
  while (i > 0 && j > 0) {
    if (b[i - 1][j] < b[i][j - 1]) {
      i--;
      s += "D";
    } else {
      j--;
      s += "R";
    }
  }
  while (i > 0) {
    s += "D";
    i--;
  }
  while (j > 0) {
    s += "R";
    j--;
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  memset(a, 0, sizeof a);
  memset(dp2, 0, sizeof dp2);
  memset(dp5, 0, sizeof dp5);
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  string s1 = "", s2 = "";
  long long int res1 = 0, res2 = 0, c2, c5;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (a[i][j] == 0) {
        if (res1 == 0) {
          s1.append(j, 'R');
          s1.append(n - 1, 'D');
          s1.append(n - j - 1, 'R');
          res1 = 1;
        }
        continue;
      }
      c2 = c5 = 0;
      while (a[i][j] % 2 == 0) {
        c2++;
        a[i][j] /= 2;
      }
      while (a[i][j] % 5 == 0) {
        c5++;
        a[i][j] /= 5;
      }
      dp2[i][j] = c2;
      dp5[i][j] = c5;
    }
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (i == 0 && j == 0)
        continue;
      else if (i == 0) {
        dp2[i][j] += dp2[i][j - 1];
        dp5[i][j] += dp5[i][j - 1];
      } else if (j == 0) {
        dp2[i][j] += dp2[i - 1][j];
        dp5[i][j] += dp5[i - 1][j];
      } else {
        dp2[i][j] += min(dp2[i - 1][j], dp2[i][j - 1]);
        dp5[i][j] += min(dp5[i - 1][j], dp5[i][j - 1]);
      }
    }
  }
  if (dp2[n - 1][n - 1] < dp5[n - 1][n - 1]) {
    res2 = dp2[n - 1][n - 1];
    s2 = getpath(dp2);
  } else {
    res2 = dp5[n - 1][n - 1];
    s2 = getpath(dp5);
  }
  if (res1 < res2 && res1 != 0)
    cout << res1 << "\n" << s1 << "\n";
  else
    cout << res2 << "\n" << s2 << "\n";
  return 0;
}
