#include <bits/stdc++.h>   using namespace std;   int mat[(int)1e3][(int)1e3], n;   int dp2[(int)1e3][(int)1e3];   int dp5[(int)1e3][(int)1e3];   int changeRow[] = {1, 0};   int changeCol[] = {0, 1};   int pw2[(int)1e3][(int)1e3], pw5[(int)1e3][(int)1e3];   string dir[] = { D ,  R };   int pwr(int n, int k) {     int ret = 0;     while (n >= k and n % k == 0) {       ret++;       n /= k;     }     return ret;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (int x = 0; x < n; x++)       for (int y = 0; y < n; y++) cin >> mat[x][y];     bool hasZero = 0;     pair<int, int> pos;     for (int x = 0; x < n; x++) {       for (int y = 0; y < n; y++) {         if (mat[x][y] == 0) {           pos = make_pair(x, y);           hasZero = true;           break;         }       }       if (hasZero) break;     }     for (int x = 0; x < n; x++) {       for (int y = 0; y < n; y++) {         pw2[x][y] = pwr(mat[x][y], 2);         pw5[x][y] = pwr(mat[x][y], 5);       }     }     for (int x = 0; x < n; x++) {       for (int y = 0; y < n; y++) {         dp2[x][y] = 2e9;         dp5[x][y] = 2e9;       }     }     dp2[0][0] = pw2[0][0];     for (int x = 0; x < n; x++) {       for (int y = 0; y < n; y++) {         for (int z = 0; z < 2; z++) {           int X = x + changeRow[z];           int Y = y + changeCol[z];           if (X == x and Y == y) continue;           if (X >= 0 and Y >= 0 and X < n and Y < n) {             dp2[X][Y] = min(dp2[X][Y], pw2[X][Y] + dp2[x][y]);           }         }       }     }     dp5[0][0] = pw5[0][0];     for (int x = 0; x < n; x++) {       for (int y = 0; y < n; y++) {         for (int z = 0; z < 2; z++) {           int X = x + changeRow[z];           int Y = y + changeCol[z];           if (X == x and Y == y) continue;           if (X >= 0 and Y >= 0 and X < n and Y < n) {             dp5[X][Y] = min(dp5[X][Y], pw5[X][Y] + dp5[x][y]);           }         }       }     }     int res2 = dp2[n - 1][n - 1];     int res5 = dp5[n - 1][n - 1];     int res = min(res2, res5);     string ans =   ;     if (hasZero && res > 1) {       cout <<  1 n ;       for (int x = 0; x < pos.first; x++) cout <<  D ;       for (int x = 0; x < pos.second; x++) cout <<  R ;       for (int x = pos.first; x < n - 1; x++) cout <<  D ;       for (int x = pos.second; x < n - 1; x++) cout <<  R ;     } else if (res == res2) {       cout << res <<   n ;       int i = n - 1, j = n - 1;       while (!(i == 0 and j == 0)) {         for (int z = 0; z < 2; z++) {           int X = i - changeRow[z];           int Y = j - changeCol[z];           if (X == i and Y == j) continue;           if (X >= 0 and Y >= 0 and X < n and Y < n) {             if (dp2[i][j] == dp2[X][Y] + pw2[i][j]) {               ans += dir[z];               i = X;               j = Y;               break;             }           }         }       }       assert(i == 0 and j == 0);       reverse(ans.begin(), ans.end());       for (auto x : ans) cout << x;       cout <<   n ;     } else {       cout << res <<   n ;       assert(res == res5);       int i = n - 1, j = n - 1;       while (!(i == 0 and j == 0)) {         for (int z = 0; z < 2; z++) {           int X = i - changeRow[z];           int Y = j - changeCol[z];           if (X == i and Y == j) continue;           if (X >= 0 and Y >= 0 and X < n and Y < n) {             if (dp5[i][j] == dp5[X][Y] + pw5[i][j]) {               ans += dir[z];               i = X;               j = Y;               break;             }           }         }       }       assert(i == 0 and j == 0);       reverse(ans.begin(), ans.end());       for (auto x : ans) cout << x;       cout <<   n ;     }   }