#include <bits/stdc++.h>
using namespace std;
struct state {
  char direction = 0;
  unsigned long cnt = 0;
  void set(const state& s, char direction, unsigned long count) {
    this->direction = direction;
    this->cnt = s.cnt + count;
  }
};
unsigned long count(int input, int n) {
  unsigned long cnt = 0;
  while (input != 0 && input % n == 0) {
    input /= n;
    cnt++;
  }
  return cnt;
}
vector<vector<state>> dp(vector<vector<int>> input, int n) {
  vector<vector<state>> s(input.size());
  for (int i = 0; i < input.size(); i++) {
    s[i] = vector<state>(input.size());
    for (int j = 0; j < input.size(); j++) {
      unsigned long c = count(input[i][j], n);
      if (i == 0 && j == 0) {
        s[i][j].cnt = c;
        continue;
      }
      int left_num = 9999999;
      if (j != 0) {
        left_num = s[i][j - 1].cnt;
      }
      if (i == 0 || left_num < s[i - 1][j].cnt) {
        s[i][j].set(s[i][j - 1], 'R', c);
      } else {
        s[i][j].set(s[i - 1][j], 'D', c);
      }
    }
  }
  return s;
}
void output(const vector<vector<state>>& s) {
  string path;
  int i = s.size() - 1;
  int j = s.size() - 1;
  while (i != 0 || j != 0) {
    char d = s[i][j].direction;
    path.push_back(d);
    if (d == 'R') {
      j--;
    } else {
      i--;
    }
  }
  reverse(path.begin(), path.end());
  cout << path << endl;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> input(n);
  int zero_i = -1, zero_j = -1;
  for (int i = 0; i < n; i++) {
    input[i] = vector<int>(n);
    for (int j = 0; j < n; j++) {
      cin >> input[i][j];
      if (input[i][j] == 0) {
        zero_i = i;
        zero_j = j;
      }
    }
  }
  auto dp2 = dp(input, 2);
  auto dp5 = dp(input, 5);
  if (zero_i != -1 && dp2[n - 1][n - 1].cnt > 0 && dp5[n - 1][n - 1].cnt > 0) {
    cout << 1 << endl;
    cout << string(zero_i, 'D') << string(zero_j, 'R')
         << string(n - zero_i - 1, 'D') << string(n - zero_j - 1, 'R') << endl;
  } else {
    int zero_num = min(dp2[n - 1][n - 1].cnt, dp5[n - 1][n - 1].cnt);
    cout << zero_num << endl;
    output(dp2[n - 1][n - 1].cnt < dp5[n - 1][n - 1].cnt ? dp2 : dp5);
  }
  return 0;
}
