#include <bits/stdc++.h>
using namespace std;
int n;
bool path2[1000 + 1][1000 + 1];
bool path5[1000 + 1][1000 + 1];
int twos[1001][1000 + 1];
int fives[1001][1000 + 1];
int nums[1000 + 1][1000 + 1];
int z[2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &nums[i][j]);
      if (nums[i][j] == 0) {
        z[0] = i, z[1] = j;
        nums[i][j] = true;
      }
    }
  }
  while (!(nums[0][0] % 2)) {
    twos[0][0]++;
    nums[0][0] /= 2;
  }
  while (!(nums[0][0] % 5)) {
    fives[0][0]++;
    nums[0][0] /= 5;
  }
  for (int i = 1; i < n; i++) {
    while (!(nums[0][i] % 2)) {
      twos[0][i]++;
      nums[0][i] /= 2;
    }
    while (!(nums[0][i] % 5)) {
      fives[0][i]++;
      nums[0][i] /= 5;
    }
    twos[0][i] += twos[0][i - 1];
    fives[0][i] += fives[0][i - 1];
    path2[0][i] = 0;
    path5[0][i] = 0;
  }
  for (int i = 1; i < n; i++) {
    while (!(nums[i][0] % 2)) {
      twos[i][0]++;
      nums[i][0] /= 2;
    }
    while (!(nums[i][0] % 5)) {
      fives[i][0]++;
      nums[i][0] /= 5;
    }
    twos[i][0] += twos[i - 1][0];
    fives[i][0] += fives[i - 1][0];
    path2[i][0] = 1;
    path5[i][0] = 1;
    for (int j = 1; j < n; j++) {
      while (!(nums[i][j] % 2)) {
        twos[i][j]++;
        nums[i][j] /= 2;
      }
      while (!(nums[i][j] % 5)) {
        fives[i][j]++;
        nums[i][j] /= 5;
      }
      if (twos[i][j - 1] < twos[i - 1][j]) {
        twos[i][j] += twos[i][j - 1];
        path2[i][j] = 0;
      } else {
        twos[i][j] += twos[i - 1][j];
        path2[i][j] = 1;
      }
      if (fives[i][j - 1] < fives[i - 1][j]) {
        fives[i][j] += fives[i][j - 1];
        path5[i][j] = 0;
      } else {
        fives[i][j] += fives[i - 1][j];
        path5[i][j] = 1;
      }
    }
  }
  vector<char> v;
  if (twos[(n - 1)][n - 1] < fives[(n - 1)][n - 1]) {
    if (twos[n - 1][n - 1] > 1) {
      if (z[0] | z[1]) {
        cout << 1 << endl;
        for (int i = 0; i < z[0]; i++) cout << 'D';
        for (int i = 0; i < z[1]; i++) cout << 'R';
        for (int i = z[0]; i < n - 1; i++) cout << 'D';
        for (int i = z[1]; i < n - 1; i++) cout << 'R';
        return 0;
      }
    }
    cout << twos[(n - 1)][n - 1] << endl;
    int i = n - 1, j = n - 1;
    while (i != 0 || j != 0) {
      if (path2[i][j] == 0) {
        v.push_back('R');
        j--;
      } else {
        v.push_back('D');
        i--;
      }
    }
  } else {
    if (fives[n - 1][n - 1] > 1) {
      if (z[0] | z[1]) {
        cout << 1 << endl;
        for (int i = 0; i < z[0]; i++) cout << 'D';
        for (int i = 0; i < z[1]; i++) cout << 'R';
        for (int i = z[0]; i < n - 1; i++) cout << 'D';
        for (int i = z[1]; i < n - 1; i++) cout << 'R';
        return 0;
      }
    }
    cout << fives[(n - 1)][n - 1] << endl;
    int i = n - 1, j = n - 1;
    while (i != 0 || j != 0) {
      if (path5[i][j] == 0) {
        v.push_back('R');
        j--;
      } else {
        v.push_back('D');
        i--;
      }
    }
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    printf("%c", v[i]);
  }
  return 0;
}
