#include <bits/stdc++.h>
using namespace std;
#define All(A) (A).begin(), (A).end()
#define SZ(A) int((A).size())
#define pr_q priority_queue
#define pb push_back
#define mp make_pair
#define INF (1<<30)
#define sc second
#define fr first
const long double PI = 3.1415926535897932384633832795;
const double EPS = 1e-7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int MAXN = int(1e5);
int A, n;
int B[1002][1002];
pair<ii, int> ans[1002][1002];
string dir[1002][1002];
int L(int x) {
if(x % 10 != 0) return 0;
int d = 0;
while(x > 0 && x % 10 == 0)
x /= 10, d++;
return d;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n; scanf("%d", &n);
int z = 0, x, y;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++){
scanf("%d", &A);
if(A == 2 || A == 5)
B[i][j] = A;
if(!A)
{ z++, x = i, y = j; continue; }
if(A && A % 10 == 0) {
B[i][j] = 1;
while(A % 10 == 0) A/= 10, B[i][j] *= 10;
}
}
if(z) {
string res = "";
for(int i = 0; i < y; i++) res += "R";
for(int i = 0; i < n - 1; i++) res += "D";
for(int i = y+1; i < n; i++) res += "R";
puts("0");
puts(res.c_str());
return 0;
}
dir[0][0] = "";
ans[0][0] = mp(ii(B[0][0]==2, B[0][0]== 5), L(B[0][0]));
for(int i = 1; i < n; i++) {
ans[i][0].fr.fr = (B[i][0] == 2) + ans[i - 1][0].fr.fr;
ans[i][0].fr.sc = (B[i][0] == 5) + ans[i - 1][0].fr.sc;
ans[i][0].sc = L(B[i][0]) + ans[i - 1][0].sc;
dir[i][0] = dir[i - 1][0] + "D";
ans[0][i].fr.fr = (B[0][i] == 2) + ans[0][i - 1].fr.fr;
ans[0][i].fr.sc = (B[0][i] == 5)+ ans[0][i - 1].fr.sc;
ans[0][i].sc = L(B[0][i]) + ans[0][i - 1].sc;
dir[0][i] = dir[0][i - 1] + "R";
}
for(int i = 1; i < n; i++) {
for(int j = 1; j < n; j++) {
if(ans[i][j - 1].sc + min(ans[i][j - 1].fr.fr, ans[i][j - 1].fr.sc) <=
ans[i - 1][j].sc + min(ans[i - 1][j].fr.fr, ans[i - 1][j].fr.sc)) {
dir[i][j] = dir[i][j - 1] + "R";
ans[i][j].fr.fr = (B[i][j] == 2) + ans[i][j - 1].fr.fr;
ans[i][j].fr.sc = (B[i][j] == 5) + ans[i][j - 1].fr.sc;
ans[i][j].sc = L(B[i][j]) + ans[i][j - 1].sc;
}else {
dir[i][j] = dir[i - 1][j] + "D";
ans[i][j].fr.fr = (B[i][j] == 2) + ans[i - 1][j].fr.fr;
ans[i][j].fr.sc = (B[i][j] == 5) + ans[i - 1][j].fr.sc;
ans[i][j].sc = L(B[i][j]) + ans[i - 1][j].sc;
}
}
}
/*for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cout << ans[i][j].fr.fr << " " << ans[i][j].fr.sc << "\n";
}
cout << "\n";
}*/
cout << min(ans[n-1][n-1].fr.fr, ans[n-1][n-1].fr.sc) + ans[n-1][n-1].sc << "\n" << dir[n-1][n-1] << "\n";
}