#include <bits/stdc++.h>
int matrix1[1000][1000];
int matrix2[1000][1000];
int matrix3[1000][1000];
char path[1000][1000];
char path1[2000], path2[2000];
int n;
int min(int a, int b) { return a > b ? b : a; }
int Dp(int k) {
  int i, j, sum, count, m;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      if (matrix1[i][j] != 0) {
        count = 0;
        m = matrix1[i][j];
        while (m % k == 0) {
          count++;
          m /= k;
        }
        matrix2[i][j] = count;
      }
    }
  sum = 0;
  for (i = n - 1; i >= 0; i--) {
    if (matrix1[n - 1][i] == 0) {
      for (j = i; j >= 0; j--) matrix3[n - 1][j] = 0X3F3F3F3F;
      break;
    } else {
      sum += matrix2[n - 1][i];
      matrix3[n - 1][i] = sum;
    }
    if (i != n - 1) path[n - 1][i] = 'R';
  }
  sum = 0;
  for (i = n - 1; i >= 0; i--) {
    if (matrix1[i][n - 1] == 0) {
      for (j = i; j >= 0; j--) matrix3[j][n - 1] = 0X3F3F3F3F;
      break;
    } else {
      sum += matrix2[i][n - 1];
      matrix3[i][n - 1] = sum;
    }
    if (i != n - 1) path[i][n - 1] = 'D';
  }
  for (i = n - 2; i >= 0; i--) {
    for (j = n - 2; j >= 0; j--) {
      if (matrix1[i][j] == 0) {
        matrix3[i][j] = 0X3F3F3F3F;
        path[i][j] = 'D';
      } else {
        if (matrix3[i][j + 1] < matrix3[i + 1][j]) {
          matrix3[i][j] = matrix3[i][j + 1] + matrix2[i][j];
          path[i][j] = 'R';
        } else {
          if (matrix3[i + 1][j] == 0X3F3F3F3F)
            matrix3[i][j] = 0X3F3F3F3F;
          else
            matrix3[i][j] = matrix3[i + 1][j] + matrix2[i][j];
          path[i][j] = 'D';
        }
      }
    }
  }
  return matrix3[0][0];
}
int main() {
  int i, j, flag, keep1, keep2, x, y, a, b;
  while (scanf("%d", &n) != EOF) {
    flag = 0;
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) {
        scanf("%d", &matrix1[i][j]);
        if (matrix1[i][j] == 0) {
          flag = 1;
          x = i;
          y = j;
        }
      }
    keep1 = Dp(2);
    a = b = 0;
    for (i = 1; i <= 2 * n - 2; i++) {
      path1[i - 1] = path[a][b];
      if (path[a][b] == 'D')
        a++;
      else
        b++;
    }
    keep2 = Dp(5);
    a = b = 0;
    for (i = 1; i <= 2 * n - 2; i++) {
      path2[i - 1] = path[a][b];
      if (path[a][b] == 'D')
        a++;
      else
        b++;
    }
    if (flag == 0) {
      printf("%d\n", min(keep1, keep2));
      if (keep1 < keep2) {
        for (i = 0; i < 2 * n - 2; i++) printf("%c", path1[i]);
        putchar('\n');
      } else {
        for (i = 0; i < 2 * n - 2; i++) printf("%c", path2[i]);
        putchar('\n');
      }
    } else {
      printf("%d\n", min(1, min(keep1, keep2)));
      if (min(keep1, keep2) >= 1) {
        for (i = 1; i <= y; i++) putchar('R');
        for (i = 1; i <= x; i++) putchar('D');
        for (i = 1; i <= n - 1 - y; i++) putchar('R');
        for (i = 1; i <= n - 1 - x; i++) putchar('D');
        putchar('\n');
      } else {
        if (keep1 < keep2) {
          for (i = 0; i < 2 * n - 2; i++) printf("%c", path1[i]);
          putchar('\n');
        } else {
          for (i = 0; i < 2 * n - 2; i++) printf("%c", path2[i]);
          putchar('\n');
        }
      }
    }
  }
  return 0;
}
