#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int> > t;
vector<vector<int> > dp2, dp5;
vector<vector<int> > p2, p5;
vector<vector<int> > deg2, deg5;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  t.assign(n, vector<int>(n, 0));
  int fl = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> t[i][j];
      if (t[i][j] == 0) fl = 1;
    }
  }
  deg2.assign(n, vector<int>(n, 0));
  deg5.assign(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int x = t[i][j];
      if (x == 0) {
        deg2[i][j] = 1000000;
        deg5[i][j] = 1000000;
      } else {
        while (x % 2 == 0) {
          x /= 2;
          ++deg2[i][j];
        }
        while (x % 5 == 0) {
          x /= 5;
          ++deg5[i][j];
        }
      }
    }
  }
  p2.assign(n, vector<int>(n, -1));
  p5.assign(n, vector<int>(n, -1));
  dp2.assign(n, vector<int>(n, 10000000));
  dp5.assign(n, vector<int>(n, 10000000));
  dp2[0][0] = deg2[0][0];
  dp5[0][0] = deg5[0][0];
  for (int i = 1; i < n; ++i) {
    dp2[0][i] = dp2[0][i - 1] + deg2[0][i];
    dp5[0][i] = dp5[0][i - 1] + deg5[0][i];
    dp2[i][0] = dp2[i - 1][0] + deg2[i][0];
    dp5[i][0] = dp5[i - 1][0] + deg5[i][0];
    p2[0][i] = 0;
    p2[i][0] = 1;
    p5[0][i] = 0;
    p5[i][0] = 1;
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < n; ++j) {
      if (dp2[i][j - 1] < dp2[i - 1][j]) {
        dp2[i][j] = dp2[i][j - 1];
        p2[i][j] = 0;
      } else {
        dp2[i][j] = dp2[i - 1][j];
        p2[i][j] = 1;
      }
      dp2[i][j] += deg2[i][j];
      if (dp5[i][j - 1] < dp5[i - 1][j]) {
        dp5[i][j] = dp5[i][j - 1];
        p5[i][j] = 0;
      } else {
        dp5[i][j] = dp5[i - 1][j];
        p5[i][j] = 1;
      }
      dp5[i][j] += deg5[i][j];
    }
  }
  int r = min(dp2[n - 1][n - 1], dp5[n - 1][n - 1]);
  if (fl && r != 0) {
    cout << 1 << endl;
    int ii = 0;
    int jj = 0;
    bool go = true;
    for (int i = 0; i < n && go; ++i) {
      for (int j = 0; j < n && go; ++j) {
        if (t[i][j] == 0) {
          ii = i;
          jj = j;
          go = false;
        }
      }
    }
    int x = 0;
    int y = 0;
    while (x != ii || y != jj) {
      if (x < ii) {
        cout << "D";
        ++x;
      } else {
        cout << "R";
        ++y;
      }
    }
    while (x != n - 1 || y != n - 1) {
      if (x < n - 1) {
        cout << "D";
        ++x;
      } else {
        cout << "R";
        ++y;
      }
    }
  } else {
    cout << r << endl;
    if (dp2[n - 1][n - 1] > dp5[n - 1][n - 1]) swap(p2, p5);
    vector<char> res;
    int ii = n - 1, jj = n - 1;
    for (int i = 0; i < 2 * (n - 1); ++i) {
      if (p2[ii][jj]) {
        --ii;
        res.push_back('D');
      } else {
        --jj;
        res.push_back('R');
      }
    }
    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); ++i) cout << res[i];
  }
  return 0;
}
