#include <bits/stdc++.h>
using namespace std;
pair<int, int> decompose(int n) {
  int count_2 = 0;
  int count_5 = 0;
  while (!(n & 1)) {
    count_2++;
    n /= 2;
  }
  while (!(n % 5)) {
    count_5++;
    n /= 5;
  }
  return make_pair(count_2, count_5);
}
pair<int, int> comuteZeros(pair<int, int>** arr, int n) {
  for (int i = 1; i < n; i++) {
    arr[0][i].first += arr[0][i - 1].first;
    arr[0][i].second += arr[0][i - 1].second;
  }
  for (int i = 1; i < n; i++) {
    arr[i][0].first += arr[i - 1][0].first;
    arr[i][0].second += arr[i - 1][0].second;
    for (int j = 1; j < n; j++) {
      arr[i][j].first += min(arr[i - 1][j].first, arr[i][j - 1].first);
      arr[i][j].second += min(arr[i - 1][j].second, arr[i][j - 1].second);
    }
  }
  n -= 1;
  int& a = arr[n][n].first;
  int& b = arr[n][n].second;
  if (a <= b)
    return make_pair(a, 2);
  else
    return make_pair(b, 5);
}
inline void printNSteps(int beg, int end, string& str, char c) {
  for (int i = beg; i < end; i++) str[i] = c;
}
string findPath(int pos, int n) {
  string path;
  path.resize(2 * (n - 1));
  printNSteps(0, pos, path, 'R');
  printNSteps(0, n, path, 'D');
  printNSteps(pos, n, path, 'R');
  return path;
}
template <class T>
string findPath(pair<int, int>** arr, int n, T f) {
  string path;
  int size = 2 * (n - 1);
  path.resize(size);
  int index = size - 1;
  int i = n - 1;
  int j = i;
  do {
    if (f(arr[i][j - 1]) <= f(arr[i - 1][j])) {
      path[index] = 'R';
      j--;
    } else {
      path[index] = 'D';
      i--;
    }
    index--;
  } while (i != 0 && j != 0);
  if (i == 0)
    printNSteps(0, index + 1, path, 'R');
  else
    printNSteps(0, index + 1, path, 'D');
  return path;
}
inline const int& get_2(const pair<int, int>& x) { return x.first; }
inline const int& get_5(const pair<int, int>& x) { return x.second; }
int main() {
  int n;
  cin >> n;
  pair<int, int>** arr = new pair<int, int>*[n];
  arr[0] = new pair<int, int>[n * n];
  for (int i = 1; i < n; i++) arr[i] = arr[0] + i * n;
  int tmp;
  int zeroPosition = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> tmp;
      if (!tmp) {
        zeroPosition = j;
        arr[i][j] = make_pair(2, 5);
      } else
        arr[i][j] = decompose(tmp);
    }
  pair<int, int> countZeros = comuteZeros(arr, n);
  if (zeroPosition != -1 && countZeros.first >= 1)
    cout << 1 << endl << findPath(zeroPosition, n);
  else
    cout << countZeros.first << endl
         << findPath(arr, n, (countZeros.second == 2) ? get_2 : get_5);
  return 0;
}
