#include <bits/stdc++.h>
using namespace std;
int n, a[1001][1001];
pair<int, int> dp[1001][1001];
pair<char, char> mo[1001][1001];
string pas;
int nx = -1, ny = -1;
int number_of_2(int v) {
  int r = 0;
  while (v % 2 == 0) {
    r++;
    v /= 2;
  }
  return r;
}
int number_of_5(int v) {
  int r = 0;
  while (v % 5 == 0) {
    r++;
    v /= 5;
  }
  return r;
}
int main() {
  cin >> n;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++) {
      cin >> a[k][i];
      if (a[k][i] == 0) {
        a[k][i] = 10;
        nx = k;
        ny = i;
      }
    }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      int r2 = number_of_2(a[k][i]);
      int r5 = number_of_5(a[k][i]);
      if (k == 1) {
        dp[k][i].first = dp[k][i - 1].first + r2;
        dp[k][i].second = dp[k][i - 1].second + r5;
        mo[k][i].first = 'R';
        mo[k][i].second = 'R';
      } else {
        if (i == 1) {
          dp[k][i].first = dp[k - 1][i].first + r2;
          dp[k][i].second = dp[k - 1][i].second + r5;
          mo[k][i].first = 'D';
          mo[k][i].second = 'D';
        } else {
          if (dp[k][i - 1].first + r2 < dp[k - 1][i].first + r2) {
            dp[k][i].first = dp[k][i - 1].first + r2;
            mo[k][i].first = 'R';
          } else {
            dp[k][i].first = dp[k - 1][i].first + r2;
            mo[k][i].first = 'D';
          }
          if (dp[k][i - 1].second + r5 < dp[k - 1][i].second + r5) {
            dp[k][i].second = dp[k][i - 1].second + r5;
            mo[k][i].second = 'R';
          } else {
            dp[k][i].second = dp[k - 1][i].second + r5;
            mo[k][i].second = 'D';
          }
        }
      }
    }
  }
  int ans = min(dp[n][n].first, dp[n][n].second);
  if (nx != -1 && ny != -1 && ans != 0) {
    cout << 1 << endl;
    for (int k = 1; k < nx; k++) printf("D");
    for (int k = 1; k < n; k++) printf("R");
    for (int k = nx; k < n; k++) printf("D");
    return 0;
  }
  mo[1][1] = {'S', 'S'};
  if (dp[n][n].second < dp[n][n].first) {
    char ch = mo[n][n].second;
    int l = n, r = n;
    while (ch != 'S') {
      pas += ch;
      if (ch == 'D') {
        l--;
        ch = mo[l][r].second;
      } else {
        r--;
        ch = mo[l][r].second;
      }
    }
  } else {
    char ch = mo[n][n].first;
    int l = n, r = n;
    while (ch != 'S') {
      pas += ch;
      if (ch == 'D') {
        l--;
        ch = mo[l][r].first;
      } else {
        r--;
        ch = mo[l][r].first;
      }
    }
  }
  cout << ans << endl;
  for (int k = pas.size() - 1; k >= 0; k--) cout << pas[k];
  return 0;
}
