#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
long long dcmp(double a, double b) {
  return (fabs(a - b) <= eps) ? 0 : ((a < b) ? -1 : 1);
}
int two = 2;
int five = 5;
int n;
pair<int, int> arr[1024][1024];
pair<int, int> mem[1024][1024];
pair<int, int> get(int n) {
  if (n == 0) return make_pair(0, 0);
  pair<int, int> res = make_pair(0, 0);
  while (n % two == 0) {
    n /= two;
    res.first++;
  }
  while (n % five == 0) {
    n /= five;
    res.second++;
  }
  return res;
}
pair<int, int> add(pair<int, int> p1, pair<int, int> p2) {
  return make_pair(p1.first + p2.first, p1.second + p2.second);
}
pair<int, int> calc(int r, int c) {
  if (c == n - 1 && r == n - 1) return arr[r][c];
  pair<int, int> &ret = mem[r][c];
  if (ret.first != -1) return ret;
  ret = make_pair(oo, oo);
  pair<int, int> cur = arr[r][c], res;
  if (r < n - 1) ret = min(ret, add(calc(r + 1, c), cur));
  if (c < n - 1) ret = min(ret, add(calc(r, c + 1), cur));
  return ret;
}
vector<char> res;
void path(int r, int c) {
  if (c == n - 1 && r == n - 1) return;
  pair<int, int> ret = calc(r, c);
  pair<int, int> cur = arr[r][c];
  if (r < n - 1) {
    pair<int, int> ret1 = add(calc(r + 1, c), cur);
    if (ret == ret1) {
      res.push_back('D');
      path(r + 1, c);
      return;
    }
  }
  if (c < n - 1) {
    pair<int, int> ret2 = add(calc(r, c + 1), cur);
    if (ret == ret2) {
      res.push_back('R');
      path(r, c + 1);
      return;
    }
  }
  return;
}
int main() {
  if (scanf("%d", &n) == EOF) return 0;
  bool zero = false;
  int x, zeroi, zeroj;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &x);
      arr[i][j] = get(x);
      if (x == 0) {
        zero = true;
        zeroi = i;
        zeroj = j;
      }
    }
  memset(mem, -1, sizeof mem);
  pair<int, int> ans = calc(0, 0);
  res.clear();
  path(0, 0);
  vector<char> path1 = res;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) swap(arr[i][j].first, arr[i][j].second);
  memset(mem, -1, sizeof mem);
  pair<int, int> ans2 = calc(0, 0);
  if (min(ans.first, ans.second) < min(ans2.first, ans2.second)) {
    x = min(ans.first, ans.second);
  } else {
    x = min(ans2.first, ans2.second);
    res.clear();
    path(0, 0);
  }
  if (zero && x > 1) {
    cout << 1 << endl;
    for (int i = 0; i < zeroi; i++) cout << "D";
    for (int j = 0; j < zeroj; j++) cout << "R";
    for (int i = zeroi; i < n - 1; i++) cout << "D";
    for (int j = zeroj; j < n - 1; j++) cout << "R";
    cout << endl;
  } else {
    cout << x << endl;
    for (int i = 0; i < (long long)res.size(); i++) printf("%c", res[i]);
    printf("\n");
  }
  return 0;
}
