#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 2;
int a[MAX][MAX];
int n;
int dp[MAX][MAX][2];
int ex2[MAX][MAX];
int ex5[MAX][MAX];
bool contain0 = false;
int row0 = -1;
int col0 = -1;
void display(int row, int col, int somu);
int somu2(int n) {
  int res = 0;
  while (n % 2 == 0) {
    res++;
    n = n / 2;
  }
  return res;
}
int somu5(int n) {
  int res = 0;
  while (n % 5 == 0) {
    res++;
    n = n / 5;
  }
  return res;
}
void input() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      if (a[i][j] == 0) {
        a[i][j] = 10;
        contain0 = true;
        row0 = i;
        col0 = j;
      }
      ex2[i][j] = somu2(a[i][j]);
      ex5[i][j] = somu5(a[i][j]);
    }
  }
}
void quyhoach() {
  int result;
  dp[1][1][0] = somu2(a[1][1]);
  dp[1][1][1] = somu5(a[1][1]);
  for (int i = 2; i <= n; i++) {
    dp[1][i][0] = dp[1][i - 1][0] + ex2[1][i];
    dp[1][i][1] = dp[1][i - 1][1] + ex5[1][i];
    dp[i][1][0] = dp[i - 1][1][0] + ex2[i][1];
    dp[i][1][1] = dp[i - 1][1][1] + ex5[i][1];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= n; j++) {
      int minsomu2 = min(dp[i - 1][j][0], dp[i][j - 1][0]);
      dp[i][j][0] = minsomu2 + ex2[i][j];
      int minsomu5 = min(dp[i - 1][j][1], dp[i][j - 1][1]);
      dp[i][j][1] = minsomu5 + ex5[i][j];
    }
  }
  if (!contain0) {
    if (dp[n][n][0] < dp[n][n][1]) {
      cout << dp[n][n][0] << endl;
      display(n, n, 2);
      cout << endl;
    } else {
      cout << dp[n][n][1] << endl;
      display(n, n, 5);
      cout << endl;
    }
  } else {
    if (dp[n][n][0] == 0) {
      cout << dp[n][n][0] << endl;
      display(n, n, 2);
      cout << endl;
    } else if (dp[n][n][1] == 0) {
      cout << dp[n][n][1] << endl;
      display(n, n, 5);
      cout << endl;
    } else {
      cout << "1" << endl;
      for (int i = 1; i < row0; i++) {
        cout << "D";
      }
      for (int j = 1; j < n; j++) {
        cout << "R";
      }
      for (int i = row0; i < n; i++) {
        cout << "D";
      }
      cout << endl;
    }
  }
}
void display(int row, int col, int somu) {
  if (row == 1 && col == 1) return;
  if (row == 1 && col != 1) {
    display(row, col - 1, somu);
    cout << "R";
  } else if (row != 1 && col == 1) {
    display(row - 1, col, somu);
    cout << "D";
  } else {
    if (somu == 2) {
      int temp = dp[row][col][0] - ex2[row][col];
      if (temp == dp[row][col - 1][0]) {
        display(row, col - 1, somu);
        cout << "R";
      } else if (temp == dp[row - 1][col][0]) {
        display(row - 1, col, somu);
        cout << "D";
      }
    } else if (somu == 5) {
      int temp = dp[row][col][1] - ex5[row][col];
      if (temp == dp[row][col - 1][1]) {
        display(row, col - 1, somu);
        cout << "R";
      } else if (temp == dp[row - 1][col][1]) {
        display(row - 1, col, somu);
        cout << "D";
      }
    }
  }
}
int main() {
  input();
  quyhoach();
  return 0;
}
