#include <bits/stdc++.h>
using namespace std;
int mat[(int)1e3][(int)1e3], n;
int dp2[(int)1e3][(int)1e3];
int dp5[(int)1e3][(int)1e3];
int changeRow[] = {1, 0};
int changeCol[] = {0, 1};
int pw2[(int)1e3][(int)1e3], pw5[(int)1e3][(int)1e3];
int pwr(int n, int k) {
  int ret = 0;
  while (n >= k and n % k == 0) {
    ret++;
    n /= k;
  }
  return ret;
}
int rec2(int i, int j) {
  int &ret = dp2[i][j];
  if (i == n - 1 && j == n - 1) return ret = pw2[i][j];
  if (ret != -1) return ret;
  ret = 2e9;
  for (int x = 0; x < 2; x++) {
    int X = i + changeRow[x];
    int Y = j + changeCol[x];
    if (X < n and Y < n && X >= 0 && Y >= 0) {
      ret = min(ret, pw2[i][j] + rec2(X, Y));
    }
  }
  return ret;
}
int rec5(int i, int j) {
  int &ret = dp5[i][j];
  if (i == n - 1 && j == n - 1) return ret = pw5[i][j];
  if (ret != -1) return ret;
  ret = 2e9;
  for (int x = 0; x < 2; x++) {
    int X = i + changeRow[x];
    int Y = j + changeCol[x];
    if (X < n and Y < n && X >= 0 && Y >= 0)
      ret = min(ret, pw5[i][j] + rec5(X, Y));
  }
  return ret;
}
string ans = "";
int pwr2 = 0, pwr5 = 0;
void storeDir(int x) {
  if (x)
    ans += "R";
  else
    ans += "D";
}
void solve2(int i, int j) {
  if (i == n - 1 && j == n - 1) {
    pwr5 += pw5[i][j];
    return;
  }
  int ret = dp2[i][j];
  for (int x = 0; x < 2; x++) {
    int X = i + changeRow[x];
    int Y = j + changeCol[x];
    if (X < n && Y < n && X >= 0 && Y >= 0) {
      if (ret == dp2[X][Y] + pw2[i][j]) {
        pwr5 += pw5[i][j];
        storeDir(x);
        solve2(X, Y);
        return;
      }
    }
  }
}
void solve5(int i, int j) {
  if (i == n - 1 && j == n - 1) {
    pwr2 += pw2[i][j];
    return;
  }
  int ret = dp5[i][j];
  for (int x = 0; x < 2; x++) {
    int X = i + changeRow[x];
    int Y = j + changeCol[x];
    if (X < n && Y < n && X >= 0 && Y >= 0) {
      if (ret == dp5[X][Y] + pw5[i][j]) {
        pwr2 += pw2[i][j];
        storeDir(x);
        solve5(X, Y);
        return;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int x = 0; x < n; x++)
    for (int y = 0; y < n; y++) cin >> mat[x][y];
  bool hasZero = 0;
  pair<int, int> pos;
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      if (mat[x][y] == 0) {
        pos = make_pair(x, y);
        hasZero = true;
        break;
      }
    }
    if (hasZero) break;
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      pw2[x][y] = pwr(mat[x][y], 2);
      pw5[x][y] = pwr(mat[x][y], 5);
    }
  }
  memset(dp2, -1, sizeof(dp2));
  memset(dp5, -1, sizeof(dp5));
  int ans2 = rec2(0, 0);
  int ans5 = rec5(0, 0);
  int mn = min(ans2, ans5);
  if (hasZero && mn > 1) {
    cout << "1\n";
    for (int x = 0; x < pos.first; x++) cout << "D";
    for (int x = 0; x < pos.second; x++) cout << "R";
    for (int x = pos.first; x < n - 1; x++) cout << "D";
    for (int x = pos.second; x < n - 1; x++) cout << "R";
  } else {
    if (mn == ans2) {
      solve2(0, 0);
      cout << min(pwr5, ans2) << "\n";
      cout << ans << "\n";
    } else {
      solve5(0, 0);
      cout << min(pwr2, ans5) << "\n";
      cout << ans << "\n";
    }
  }
}
