#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MAX_N = 1005;
int n, zero_x, zero_y;
int bases[] = {2, 5};
int dx[] = {0, -1};
int dy[] = {-1, 0};
int dc[] = {'R', 'D'};
int raw[2][MAX_N][MAX_N];
int dp[2][MAX_N][MAX_N];
int par[2][MAX_N][MAX_N];
char ans[2 * MAX_N];
int main() {
  scanf(" %d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int x;
      scanf(" %d", &x);
      if (x == 0) {
        zero_x = i;
        zero_y = j;
        continue;
      }
      for (int b = 0; b < 2; ++b) {
        ll base = bases[b];
        while (x % base == 0) {
          ++raw[b][i][j];
          base *= bases[b];
        }
      }
    }
  }
  for (int b = 0; b < 2; ++b) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (i == 1 && j == 1) {
          dp[b][i][j] = raw[b][i][j];
        } else if (i == 1 || (j > 1 && dp[b][i][j - 1] < dp[b][i - 1][j])) {
          dp[b][i][j] = raw[b][i][j] + dp[b][i][j - 1];
        } else {
          dp[b][i][j] = raw[b][i][j] + dp[b][i - 1][j];
          par[b][i][j] = 1;
        }
      }
    }
  }
  int which = 1;
  if (dp[0][n][n] < dp[1][n][n]) {
    which = 0;
  }
  if (zero_x != 0 && (1 < dp[which][n][n])) {
    printf("1\n");
    for (int i = 1; i < zero_x; ++i) {
      printf("D");
    }
    for (int j = 1; j < zero_y; ++j) {
      printf("R");
    }
    for (int i = zero_x; i < n; ++i) {
      printf("D");
    }
    for (int j = zero_y; j < n; ++j) {
      printf("R");
    }
    printf("\n");
    return 0;
  }
  int x = n, y = n, idx = 2 * n - 2;
  while (x != 1 || y != 1) {
    int d = par[which][x][y];
    x += dx[d];
    y += dy[d];
    ans[idx--] = dc[d];
  }
  assert(idx == 0);
  printf("%d\n", dp[which][n][n]);
  for (idx = 1; idx <= 2 * n - 2; ++idx) {
    printf("%c", ans[idx]);
  }
  printf("\n");
  return 0;
}
