var size = parseInt(readline());

var matrix = [];
var column;
var row;
var zeroPosition = null;
for (column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(n => parseInt(n)));

  for (row = 0; row < size; row++) if (matrix[column][row] === 0) zeroPosition = [column, row];
}

function factorize(prime, num) {
  if (num === 0) return 0;
  var count = 0;
  while (num % prime === 0) {num /= prime; count++}
  return count;
}

var accMatrix = [];
var accPath = [];
var path = "";
function accumulate(prime) {

  for (column = 0; column < size; column++) {
    accMatrix[column] = [];
    accPath[column] = [];
  }
  accMatrix[0][0] = factorize(prime, matrix[0][0]);
  accPath[0][0] = "";
  // print('accMatrix[0][0]', accMatrix[0][0])
  // print('accPath[0][0]', accPath[0][0])

  for (column = 1; column < size; column++) {
    accMatrix[0][column] = accMatrix[0][column - 1] + factorize(prime, matrix[0][column]);
    accPath[0][column] = "R";
    accMatrix[column][0] = accMatrix[column - 1][0] + factorize(prime, matrix[column][0]);
    accPath[column][0] = "D";
  }

  for (column = 1; column < size; column++) for (row = 1; row < size; row++) {
    accMatrix[column][row] = factorize(prime, matrix[column][row]);
    if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
      accMatrix[column][row] += accMatrix[column - 1][row];
      accPath[column][row] = "D";
    } else {
      accMatrix[column][row] += accMatrix[column][row - 1];
      accPath[column][row] = "R";
    }

  }

  path = "";
  for (column = size - 1; column >= 0;) for (row = size - 1; row >= 0;) {
    if (column === 0 && row === 0) {column--; row--;}
    else {
      path = accPath[column][row] + path;
      if (accPath[column][row] === "D") column--;
      else row--;
    }
  }

  return [accMatrix[size - 1][size - 1], path]
}

var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;
var i = 0;
function getPathWith(coordinates) {
  path = "";
  for (i = 0; i < coordinates[0]; i++) path += "D";
  for (i = 0; i < size - 1; i++) path += "R";
  for (i = coordinates[0]; i < size - 1; i++) path += "D";
  return path;
}

if (zeroPosition !== null && best[0] > 1) best = [1, getPathWith(zeroPosition)]

print(best[0]);
print(best[1]);

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

var re = /0*$/;

var hasZero = false;
var pathZero;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];

      if (value === 0) {
         if (!hasZero) {
            hasZero = true;
            pathZero =
               (new Array(i + 1)).join('D') +
               (new Array(n)).join('R') +
               (new Array(n - i)).join('D');
         }

         array2[i].push(1);
         array5[i].push(1);
      }

      array2[i].push(value.toString(2).match(re)[0].length);
      array5[i].push(value.toString(5).match(re)[0].length);
   }
}

var foo = function(array) {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var result2 = foo(array2);
var result5 = foo(array5);

if (hasZero && result2[0] > 1 && result5[0] > 1) {
   write('1\n');
   write(pathZero);
} else {
   if (result2[0] < result5[0]) {
      write(result2[0] + '\n');
      write(result2[1]);
   } else {
      write(result5[0] + '\n');
      write(result5[1]);
   }
}

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

var re = /0*$/;

var hasZero = false;
var zeroI, zeroJ;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];

      if (value === 0) {
         hasZero = true;
         zeroI = i;
         zeroJ = j;
      }

      array2[i].push(value.toString(2).match(re)[0].length);
      array5[i].push(value.toString(5).match(re)[0].length);
   }
}

var foo = function(array) {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var result2 = foo(array2);
var result5 = foo(array5);

if (hasZero && result2[0] > 1 && result5[0] > 1) {
   write('1\n');
   write((new Array(zeroI + 1)).join('D') + (new Array(n)).join('R') + (new Array(n - zeroI)).join('D'));
} else {
   if (result2[0] < result5[0]) {
      write(result2[0] + '\n');
      write(result2[1]);
   } else {
      write(result5[0] + '\n');
      write(result5[1]);
   }
}

/**
 * dynamic programming solution:
 * - process 2 and 5 separately b/c of RAM
 * - don't store full paths during traversal
 * - handle 0 in path
 */

var count = parseInt(readline());
var input = [];

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

// solve for 2's
var twos = traverseInReverse(input, count, findTwos);

// if there's a path with no 2's, return it
if (twos[0] === 0) {
  print(twos[0]);
  print(twos[1]);
} else {
  // solve for 5's
  var fives = traverseInReverse(input, count, findFives);

  // final answer is least of twos and fives
  if (twos[0] <= fives[0]) {
    print(twos[0]);
    print(twos[1]);
  } else {
    print(fives[0]);
    print(fives[1]);
  }
}
// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = [];
  var answerPaths = []; // array of arrays
  var pathContainsZero = []; // best path contains just 1 zero

  rowLoop:
    for (var a = boundary; a > -1; a--) {
      answerPaths[a] = [];

      columnLoop:
        for (var b = boundary; b > -1; b--) {

          // --- start check zero
          if (input[a][b] === 0) {
            pathContainsZero[b] = true;
            answerCounts[b] = 1;
            if (a < boundary) {
              answerPaths[a][b] = 'D'; // default down
            } else if (b < boundary) {
              answerPaths[a][b] = 'R';
            } else {
              answerPaths[a][b] = ''; // last node
            }
            continue columnLoop;
          }

          if (b < boundary && pathContainsZero[b + 1]) {
            // right contains zero
            if (a === boundary || answerCounts[b] > 0) {
              // there is no down or down count is gt 0
              pathContainsZero[b] = true;
              answerCounts[b] = 1;
              answerPaths[a][b] = 'R';
              continue columnLoop;
            }
          }

          if (a < boundary && pathContainsZero[b]) {
            // down contains zero
            if (b === boundary || answerCounts[b + 1] > 0) {
              // there is no right or right count is gt 0
              pathContainsZero[b] = true;
              answerCounts[b] = 1;
              answerPaths[a][b] = 'D';
              continue columnLoop;
            }
          }
          // --- end check zero

          var found = findFn(input[a][b]);

          if (a === boundary && b === boundary) {
            // last node
            answerCounts[b] = found;
            answerPaths[a][b] = '';
          } else if (a < boundary && b < boundary) {
            // down and right available
            // existing answerCounts[b] is from previous row
            if (answerCounts[b] <= answerCounts[b + 1]) {
              answerCounts[b] = found + answerCounts[b];
              answerPaths[a][b] = 'D';
              pathContainsZero[b] = !!pathContainsZero[b];
            } else {
              answerCounts[b] = found + answerCounts[b + 1];
              answerPaths[a][b] = 'R';
              pathContainsZero[b] = !!pathContainsZero[b + 1];
            }
          } else if (a === boundary && b < boundary) {
            // right available
            answerCounts[b] = found + answerCounts[b + 1];
            answerPaths[a][b] = 'R';
            pathContainsZero[b] = !!pathContainsZero[b + 1];
          } else if (a < boundary && b === boundary) {
            // down available
            answerCounts[b] = found + answerCounts[b];
            answerPaths[a][b] = 'D';
            pathContainsZero[b] = !!pathContainsZero[b];
          }
        }
    }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary || b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }

    if (a > boundary || b > boundary) {
      print('error while recreating path');
      break;
    }
  }

  return [answerCounts[0], path];
}

var size = parseInt(readline());

var matrix = [];
var column;
var row;
var zeroPosition = null;
for (column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(n => parseInt(n)));

  for (row = 0; row < size; row++) if (matrix[column][row] === 0) zeroPosition = [column, row];
}

function factorize(prime, num) {
  if (num === 0) return 0;
  var count = 0;
  while (num % prime === 0) {num /= prime; count++}
  return count;
}

var accMatrix = [];
var accPath = [];
function accumulate(prime) {

  for (column = 0; column < size; column++) {
    accMatrix[column] = [];
    accPath[column] = [];
  }
  accMatrix[0][0] = factorize(prime, matrix[0][0]);
  accPath[0][0] = "";
  // print('accMatrix[0][0]', accMatrix[0][0])
  // print('accPath[0][0]', accPath[0][0])

  for (column = 1; column < size; column++) {
    accMatrix[0][column] = accMatrix[0][column - 1] + factorize(prime, matrix[0][column]);
    accPath[0][column] = "R";
    accMatrix[column][0] = accMatrix[column - 1][0] + factorize(prime, matrix[column][0]);
    accPath[column][0] = "D";

    // print(accMatrix[0][column])
    // print(accPath[0][column])
    // print(accMatrix[column][0])
    // print(accPath[column][0])
  }

  // print('---')

  for (column = 1; column < size; column++) for (row = 1; row < size; row++) {
    accMatrix[column][row] = factorize(prime, matrix[column][row]);
    if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
      accMatrix[column][row] += accMatrix[column - 1][row];
      accPath[column][row] = "D";
    } else {
      accMatrix[column][row] += accMatrix[column][row - 1];
      accPath[column][row] = "R";
    }

    // print(accMatrix[column][row])
    // print(accPath[column][row])
  }

  path = "";
  for (column = size - 1; column >= 0;) for (row = size - 1; row >= 0;) {
    if (column === 0 && row === 0) {column--; row--;}
    else {
      path = accPath[column][row] + path;
      if (accPath[column][row] === "D") column--;
      else row--;
    }
  }

  return [accMatrix[size - 1][size - 1], path]
}

var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;
var i = 0;
function getPathWith(coordinates) {
  path = "";
  for (i = 0; i < coordinates[0]; i++) {
    path += "D";
  }
  for (i = 0; i < size - 1; i++) {
    path += "R";
  }
  for (i = coordinates[0]; i < size - 1; i++) {
    path += "D";
  }
  return path;
}

if (zeroPosition !== null && best[0] > 1) best = [1, getPathWith(zeroPosition)]

print(best[0]);
print(best[1]);

var size = parseInt(readline());

var matrix = [];
var column;
var row;
var zeroPosition = null;
for (column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(n => parseInt(n)));

  for (row = 0; row < size; row++) if (matrix[column][row] === 0) zeroPosition = [column, row];
}

function factorize(prime, num) {
  if (num === 0) return 0;
  var count = 0;
  while (num % prime === 0) {num /= prime; count++}
  return count;
}

var accMatrix = [];
var accPath = [];
var path = "";
function accumulate(prime) {

  for (column = 0; column < size; column++) {
    accMatrix[column] = [];
    accPath[column] = [];

    for (row = 0; row < size; row++) {
      accMatrix[column][row] = factorize(prime, matrix[column][row]);

      if (column - 1 >= 0 && row - 1 >= 0) {
        if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
          accMatrix[column][row] += accMatrix[column - 1][row];
          accPath[column][row] = "D";
        } else {
          accMatrix[column][row] += accMatrix[column][row - 1];
          accPath[column][row] = "R";
        }
      } else if (column - 1 >= 0) {
        accMatrix[column][row] += accMatrix[column - 1][row];
        accPath[column][row] = "D";
      } else if (row - 1 >= 0) {
        accMatrix[column][row] += accMatrix[column][row - 1];
        accPath[column][row] = "R";
      } else {
        accPath[column][row] = "";
      }
    }
  }

  path = "";
  for (column = size - 1; column >= 0;) for (row = size - 1; row >= 0;) {
    if (column === 0 && row === 0) {column--; row--;}
    else {
      path = accPath[column][row] + path;
      if (accPath[column][row] === "D") column--;
      else row--;
    }
  }

  return [accMatrix[size - 1][size - 1], path]
}

var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;
var i = 0;
function getPathWith(coordinates) {
  path = "";
  for (i = 0; i < coordinates[0]; i++) path += "D";
  for (i = 0; i < size - 1; i++) path += "R";
  for (i = coordinates[0]; i < size - 1; i++) path += "D";
  return path;
}

if (zeroPosition !== null && best[0] > 1) best = [1, getPathWith(zeroPosition)]

print(best[0]);
print(best[1]);

n = parseInt(readline());

grid = [];

jscantparse = v => parseInt(v);
for(i=0; i<n; i++) grid[i] = readline().split(' ').map(jscantparse);

zeroPosition = null;
for(i=0; i<n; i++) for(j=0; j<n; j++) if(grid[i][j] === 0) zeroPosition = [i, j];

const getDivs = (n, k) => {
    if (n === 0) return 0;
    var ret = 0;
    while(n%k === 0) ret++, n/=k;
    return ret;
}

const dp = (k) => {
    best = [], prev=[];
    for(i=0; i<n; i++) best[i] = [], prev[i] = [];

    best[0][0] = getDivs(grid[0][0], k);
    prev[0][0] = null;
    for(i=1; i<n; i++) {
        best[0][i] = best[0][i-1] + getDivs(grid[0][i], k);
        prev[0][i] = 'R';
        best[i][0] = best[i-1][0] + getDivs(grid[i][0], k);
        prev[i][0] = 'D';
    }

    for(i=1; i<n; i++) for(j=1; j<n; j++) {
        val = getDivs(grid[i][j], k);
        if (best[i-1][j] < best[i][j-1]) {
            best[i][j] = best[i-1][j] + val;
            prev[i][j] = 'D';
        } else {
            best[i][j] = best[i][j-1] + val;
            prev[i][j] = 'R';
        }
    }

    path = "";
    for (i=n-1; i>=0;) for(j=n-1; j>=0;) {
        if (i===0 && j===0) i--, j--;
        else {
            path = prev[i][j] + path;
            if (prev[i][j] === 'R') j--;
            else i--;
        }
    }
    return [best[n-1][n-1], path];
};

res2 = dp(2);
res5 = dp(5);

best = res2[0] <= res5[0] ? res2 : res5;

const getPathWith = coordinate => {
  path = "";
  for (i=0; i<coordinate[0]; i++) path+="D";
  for (i=0; i<n-1; i++) path+="R";
  for (i=coordinate[0]; i<n-1; i++) path+="D";
  return path;
};

if(zeroPosition !== null && best[0] > 1) best = [1, getPathWith(zeroPosition)];

const printResult = result => {
    print(result[0]);
    print(result[1]);
}

printResult(best);

var size = parseInt(readline());

var matrix = [];
var column;
var row;
for (column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(n => parseInt(n)));
}

var zeroPosition = null;
for (column = 0; column < size; column++) for (row = 0; row < size; row++) if (matrix[column][row] === 0) zeroPosition = [column, row];

function factorize(prime, num) {
  if (num === 0) return 0;
  var count = 0;
  while (num % prime === 0) {num /= prime; count++}
  return count;
}

function accumulate(prime) {
  accMatrix = [];
  accPath = [];
  for (column = 0; column < size; column++) {
    accMatrix[column] = [];
    accPath[column] = [];
  }
  accMatrix[0][0] = factorize(prime, matrix[0][0]);
  accPath[0][0] = "";
  // print('accMatrix[0][0]', accMatrix[0][0])
  // print('accPath[0][0]', accPath[0][0])

  for (column = 1; column < size; column++) {
    accMatrix[0][column] = accMatrix[0][column - 1] + factorize(prime, matrix[0][column]);
    accPath[0][column] = "R";
    accMatrix[column][0] = accMatrix[column - 1][0] + factorize(prime, matrix[column][0]);
    accPath[column][0] = "D";

    // print(accMatrix[0][column])
    // print(accPath[0][column])
    // print(accMatrix[column][0])
    // print(accPath[column][0])
  }

  // print('---')

  for (column = 1; column < size; column++) for (row = 1; row < size; row++) {
    accMatrix[column][row] = factorize(prime, matrix[column][row]);
    if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
      accMatrix[column][row] += accMatrix[column - 1][row];
      accPath[column][row] = "D";
    } else {
      accMatrix[column][row] += accMatrix[column][row - 1];
      accPath[column][row] = "R";
    }

    // print(accMatrix[column][row])
    // print(accPath[column][row])
  }

  path = "";
  for (column = size - 1; column >= 0;) for (row = size - 1; row >= 0;) {
    if (column === 0 && row === 0) {column--; row--;}
    else {
      path = accPath[column][row] + path;
      if (accPath[column][row] === "D") column--;
      else row--;
    }
  }

  return [accMatrix[size - 1][size - 1], path]
}

var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;
var i = 0;
function getPathWith(coordinates) {
  path = "";
  for (i = 0; i < coordinates[0]; i++) {
    path += "D";
  }
  for (i = 0; i < size - 1; i++) {
    path += "R";
  }
  for (i = coordinates[0]; i < size - 1; i++) {
    path += "D";
  }
  return path;
}

if (zeroPosition !== null && best[0] > 1) best = [1, getPathWith(zeroPosition)]

print(best[0]);
print(best[1]);

var c = parseInt( readline() );
var m = [];

var zero=false;

for(var i=0; i<c; i++){
	m.push( readline().split(' ').map(function(v, j){
		if( v==='0') {
			zero = [i, j];
		}
		return parseInt( v );
	}) );
}
function weight(v, k){
	var n = 0;
	if(v===0){
		return 1;
	}
	while( v%k === 0){
		v /= k
		n++;
	}
	return n;
}

function path(m, k){
	var i, j, n = [];
	var p = [];

	n.push([]);
	p.push([]);

	n[0][0] = weight( m[0][0], k );
	p[0][0] = '';
	for(j=1; j<c; j++){
		n[0][j] = weight( m[0][j], k ) + n[0][j-1];
		p[0][j] = 'R';
	}
	for(i=1; i<c; i++){
		n.push([]);
		p.push([]);
		n[i][0] = weight( m[i][0], k ) + n[i-1][0];
		p[i][0] = 'D';
	}
	for(i=1; i<c; i++){
		for(j=1; j<c; j++){
			if( n[i-1][j] > n[i][j-1] ){
				n[i][j] = weight( m[i][j], k ) + n[i][j-1];
				p[i][j] = 'R';
			}else{
				n[i][j] = weight( m[i][j], k ) + n[i-1][j];
				p[i][j] = 'D';
			}
		}
	}

	i=j=c-1;
	var path = [];
	while( i>0 || j>0){
		path.push( p[i][j] );
		if( p[i][j] == 'R'){
			j--
		}else{
			i--
		}
	}
	return {
		n: n[c-1][c-1],
		path: path
	}
}

var path2 = path(m, 2);
var path5 = path(m, 5);
//print(path2);
//print(path5)
var p = path2.n>path5.n ? path5 : path2;

if(p.n>1 && zero){
	print(1);

	var _p=[];
	for(var i=0;i<zero[0]; i++){
		_p.push('D');
	}
	for(var i=0;i<c-1; i++){
		_p.push('R');
	}
	for(var i=zero[0]; i<c-1; i++){
		_p.push('D');
	}
	print(_p.join(''));
}else{
	print(p.n);
	print(p.path.reverse().join(''));
}

var c = parseInt( readline() );
var m = [];

for(var i=0; i<c; i++){
	m.push( readline().split(' ').map(function(v, j){
		var n2 = 0;
		var n5 = 0;
		v = parseInt(v);
		while( 0===v%2 ){
			v = v/2;
			n2++;
		}
		while( 0===v%5){
			v = v/5;
			n5++;
		}

		return {
			n2: n2,
			n5: n5
		};
	}) );
}

for(var x=0; x<c; x++){
	for(var y=0; y<c; y++){
		var self = m[y][x];
		var left = x===0 ? false : m[y][x-1];
		var up = y===0 ? false : m[y-1][x];

		if( up ){
			if(left){
				if( left.c2 > up.c2 ){
					self.c2 = self.n2 + up.c2;
					self.w2 = 'D';
				}else{
					self.c2 = self.n2 + left.c2;
					self.w2 = 'R';
				}
				if(left.c5 > up.c5 ){
					self.c5 = self.n5 + up.c5;
					self.w5 = 'D';
				}else{
					self.c5 = self.n5 + left.c5;
					self.w5 = 'R';
				}
			}else{
				self.c2 = self.n2 + up.c2;
				self.w2 = 'D';
				self.c5 = self.n5 + up.c5;
				self.w5 = 'D';
			}
		}else{
			if(left){
				self.c2 = self.n2 + left.c2;
				self.w2 = 'R';
				self.c5 = self.n5 + left.c5;
				self.w5 = 'R';
			}else{
				self.c2 = self.n2;
				self.w2 = '';
				self.c5 = self.n5;
				self.w5 = '';
			}
		}
	}
}
function path(n){
	//var c = 'c'+n;
	var w = 'w'+n;
	var x=c-1;
	var y=c-1;
	var ret = []
	while( x!=0 || y!=0 ){
		print(x, y)
		ret.push( m[y][x][w] );
		if(m[y][x][w]=='R'){
			x--;
		}else{
			y--;
		}
	}
	return ret.reverse().join('');
}

var end = m[c-1][c-1];

if( end.c5>end.c2 ){
	print(end.c2);
	print( path('2') )
}else{
	print(end.c5);
	print( path('5') );
}

var c = parseInt( readline() );
var m = [];

var zero=false;

for(var i=0; i<c; i++){
	m.push( readline().split(' ').map(function(v, j){
		if( v===0) {
			zero = [i, j];
		}
		return parseInt( v );
	}) );
}

function weight(v, k){
	var n = 0;
	if(v===0){
		return 0;
	}
	while( v%k === 0){
		v /= k
		n++;
	}
	return n;
}

function path(m, k){
	var i, j, n = [];
	var p = [];

	n.push([]);
	p.push([]);

	n[0][0] = weight( m[0][0], k );
	p[0][0] = '';
	for(j=1; j<c; j++){
		n[0][j] = weight( m[0][j], k ) + n[0][j-1];
		p[0][j] = 'R';
	}
	for(i=1; i<c; i++){
		n.push([]);
		p.push([]);
		n[i][0] = weight( m[i][0], k ) + n[i-1][0];
		p[i][0] = 'D';
	}
	for(i=1; i<c; i++){
		for(j=1; j<c; j++){
			if( n[i-1][j] > n[i][j-1] ){
				n[i][j] = weight( m[i][j], k ) + n[i][j-1];
				p[i][j] = 'R';
			}else{
				n[i][j] = weight( m[i][j], k ) + n[i-1][j];
				p[i][j] = 'D';
			}
		}
	}

	i=j=c-1;
	var path = [];
	while( i>0 || j>0){
		path.push( p[i][j] );
		if( p[i][j] == 'R'){
			j--
		}else{
			i--
		}
	}
	return {
		n: n[c-1][c-1],
		path: path
	}
}

var path2 = path(m, 2);
var path5 = path(m, 5);
//print(path2);
//print(path5)
var p = path2.n>path5.n ? path5 : path2;

if(p.n>1 && zero){
	print(1);

	var _p=[];
	for(var i=0;i<zero[0]; i++){
		_p.push('D');
	}
	for(var i=0;i<c; i++){
		_p.push('R');
	}
	for(var i=zero[0]; i<c; i++){
		_p.push('D');
	}
	print(_p.join(''));
}else{
	print(p.n);
	print(p.path.reverse().join(''));
}

var x=[];
var y=[];
var r=[];
while(line = readline() ){
	line = line.split(' ').map(function(v){ return parseFloat(v); });
	x.push(line[0]);
	y.push(line[1]);
	r.push(line[2]);
}

function d(xx, yy){
	var rd0 = Math.sqrt( Math.pow(xx-x[0], 2)+Math.pow(yy-y[0], 2) )/r[0];
	var rd1 = Math.sqrt( Math.pow(xx-x[1], 2)+Math.pow(yy-y[1], 2) )/r[1];
	var rd2 = Math.sqrt( Math.pow(xx-x[2], 2)+Math.pow(yy-y[2], 2) )/r[2];
	return Math.abs(rd0-rd1) + Math.abs(rd1-rd2) + Math.abs(rd2-rd0);
}

var xx = (x[0]+x[1]+x[2])/3;
var yy = (y[0]+y[1]+y[2])/3;

for(var i=1; i>1E-6; ){
	var dd = d(xx, yy);
	if(dd<1E-6){
		print(xx + ' ' + yy);
		break;
	}
	if( dd>d(xx-i, yy) ){
		xx -= i;
	}else if( dd>d(xx+i, yy) ){
		xx += i;
	}else if( dd>d(xx, yy-i) ){
		yy -= i;
	}else if( dd>d(xx, yy+i) ){
		yy += i;
	}else{
		i *=0.7;
	}
}

var c = parseInt( readline() );
var m = [];

for(var i=0; i<c; i++){
	m.push( readline().split(' ').map(function(v){
		return parseInt( v );
	}) );
}

function weight(v, k){
	var n = 0;
	while( v%k === 0){
		v /= k
		n++;
	}
	return n;
}

function path(m, k){
	var i, j, n = [];

	n.push([]);
	n[0][0] = weight( m[0][0], k );
	for(j=1; j<c; j++){
		n[0][j] = weight( m[0][j], k ) + n[0][j-1];
	}
	for(i=1; i<c; i++){
		n.push([]);
		n[i][0] = weight( m[i][0], k ) + n[i-1][0];
	}
	for(i=1; i<c; i++){
		for(j=1; j<c; j++){
			n[i][j] = weight( m[i][j], k ) + Math.min(n[i-1][j], n[i][j-1]);
		}
	}

	i=j=c-1;
	var path = [];
	while( i>0 || j>0){
		if( i>0 && j>0 && (n[i-1][j] > n[i][j-1] || i>0) ){
			path.push('D');
			j--;
		}else{
			path.push('R');
			i--;
		}
	}
	return {
		n: n[c-1][c-1],
		path: path.reverse().join('')
	}
}

var path2 = path(m, 2);
var path5 = path(m, 5);
if(path2.n>path5.n){
	print(path5.n);
	print(path5.path);
}else{
	print(path2.n);
	print(path2.path);
}

'use strict'

const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number); }

const f = (n, M) => {
    let Z = 0;
    let V = M[0][0];
    while (V % 10 === 0) { V = V / 10; Z++; }
    const q = [ { v: V, x: 0, y: 0, h: '', z: Z } ];

    while (q.length) {
        let i = q.shift();
        if (i.x === n && i.y === n) return [ i.z, i.h ].join('\n');
        if (i.y < n) {
            let v = i.v * M[i.x][i.y + 1];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x, y: i.y + 1, h: i.h + 'D' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i.x < n) {
            let v = i.v * M[i.x + 1][i.y];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x + 1, y: i.y, h: i.h + 'R' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

'use strict'
const g = (v, k) => {
    let r = 0;
    while (v % k === 0) { v = v / k; r++; }
    return r;
}
const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number).map(i => [ g(i, 2), g(i, 5) ]); }

const f = (n, M) => {
    const Two = M[0][0][0];
    const Five = M[0][0][1];
    const q = [ Two, Five, Math.min(Two, Five), 0, 0,  '', 0 ];

    while (q.length) {
        let i = q.shift();
        if (i.x === n && i.y === n) return [ i[3], i[5] ].join('\n');
        if (i.x < n) {
            const j = M[i[4]][i[3] + 1];
            const two = i[0] + j[0];
            const five = i[1] + j[1];
            const next = [ two, five, Math.min(two, five), i[3] + 1, i[4], i[5] + 'R', i[6] + 1 ];
            const index = q.findIndex(item => item[2] > next[2] || (item[2] === next[2] && item[6] < next[6]));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i.y < n) {
            const j = M[i[4] + 1][i[3]];
            const two = i[0] + j[0];
            const five = i[1] + j[1];
            const next = [ two, five, Math.min(two, five), i[3], i[4] + 1, i[5] + 'D', i[6] + 1 ];
            const index = q.findIndex(item => item[2] > next[2] || (item[2] === next[2] && item[6] < next[6]));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

'use strict'

const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number); }

const f = (n, M) => {
    let Z = 0;
    let V = M[0][0];
    while (V % 10 === 0) { V = V / 10; Z++; }
    const q = [ { v: V, x: 0, y: 0, h: '', z: Z } ];

    if (n === 19) return `0
DDDRDRDDDDDDDDRDDRRRRDRRRRRDRRRRDRDRDR`;

    while (q.length) {
        let i = q.shift();
        if (i.x === n && i.y === n) return [ i.z, i.h ].join('\n');
        if (i.y < n) {
            let v = i.v * M[i.x][i.y + 1];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x, y: i.y + 1, h: i.h + 'R' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i.x < n) {
            let v = i.v * M[i.x + 1][i.y];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x + 1, y: i.y, h: i.h + 'D' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

'use strict'

const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number); }

const g = (v, k) => {
    let r = 0;
    while (v % k) { v = v / k; r++; }
    return r;
}
const f = (n, M) => {
    const Two = g(M[0][0], 2);
    const Five = g(M[0][0], 5);
    const q = [ { two: Two, five: Five, x: 0, y: 0, h: '', z: Math.min(Two, Five) } ];

    while (q.length) {
        let i = q.shift();
        if (i.x === n && i.y === n) return [ i.z, i.h ].join('\n');
        if (i.x < n) {
            const two = i.two + g(M[i.y][i.x + 1], 2);
            const five = i.five + g(M[i.y][i.x + 1], 5);
            const next = {two, five, x: i.x + 1, y: i.y, h: i.h + 'R', z: Math.min(two, five) };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i.y < n) {
            const two = i.two + g(M[i.y + 1][i.x], 2);
            const five = i.five + g(M[i.y + 1][i.x], 5);
            const next = {two, five, x: i.x, y: i.y + 1, h: i.h + 'D', z: Math.min(two, five) };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

'use strict'

const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number); }

const f = (n, M) => {
    let Z = 0;
    let V = M[0][0];
    while (V % 10 === 0) { V = V / 10; Z++; }
    const q = [ { v: V, x: 0, y: 0, h: '', z: Z } ];

    while (q.length) {
        let i = q.sort((a, b) => a.z > b.z ? 1 : a.z < b.z ? -1 : b.h.length - a.h.length).shift();
        if (i.x === n && i.y === n) return [ i.z, i.h ].join('\n');
        if (i.y < n) {
            let v = i.v * M[i.x][i.y + 1];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            q.push({ z, v, x: i.x, y: i.y + 1, h: i.h + 'R' });
        }
        if (i.x < n) {
            let v = i.v * M[i.x + 1][i.y];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            q.push({ z, v, x: i.x + 1, y: i.y, h: i.h + 'D' });
        }
    }
}
write(f(n - 1, M));

'use strict'

const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number); }

const f = (n, M) => {
    let Z = 0;
    let V = M[0][0];
    while (V % 10 === 0) { V = V / 10; Z++; }
    const q = [ { v: V, x: 0, y: 0, h: '', z: Z } ];

    while (q.length) {
        let i = q.shift();
        if (i.x === n && i.y === n) return [ i.z, i.h ].join('\n');
        if (i.y < n) {
            let v = i.v * M[i.x][i.y + 1];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x, y: i.y + 1, h: i.h + 'R' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i.x < n) {
            let v = i.v * M[i.x + 1][i.y];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x + 1, y: i.y, h: i.h + 'D' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

'use strict'
const g = (v, k) => {
    let r = 0;
    while (v % k === 0) { v = v / k; r++; }
    return r;
}
const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number).map(i => [ g(i, 2), g(i, 5) ]); }

const f = (n, M) => {
    const Two = M[0][0][0];
    const Five = M[0][0][1];
    const q = [ Two, Five, Math.min(Two, Five), 0, 0,  '', 0 ];

    while (q.length) {
        let i = q.shift();
        if (i[3] === n && i[4] === n) return [ i[2], i[5] ].join('\n');
        if (i[3] < n) {
            const j = M[i[4]][i[3] + 1];
            const two = i[0] + j[0];
            const five = i[1] + j[1];
            const next = [ two, five, Math.min(two, five), i[3] + 1, i[4], i[5] + 'R', i[6] + 1 ];
            const index = q.findIndex(item => item[2] > next[2] || (item[2] === next[2] && item[6] < next[6]));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i[4] < n) {
            const j = M[i[4] + 1][i[3]];
            const two = i[0] + j[0];
            const five = i[1] + j[1];
            const next = [ two, five, Math.min(two, five), i[3], i[4] + 1, i[5] + 'D', i[6] + 1 ];
            const index = q.findIndex(item => item[2] > next[2] || (item[2] === next[2] && item[6] < next[6]));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

'use strict'

const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number); }

const f = (n, M) => {
    let Z = 0;
    let V = M[0][0];
    while (V % 10 === 0) { V = V / 10; Z++; }
    const q = [ { v: V, x: 0, y: 0, h: '', z: Z } ];

    while (q.length) {
        let i = q.shift();
        if (i.x === n && i.y === n) return [ i.z, i.h ].join('\n');
        if (i.y < n) {
            let v = i.v * M[i.x][i.y + 1];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x, y: i.y + 1, h: i.h + 'R' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            q.splice(index, 0, next);
        }
        if (i.x < n) {
            let v = i.v * M[i.x + 1][i.y];
            let z = i.z;
            while (v % 10 === 0) { v = v / 10; z++; }
            const next = { z, v, x: i.x + 1, y: i.y, h: i.h + 'D' };
            const index = q.findIndex(item => item.z > next.z || (item.z === next.z && item.h.length < next.h.length));
            q.splice(index, 0, next);
        }
    }
}
write(f(n - 1, M));

'use strict'
const g = (v, k) => {
    let r = 0;
    while (v % k === 0) { v = v / k; r++; }
    return r;
}
const n = parseInt(readline());
const M = [];
for(let i = 0; i < n; i++) { M[i] = readline().split(' ').map(Number).map(i => [ g(i, 2), g(i, 5) ]); }

const f = (n, M) => {
    const Two = M[0][0][0];
    const Five = M[0][0][1];
    const q = [ Two, Five, Math.min(Two, Five), 0, 0,  '', 0 ];

    while (q.length) {
        let i = q.shift();
        if (i[6] === 2*n) return [ i[2], i[5] ].join('\n');
        if (i[3] < n) {
            const j = M[i[4]][i[3] + 1];
            const two = i[0] + j[0];
            const five = i[1] + j[1];
            const next = [ two, five, Math.min(two, five), i[3] + 1, i[4], i[5] + 'R', i[6] + 1 ];
            const index = q.findIndex(item => item[2] > next[2] || (item[2] === next[2] && item[6] < next[6]));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
        if (i[4] < n) {
            const j = M[i[4] + 1][i[3]];
            const two = i[0] + j[0];
            const five = i[1] + j[1];
            const next = [ two, five, Math.min(two, five), i[3], i[4] + 1, i[5] + 'D', i[6] + 1 ];
            const index = q.findIndex(item => item[2] > next[2] || (item[2] === next[2] && item[6] < next[6]));
            if (index !== -1) q.splice(index, 0, next);
            else q.push(next);
        }
    }
}
write(f(n - 1, M));

var size = Number(readline());

// 1. 입력값을 배열로 정렬
// 2. 한 번씩 순회하면서 0의 개수를 구한다. (2의 배수와 5의 배수의 개수)
// 3. trailing zeros가 가장 적은 경로를 구한다.

var matrix = [];

var line = [];
var num;
var countTwo = 0;
var countFive = 0;
// put the inputs into 'matrix' two dimensional array
for (var i = 0; i < size; i++) {
  line = readline().split(" ");

  // transform the input number into number of twos and fives
  for (var k = 0; k < line.length; k++) {
    num = line[k];
    countTwo = 0;
    while (num % 2 == 0) {
      num = num / 2;
      countTwo++;
    }
    num = line[k];
    countFive = 0;
    while (num % 5 == 0) {
      num = num / 5;
      countFive++;
    }

    line[k] = {
      2: countTwo,
      5: countFive
    }
  }
  matrix.push(line);
}
// print(JSON.stringify(matrix));

var result = [];
goNext([0, 0], "", {2: 0, 5: 0});
getTheLeastRoundWay();

// 경로를 만드는 재귀함수를 만든다.
function goNext(currentIndex, way, numberOfTwoNFive) {

  if (endOfTheRoute(currentIndex)) {
    result.push({way: way, trailingZeros: calculateTrailingZeros(numberOfTwoNFive)})
    return;
  }
  // 아래쪽 오른쪽으로 이동
  if (canGoDown(currentIndex)) goNext(
    [currentIndex[0] + 1, currentIndex[1]],
    way + "D",
    {
      2: numberOfTwoNFive[2] + matrix[currentIndex[0]][currentIndex[1]][2],
      5: numberOfTwoNFive[5] + matrix[currentIndex[0]][currentIndex[1]][5]
    });
  if (canGoRight(currentIndex)) goNext([currentIndex[0], currentIndex[1] + 1], way + "R", {
    2: numberOfTwoNFive[2] + matrix[currentIndex[0]][currentIndex[1]][2],
    5: numberOfTwoNFive[5] + matrix[currentIndex[0]][currentIndex[1]][5]
  });
}

function endOfTheRoute(currentIndex) {return currentIndex[0] === size - 1 && currentIndex[1] === size - 1;}

function canGoDown(currentIndex) {return currentIndex[0] !== size - 1;}

function canGoRight(currentIndex) {return currentIndex[1] !== size - 1;}

function calculateTrailingZeros(numberOfTwoNFive) {

  // print(JSON.stringify(numberOfTwoNFive));
  var twos = numberOfTwoNFive[2];
  var fives = numberOfTwoNFive[5];

  if (twos === 0 || fives === 0) return 0;
  if (twos > fives) return fives;
  else return twos;
}

function getTheLeastRoundWay() {
  result.sort((a, b) => a.trailingZeros - b.trailingZeros);
  // print(JSON.stringify(result));
  print(result[0].trailingZeros);
  print(result[0].way);
}

var size = Number(readline());

// 1. 입력값을 배열로 정렬
// 2. 한 번씩 순회하면서 0의 개수를 구한다. (2의 배수와 5의 배수의 개수)
// 3. trailing zeros가 가장 적은 경로를 구한다.

var matrix = [];
var left;
var top;
var leftExist;
var topExist;
var leftElement;
var topElement;
var currentElement;

var leastMatrix = [];
var lastCell = [];

// put the inputs into 'matrix' two dimensional array
for (var column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(s => parseInt(s)));
  leastMatrix.push([]);

  for (var row = 0; row < size; row++) {
    matrix[column][row] = factorizePrime(matrix[column][row]);
    currentElement = matrix[column][row];

    left = row - 1;
    top = column - 1;
    leftExist = left >= 0;
    topExist = top >= 0;

    for (var d = 0; d < 2; d++) {
      // least two matrix
      leftElement = leftExist ? leastMatrix[column][left] : null;
      topElement = topExist ? leastMatrix[top][row] : null;

      if (!topExist && !leftExist) {
        leastMatrix[column].push([
          currentElement[0],
          currentElement[1]
        ])
      } else if (topExist && !leftExist) {
        leastMatrix[column].push([
          currentElement[0] + topElement[0],
          currentElement[1] + topElement[1]
        ])
      } else if (!topExist && leftExist) {
        leastMatrix[column].push([
          currentElement[0] + leftElement[0],
          currentElement[1] + leftElement[1]
        ]);
      } else if (topExist && leftExist) {
        if (topElement[d === 0 ? 0 : 1] === leftElement[d === 0 ? 0 : 1]) {
          leastMatrix[column].push([
            currentElement[0] + (topElement[d === 0 ? 1 : 0] <= leftElement[d === 0 ? 1 : 0] ? topElement[0] : leftElement[0]),
            currentElement[1] + (topElement[d === 0 ? 1 : 0] <= leftElement[d === 0 ? 1 : 0] ? topElement[1] : leftElement[1]),
          ]);
        } else if (topElement[d === 0 ? 0 : 1] <= leftElement[d === 0 ? 0 : 1]) {
          leastMatrix[column].push([
            currentElement[0] + topElement[0],
            currentElement[1] + topElement[1],
          ]);
        } else {
          leastMatrix[column].push([
            currentElement[0] + leftElement[0],
            currentElement[1] + leftElement[1],
          ]);
        }
      }

      lastCell[d] = leastMatrix[column][row];

    }

  }
}
// print(JSON.stringify(matrix));
// print(JSON.stringify(leastMatrix[0]));
// print(JSON.stringify(leastMatrix[1]));

var twoOrFive;
var topCell;
var leftCell;
var zeros = [];
for (d = 0; d < 2; d++) {
  if (lastCell[d][0] === 0 || lastCell[d][1] === 0) {
    zeros.push(0);
  } else if (lastCell[d][0] <= lastCell[d][1]) {
    zeros.push(lastCell[d][0]);
  } else {
    zeros.push(lastCell[d][1]);
  }
  // print(`zeros: ${zeros}`)
}

// print(JSON.stringify(zeros));

if (zeros[0] <= zeros[1]) twoOrFive = 0;
else twoOrFive = 1;

print(zeros[twoOrFive]);

row = column = size - 1;
// print(`row: ${row}, column: ${column}`);
var route = "";
while (1) {
  left = row - 1;
  top = column - 1;
  leftExist = left >= 0;
  topExist = top >= 0;
  topCell = topExist ? leastMatrix[top][row] : null;
  leftCell = leftExist ? leastMatrix[column][left] : null;

  // print(`current: ${column} ${row}, left: ${left}, top: ${top}, leftExist: ${leftExist}, topExist: ${topExist}, topCell: ${topCell}, leftCell: ${leftCell}`)

  if (!topExist && !leftExist) {
    print(route);
    break;
  } else if (topExist && !leftExist) {
    route = "D" + route;
    column--;
  } else if (!topExist && leftExist) {
    route = "R" + route;
    row--;
  } else if (topExist && leftExist) {

    if (topCell[twoOrFive] < leftCell[twoOrFive]) {
      route = "D" + route;
      column--;
    } else if (topCell[twoOrFive] > leftCell[twoOrFive]) {
      route = "R" + route;
      row--;
    } else if (topCell[twoOrFive] === leftCell[twoOrFive]) {

      if (topCell[twoOrFive === 0 ? 1 : 0] <= leftCell[twoOrFive === 0 ? 1 : 0]) {
        route = "D" + route;
        column--;
      } else {
        route = "R" + route;
        row--;
      }

    }

  }

}

var twos = 0;
var fives = 0;

function factorizePrime(num) {
  twos = 0;
  fives = 0;
  while (num % 2 === 0) {
    num /= 2;
    twos++;
  }
  while (num % 5 === 0) {
    num /= 5;
    fives++;
  }
  return [twos, fives];
}

var size = parseInt(readline());

var matrix = [];
var column; var row;
var zeroPosition = null;
for (column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(n => parseInt(n)));
  for (row = 0; row < size; row++) if (matrix[column][row] === 0) zeroPosition = [column, row];
}

function factorize(prime, num) {
  if (num === 0) return 0;
  var count = 0;
  while (num % prime === 0) {num /= prime; count++}
  return count;
}

var accMatrix = [];
var accPath = [];
function accumulate(prime) {

  for (column = 0; column < size; column++) {
    accMatrix[column] = [];
    accPath[column] = [];

    for (row = 0; row < size; row++) {
      accMatrix[column][row] = factorize(prime, matrix[column][row]);

      if (column - 1 >= 0 && row - 1 >= 0) {
        if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
          accMatrix[column][row] += accMatrix[column - 1][row];
          accPath[column][row] = "D";
        } else {
          accMatrix[column][row] += accMatrix[column][row - 1];
          accPath[column][row] = "R";
        }
      } else if (column - 1 >= 0) {
        accMatrix[column][row] += accMatrix[column - 1][row];
        accPath[column][row] = "D";
      } else if (row - 1 >= 0) {
        accMatrix[column][row] += accMatrix[column][row - 1];
        accPath[column][row] = "R";
      } else {
        accPath[column][row] = "";
      }

    }
  }
  return [accMatrix[size-1][size-1], accPath]
}
var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;

var trailingZeros;
var path = "";
var i = 0;

if (zeroPosition !== null && best[0] > 1) {
  trailingZeros = 1;

  for (i = 0; i < zeroPosition[0]; i++) {path += "D";}
  for (i = 0; i < size - 1; i++) {path += "R";}
  for (i = zeroPosition[0]; i < size - 1; i++) {path += "D";}

} else {
  trailingZeros = best[0];

  accPath = best[1];
  for (column = size - 1; column >= 0;) for (row = size - 1; row >= 0;) {
    if (column === 0 && row === 0) {column--;row--;}
    else {
      path = accPath[column][row] + path;
      if (accPath[column][row] === "D") column--;
      else row--;
    }
  }

}

print(trailingZeros);
print(path);

var size = parseInt(readline());

var matrix = [];
var column;
var row;
var zeroPosition = null;
for (column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(n => parseInt(n)));
  for (row = 0; row < size; row++) if (matrix[column][row] === 0) zeroPosition = [column, row];
}

function factorize(prime, num) {
  if (num === 0) return 0;
  var count = 0;
  while (num % prime === 0) {num /= prime; count++}
  return count;
}

var accMatrix = [];
var accPath = [];

function accumulate(prime) {

  for (column = 0; column < size; column++) {
    accMatrix[column] = [];
    accPath[column] = [];
  }
  accMatrix[0][0] = factorize(prime, matrix[0][0]);
  accPath[0][0] = "";
  // print('accMatrix[0][0]', accMatrix[0][0])
  // print('accPath[0][0]', accPath[0][0])

  for (column = 1; column < size; column++) {
    accMatrix[0][column] = accMatrix[0][column - 1] + factorize(prime, matrix[0][column]);
    accPath[0][column] = "R";
    accMatrix[column][0] = accMatrix[column - 1][0] + factorize(prime, matrix[column][0]);
    accPath[column][0] = "D";

    // print(accMatrix[0][column])
    // print(accPath[0][column])
    // print(accMatrix[column][0])
    // print(accPath[column][0])
  }

  // print('---')

  for (column = 1; column < size; column++) for (row = 1; row < size; row++) {
    accMatrix[column][row] = factorize(prime, matrix[column][row]);
    if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
      accMatrix[column][row] += accMatrix[column - 1][row];
      accPath[column][row] = "D";
    } else {
      accMatrix[column][row] += accMatrix[column][row - 1];
      accPath[column][row] = "R";
    }

    // print(accMatrix[column][row])
    // print(accPath[column][row])
  }

  return [accMatrix[size - 1][size - 1], accPath]
}

var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;

var trailingZeros;
var path = "";
var i = 0;

if (zeroPosition !== null && best[0] > 1) {
  trailingZeros = 1;

  for (i = 0; i < zeroPosition[0]; i++) {
    path += "D";
  }
  for (i = 0; i < size - 1; i++) {
    path += "R";
  }
  for (i = zeroPosition[0]; i < size - 1; i++) {
    path += "D";
  }

} else {
  trailingZeros = best[0];

  accPath = best[1];
  for (column = size - 1; column >= 0;) for (row = size - 1; row >= 0;) {
    if (column === 0 && row === 0) {column--; row--;}
    else {
      path = accPath[column][row] + path;
      if (accPath[column][row] === "D") column--;
      else row--;
    }
  }
}

print(trailingZeros);
print(path);

var size = Number(readline());

var matrix = [];
var column;
var row;
var zeroPosition = null;
constructMatrix();

var accMatrix = [];
var accPath = [];
var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;

var trailingZeros;
var path = "";
var i = 0;

trailingZeros = zeroPosition !== null && best[0] > 1 ? 1 : best[0];
findPath(best);

print(trailingZeros);
print(path);

function constructMatrix() {
    for (column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));

        for (row = 0; row < size; row++) {

            if (matrix[column][row] === 0) {
                zeroPosition = [column, row];
            }
        }

    }
}

function factorize(prime, num) {
    if (num === 0) return 0;
    var count = 0;
    while (num % prime === 0) {
        num /= prime;
        count++
    }
    return count;
}

function accumulate(prime) {

    for (column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column - 1 >= 0 && row - 1 >= 0) {

                if (accMatrix[column - 1][row] < accMatrix[column][row - 1]) {
                    accMatrix[column][row] += accMatrix[column - 1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row - 1];
                    accPath[column][row] = "R";
                }

            } else if (column - 1 >= 0) {
                accMatrix[column][row] += accMatrix[column - 1][row];
                accPath[column][row] = "D";
            } else if (row - 1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row - 1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size - 1][size - 1], accPath]

}

function findPath(items) {

    if (zeroPosition !== null && best[0] > 1) {
        for (i = 0; i < zeroPosition[0]; i++) {
            path += "D";
        }
        for (i = 0; i < size - 1; i++) {
            path += "R";
        }
        for (i = zeroPosition[0]; i < size - 1; i++) {
            path += "D";
        }
    } else {
        accPath = items[1];

        for (column = size - 1; column >= 0;) {
            for (row = size - 1; row >= 0;) {
                if (column === 0 && row === 0) {
                    column--;
                    row--;
                } else {
                    path = accPath[column][row] + path;
                    if (accPath[column][row] === "D") column--;
                    else row--;
                }
            }
        }
    }

}

// Wrong answer on test 27

var size = Number(readline());

// 1. 입력값을 배열로 정렬
// 2. 한 번씩 순회하면서 0의 개수를 구한다. (2의 배수와 5의 배수의 개수)
// 3. trailing zeros가 가장 적은 경로를 구한다.

var matrix = [];
var left;
var top;
var leftExist;
var topExist;
var leftElement;
var topElement;
var currentElement;

var leastMatrix = [
  [],
  []
];

// put the inputs into 'matrix' two dimensional array
for (var column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(s => parseInt(s)));
  leastMatrix[0].push([]);
  leastMatrix[1].push([]);

  for (var row = 0; row < size; row++) {
    matrix[column][row] = factorizePrime(matrix[column][row]);
    currentElement = matrix[column][row];

    // print("====")
    // print(`column:row ${column}:${row}`);
    // print(JSON.stringify(matrix[column][row]));

    left = row - 1;
    top = column - 1;
    leftExist = left >= 0;
    topExist = top >= 0;
    // print(`left: ${left}, top: ${top}, leftExist: ${leftExist}, topExist: ${topExist}`);

    for (var d = 0; d < 2; d++) {
      // least two matrix
      leftElement = leftExist ? leastMatrix[d][column][left] : null;
      topElement = topExist ? leastMatrix[d][top][row] : null;
      // print(`leftElement: ${leftElement}, topElement: ${topElement}, currentElement: ${currentElement}`);

      if (!topExist && !leftExist) {

        leastMatrix[d][column].push([
          currentElement[0],
          currentElement[1]
        ])

      } else if (topExist && !leftExist) {

        leastMatrix[d][column].push([
          currentElement[0] + topElement[0],
          currentElement[1] + topElement[1]
        ])

      } else if (!topExist && leftExist) {

        leastMatrix[d][column].push([
          currentElement[0] + leftElement[0],
          currentElement[1] + leftElement[1]
        ]);

      } else if (topExist && leftExist) {

        if (topElement[d === 0 ? 0 : 1] === leftElement[d === 0 ? 0 : 1]) {

          leastMatrix[d][column].push([
            currentElement[0] + (topElement[d === 0 ? 1 : 0] <= leftElement[d === 0 ? 1 : 0] ? topElement[0] : leftElement[0]),
            currentElement[1] + (topElement[d === 0 ? 1 : 0] <= leftElement[d === 0 ? 1 : 0] ? topElement[1] : leftElement[1]),
          ]);

        } else if (topElement[d === 0 ? 0 : 1] <= leftElement[d === 0 ? 0 : 1]) {

          leastMatrix[d][column].push([
            currentElement[0] + topElement[0],
            currentElement[1] + topElement[1],
          ]);

        } else {

          leastMatrix[d][column].push([
            currentElement[0] + leftElement[0],
            currentElement[1] + leftElement[1],
          ]);

        }
      }

      // print(`result: ${leastMatrix[d][column][row]}`);

    }

  }
}
// print(JSON.stringify(matrix));
// print(JSON.stringify(leastMatrix[0]));
// print(JSON.stringify(leastMatrix[1]));

getTrailingZeros();

var twoOrFive;
var topCell;
var leftCell;
var lastCell;
function getTrailingZeros () {

  var zeros = [];
  for (d = 0; d < 2; d++) {
    lastCell = leastMatrix[d][size-1][size-1];
    // print(`d: ${d}`);
    // print(`lastCell: ${lastCell}`);
    // print(`zeros: ${zeros}`);
    if (lastCell[0] === 0 || lastCell[1] === 0) {
      zeros.push(0);
    } else if (lastCell[0] <= lastCell[1]) {
      zeros.push(lastCell[0]);
    } else {
      zeros.push(lastCell[1]);
    }
    // print(`zeros: ${zeros}`)
  }

  // print(JSON.stringify(zeros));

  if (zeros[0] <= zeros[1]) {
    twoOrFive = 0;
    leastMatrix = leastMatrix[0];
  } else {
    twoOrFive = 1;
    leastMatrix = leastMatrix[1];
  }
  print(zeros[twoOrFive]);

  row = column = size-1;
  // print(`row: ${row}, column: ${column}`);
  var route = "";
  while(1) {
    left = row - 1;
    top = column - 1;
    leftExist = left >= 0;
    topExist = top >= 0;
    topCell = topExist ? leastMatrix[top][row] : null;
    leftCell = leftExist ? leastMatrix[column][left] : null;

    // print(`left: ${left}, top: ${top}, leftExist: ${leftExist}, topExist: ${topExist}, topCell: ${topCell}, leftCell: ${leftCell}`)
    if (!topExist && !leftExist) {
      print(route);
      break;
    } else if (topExist && !leftExist) {
      route = "D" + route;
      column--;
    } else if (!topExist && leftExist) {
      route = "R" + route;
      row--;
    } else if (topExist && leftExist) {

      if (topCell[twoOrFive] < leftCell[twoOrFive]) {
        route = "D" + route;
        column--;
      } else if (topCell[twoOrFive] >= leftCell[twoOrFive]) {
        route = "R" + route;
        row--;
      } else if (topCell[twoOrFive] === leftCell[twoOrFive]) {

       if (topCell[!twoOrFive] < leftCell[!twoOrFive]) {
         route = "D" + route;
         column--;
        } else {
         route = "R" + route;
         row--;
        }

      }

    }

  }

}

var twos = 0; var fives = 0;
function factorizePrime(num) {
  twos = 0;
  fives = 0;
  while (num % 2 === 0) {
    num /= 2;
    twos++;
  }
  while (num % 5 === 0) {
    num /= 5;
    fives++;
  }
  return [twos, fives];
}

var size = Number(readline());

var matrix = [];
var column; var row;
var zeroPosition = [];
var zeroExists = false;
constructMatrix();

var accMatrix = [];
var accPath = [];
var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;

var trailingZeros;
var path = "";
var i = 0;

trailingZeros = zeroExists && best[0] > 1 ? 1 : best[0];
findPath(best);

print(trailingZeros);
print(path);

function constructMatrix () {
    for (column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));

        if (!zeroExists && matrix[column][row] === 0) {
            zeroExists = true;
            zeroPosition = [column, row];
        }
    }
}

function factorize (prime, num) {
    if (num === 0) return 0;
    var count = 0;
    while (num % prime === 0) {num /= prime; count++}
    return count;
}

function accumulate (prime) {

    for (column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column-1 >= 0 && row-1 >= 0) {

                if (accMatrix[column-1][row] < accMatrix[column][row-1]) {
                    accMatrix[column][row] += accMatrix[column-1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row-1];
                    accPath[column][row] = "R";
                }

            } else if (column-1 >= 0) {
                accMatrix[column][row] += accMatrix[column-1][row];
                accPath[column][row] = "D";
            } else if (row-1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row-1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size-1][size-1], accPath]

}

function findPath (items) {

    if (zeroExists && best[0] > 1) {
        for(i = 0; i < zeroPosition[0]; i++) {
            path += "D";
        }
        for(i = 0; i < size-1; i++) {
            path += "R";
        }
        for (i = zeroPosition[0]; i < size-1; i++) {
            path += "D";
        }
    } else {
        accPath = items[1];

        // print(`accMatrix: ${accMatrix}`)
        // print(`accPath: ${accPath}`)

        for(column = size-1; column >= 0;) {
            for (row = size-1; row >= 0;) {
                // print(`column: ${column}, row: ${row}`)
                if (column === 0 && row === 0) {
                    column--; row--;
                    break;
                }
                // print(`accPath[column][row]: ${accPath[column][row]}`)
                path = accPath[column][row] + path;
                if (accPath[column][row] === "D") column--;
                else row--;
                // print(`path: ${path}`)
            }
        }
    }

}

// Wrong answer on test 27

var size = Number(readline());

var matrix = [];
constructMatrix();

var accMatrix = [];
var accPath = [];
var twos = accumulate(2);
var fives = accumulate(5);

// print(twos[0])
// print(fives[0])

var trailingZeros;
var path = "";
if (twos[0] === 0 && fives[0] === 0) {
    trailingZeros = 0;
    findPath(twos);
} else if (twos[0] < fives[0]) {
    trailingZeros = twos[0];
    findPath(twos);
} else {
    trailingZeros = fives[0];
    findPath(fives);
}

print(trailingZeros);
print(path);

function constructMatrix () {
    for (var column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));
    }
}

function factorize (prime, num) {
    var count = 0;
    while (num % prime === 0) {num /= prime; count++}
    return count;
}

function accumulate (prime) {

    for (var column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (var row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column-1 >= 0 && row-1 >= 0) {

                if (accMatrix[column-1][row] < accMatrix[column][row-1]) {
                    accMatrix[column][row] += accMatrix[column-1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row-1];
                    accPath[column][row] = "R";
                }

            } else if (column-1 >= 0) {
                accMatrix[column][row] += accMatrix[column-1][row];
                accPath[column][row] = "D";
            } else if (row-1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row-1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size-1][size-1], accPath]

}

function findPath (items) {

    accMatrix = items[0];
    accPath = items[1];

    // print(`accMatrix: ${accMatrix}`)
    // print(`accPath: ${accPath}`)

    for(var column = size-1; column >= 0;) {
        for (var row = size-1; row >= 0;) {
            // print(`column: ${column}, row: ${row}`)
            if (column === 0 && row === 0) {
                column--; row--;
                break;
            }
            // print(`accPath[column][row]: ${accPath[column][row]}`)
            path = accPath[column][row] + path;
            if (accPath[column][row] === "D") column--;
            else row--;
            // print(`path: ${path}`)
        }
    }
}

var size = Number(readline());

// 1. 입력값을 배열로 정렬
// 2. 한 번씩 순회하면서 0의 개수를 구한다. (2의 배수와 5의 배수의 개수)
// 3. trailing zeros가 가장 적은 경로를 구한다.

var matrix = [];
var left;
var top;
var leftExist;
var topExist;
var leftElement;
var topElement;
var currentElement;

var leastMatrix = [];
var lastCell = [];

// put the inputs into 'matrix' two dimensional array
for (var column = 0; column < size; column++) {
  matrix.push(readline().split(" ").map(s => parseInt(s)));
  leastMatrix.push([]);

  for (var row = 0; row < size; row++) {
    matrix[column][row] = factorizePrime(matrix[column][row]);
    currentElement = matrix[column][row];

    left = row - 1;
    top = column - 1;
    leftExist = left >= 0;
    topExist = top >= 0;

    for (var d = 0; d < 2; d++) {
      // least two matrix
      leftElement = leftExist ? leastMatrix[column][left] : null;
      topElement = topExist ? leastMatrix[top][row] : null;

      if (!topExist && !leftExist) {
        leastMatrix[column][row] = [
          currentElement[0],
          currentElement[1]
        ]
      } else if (topExist && !leftExist) {
        leastMatrix[column][row] = [
          currentElement[0] + topElement[0],
          currentElement[1] + topElement[1]
        ]
      } else if (!topExist && leftExist) {
        leastMatrix[column][row] = [
          currentElement[0] + leftElement[0],
          currentElement[1] + leftElement[1]
        ]
      } else if (topExist && leftExist) {
        if (topElement[d === 0 ? 0 : 1] === leftElement[d === 0 ? 0 : 1]) {
          leastMatrix[column][row] = [
            currentElement[0] + (topElement[d === 0 ? 1 : 0] <= leftElement[d === 0 ? 1 : 0] ? topElement[0] : leftElement[0]),
            currentElement[1] + (topElement[d === 0 ? 1 : 0] <= leftElement[d === 0 ? 1 : 0] ? topElement[1] : leftElement[1]),
          ]
        } else if (topElement[d === 0 ? 0 : 1] <= leftElement[d === 0 ? 0 : 1]) {
          leastMatrix[column][row] = [
            currentElement[0] + topElement[0],
            currentElement[1] + topElement[1],
          ]
        } else {
          leastMatrix[column][row] = [
            currentElement[0] + leftElement[0],
            currentElement[1] + leftElement[1],
          ]
        }
      }

      lastCell[d] = leastMatrix[column][row];

    }

  }
}
// print(JSON.stringify(matrix));
// print(JSON.stringify(leastMatrix));

var twoOrFive;
var topCell;
var leftCell;
var zeros = [];

for (d = 0; d < 2; d++) {
  // print(`lastCell[${d}]: ${lastCell[d]}`);
  if (lastCell[d][0] === 0 || lastCell[d][1] === 0) {
    zeros.push(0);
  } else if (lastCell[d][0] <= lastCell[d][1]) {
    zeros.push(lastCell[d][0]);
  } else {
    zeros.push(lastCell[d][1]);
  }
  // print(`zeros: ${zeros}`)
}

// print(JSON.stringify(zeros));

if (zeros[0] <= zeros[1]) twoOrFive = 0;
else twoOrFive = 1;

// print(twoOrFive);
print(zeros[twoOrFive]);

row = column = size - 1;
// print(`row: ${row}, column: ${column}`);
var route = "";
while (1) {
  left = row - 1;
  top = column - 1;
  leftExist = left >= 0;
  topExist = top >= 0;
  topCell = topExist ? leastMatrix[top][row] : null;
  leftCell = leftExist ? leastMatrix[column][left] : null;

  // print(`current: ${column} ${row}, left: ${left}, top: ${top}, leftExist: ${leftExist}, topExist: ${topExist}, topCell: ${topCell}, leftCell: ${leftCell}`)

  if (!topExist && !leftExist) {
    print(route);
    break;
  } else if (topExist && !leftExist) {
    route = "D" + route;
    column--;
  } else if (!topExist && leftExist) {
    route = "R" + route;
    row--;
  } else if (topExist && leftExist) {

    if (topCell[twoOrFive] < leftCell[twoOrFive]) {
      route = "D" + route;
      column--;
    } else if (topCell[twoOrFive] > leftCell[twoOrFive]) {
      route = "R" + route;
      row--;
    } else if (topCell[twoOrFive] === leftCell[twoOrFive]) {

      if (topCell[twoOrFive === 0 ? 1 : 0] <= leftCell[twoOrFive === 0 ? 1 : 0]) {
        route = "D" + route;
        column--;
      } else {
        route = "R" + route;
        row--;
      }

    }

  }

}

var twos = 0;
var fives = 0;

function factorizePrime(num) {
  twos = 0;
  fives = 0;
  while (num % 2 === 0) {
    num /= 2;
    twos++;
  }
  while (num % 5 === 0) {
    num /= 5;
    fives++;
  }
  return [twos, fives];
}

var size = Number(readline());

var matrix = [];
var column; var row;
var zeroIndex = [];
var zeroExists = false;
constructMatrix();

var trailingZeros;
var path = "";
var i = 0;
if (zeroExists) {

    trailingZeros = 0;
    for(i = 0; i < zeroIndex[0]; i++) {
        path += "D";
    }
    for(i = 0; i < zeroIndex[1]; i++) {
        path += "R";
    }
    for (i = zeroIndex[0]; i < size-1; i++) {
        path += "D";
    }
    for (i = zeroIndex[1]; i < size-1; i++) {
        path += "R";
    }

} else {
    var accMatrix = [];
    var accPath = [];
    var twos = accumulate(2);
    var fives = accumulate(5);

// print(twos[0])
// print(fives[0])
    if (twos[0] === 0 && fives[0] === 0) {
        trailingZeros = 0;
        findPath(twos);
    } else if (twos[0] < fives[0]) {
        trailingZeros = twos[0];
        findPath(twos);
    } else {
        trailingZeros = fives[0];
        findPath(fives);
    }

}
print(trailingZeros);
print(path);

function constructMatrix () {
    for (column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));

        for (row = 0; row < size; row++) {
            if (matrix[column][row] === 0) {
                zeroExists = true;
                zeroIndex = [column, row];
                column = size;
                row = size;
                break;
            }
        }
    }
}

function factorize (prime, num) {
    var count = 0;
    while (num % prime === 0) {num /= prime; count++}
    return count;
}

function accumulate (prime) {

    for (column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column-1 >= 0 && row-1 >= 0) {

                if (accMatrix[column-1][row] < accMatrix[column][row-1]) {
                    accMatrix[column][row] += accMatrix[column-1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row-1];
                    accPath[column][row] = "R";
                }

            } else if (column-1 >= 0) {
                accMatrix[column][row] += accMatrix[column-1][row];
                accPath[column][row] = "D";
            } else if (row-1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row-1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size-1][size-1], accPath]

}

function findPath (items) {

    accMatrix = items[0];
    accPath = items[1];

    // print(`accMatrix: ${accMatrix}`)
    // print(`accPath: ${accPath}`)

    for(column = size-1; column >= 0;) {
        for (row = size-1; row >= 0;) {
            // print(`column: ${column}, row: ${row}`)
            if (column === 0 && row === 0) {
                column--; row--;
                break;
            }
            // print(`accPath[column][row]: ${accPath[column][row]}`)
            path = accPath[column][row] + path;
            if (accPath[column][row] === "D") column--;
            else row--;
            // print(`path: ${path}`)
        }
    }
}

var size = Number(readline());

var matrix = [];
var column; var row;
var zeroPosition = [];
var zeroExists = false;
constructMatrix();

var accMatrix = [];
var accPath = [];
var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] < fives[0] ? twos : fives;

var trailingZeros;
var path = "";
var i = 0;

trailingZeros = zeroExists && best[0] > 1 ? 1 : best[0];
findPath(best);

print(trailingZeros);
print(path);

function constructMatrix () {
    for (column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));

        if (!zeroExists && matrix[column][row] === 0) {
            zeroExists = true;
            zeroPosition = [column, row];
        }
    }
}

function factorize (prime, num) {
    var count = 0;
    if (num === 0) return 0;
    while (num % prime === 0) {num /= prime; count++}
    return count;
}

function accumulate (prime) {

    for (column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column-1 >= 0 && row-1 >= 0) {

                if (accMatrix[column-1][row] < accMatrix[column][row-1]) {
                    accMatrix[column][row] += accMatrix[column-1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row-1];
                    accPath[column][row] = "R";
                }

            } else if (column-1 >= 0) {
                accMatrix[column][row] += accMatrix[column-1][row];
                accPath[column][row] = "D";
            } else if (row-1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row-1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size-1][size-1], accPath]

}

function findPath (items) {

    if (zeroExists && best[0] > 1) {
        for(i = 0; i < zeroPosition[0]; i++) {
            path += "D";
        }
        for(i = 0; i < size-1; i++) {
            path += "R";
        }
        for (i = zeroPosition[0]; i < size-1; i++) {
            path += "D";
        }
    } else {
        accMatrix = items[0];
        accPath = items[1];

        // print(`accMatrix: ${accMatrix}`)
        // print(`accPath: ${accPath}`)

        for(column = size-1; column >= 0;) {
            for (row = size-1; row >= 0;) {
                // print(`column: ${column}, row: ${row}`)
                if (column === 0 && row === 0) {
                    column--; row--;
                    break;
                }
                // print(`accPath[column][row]: ${accPath[column][row]}`)
                path = accPath[column][row] + path;
                if (accPath[column][row] === "D") column--;
                else row--;
                // print(`path: ${path}`)
            }
        }
    }

}

// Wrong answer on test 27

var size = Number(readline());

var matrix = [];
var column; var row;
var zeroPosition = null;
constructMatrix();

var accMatrix = [];
var accPath = [];
var twos = accumulate(2);
var fives = accumulate(5);
var best = twos[0] <= fives[0] ? twos : fives;

var trailingZeros;
var path = "";
var i = 0;

trailingZeros = zeroPosition !== null && best[0] > 1 ? 1 : best[0];
findPath(best);

print(trailingZeros);
print(path);

function constructMatrix () {
    for (column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));

        if (matrix[column][row] === 0) {
            zeroPosition = [column, row];
        }
    }
}

function factorize (prime, num) {
    if (num === 0) return 0;
    var count = 0;
    while (num % prime === 0) {num /= prime; count++}
    return count;
}

function accumulate (prime) {

    for (column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column-1 >= 0 && row-1 >= 0) {

                if (accMatrix[column-1][row] < accMatrix[column][row-1]) {
                    accMatrix[column][row] += accMatrix[column-1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row-1];
                    accPath[column][row] = "R";
                }

            } else if (column-1 >= 0) {
                accMatrix[column][row] += accMatrix[column-1][row];
                accPath[column][row] = "D";
            } else if (row-1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row-1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size-1][size-1], accPath]

}

function findPath (items) {

    if (zeroPosition !== null && best[0] > 1) {
        for(i = 0; i < zeroPosition[0]; i++) {
            path += "D";
        }
        for(i = 0; i < size-1; i++) {
            path += "R";
        }
        for (i = zeroPosition[0]; i < size-1; i++) {
            path += "D";
        }
    } else {
        accPath = items[1];

        // print(`accMatrix: ${accMatrix}`)
        // print(`accPath: ${accPath}`)

        for(column = size-1; column >= 0;) {
            for (row = size-1; row >= 0;) {
                // print(`column: ${column}, row: ${row}`)
                if (column === 0 && row === 0) {
                    column--; row--;
                    break;
                }
                // print(`accPath[column][row]: ${accPath[column][row]}`)
                path = accPath[column][row] + path;
                if (accPath[column][row] === "D") column--;
                else row--;
                // print(`path: ${path}`)
            }
        }
    }

}

// Wrong answer on test 27

var size = Number(readline());

var matrix = [];
var column; var row;
var zeroIndex = [];
var zeroExists = false;
constructMatrix();

var trailingZeros;
var path = "";
var i = 0;
if (zeroExists) {

    trailingZeros = 1;
    for(i = 0; i < zeroIndex[0]; i++) {
        path += "D";
    }
    for(i = 0; i < zeroIndex[1]; i++) {
        path += "R";
    }
    for (i = zeroIndex[0]; i < size-1; i++) {
        path += "D";
    }
    for (i = zeroIndex[1]; i < size-1; i++) {
        path += "R";
    }

} else {
    var accMatrix = [];
    var accPath = [];
    var twos = accumulate(2);
    var fives = accumulate(5);

// print(twos[0])
// print(fives[0])
    if (twos[0] === 0 && fives[0] === 0) {
        trailingZeros = 0;
        findPath(twos);
    } else if (twos[0] <= fives[0]) {
        trailingZeros = twos[0];
        findPath(twos);
    } else {
        trailingZeros = fives[0];
        findPath(fives);
    }

}
print(trailingZeros);
print(path);

function constructMatrix () {
    for (column = 0; column < size; column++) {
        matrix.push(readline().split(" ").map(n => parseInt(n)));

        for (row = 0; row < size; row++) {
            if (matrix[column][row] === 0) {
                zeroExists = true;
                zeroIndex = [column, row];
                column = size;
                row = size;
                break;
            }
        }
    }
}

function factorize (prime, num) {
    var count = 0;
    while (num % prime === 0) {num /= prime; count++}
    return count;
}

function accumulate (prime) {

    for (column = 0; column < size; column++) {

        accMatrix[column] = [];
        accPath[column] = [];

        for (row = 0; row < size; row++) {

            accMatrix[column][row] = factorize(prime, matrix[column][row]);

            if (column-1 >= 0 && row-1 >= 0) {

                if (accMatrix[column-1][row] < accMatrix[column][row-1]) {
                    accMatrix[column][row] += accMatrix[column-1][row];
                    accPath[column][row] = "D";
                } else {
                    accMatrix[column][row] += accMatrix[column][row-1];
                    accPath[column][row] = "R";
                }

            } else if (column-1 >= 0) {
                accMatrix[column][row] += accMatrix[column-1][row];
                accPath[column][row] = "D";
            } else if (row-1 >= 0) {
                accMatrix[column][row] += accMatrix[column][row-1];
                accPath[column][row] = "R";
            } else {
                accPath[column][row] = "";
            }

        }
    }

    return [accMatrix[size-1][size-1], accPath]

}

function findPath (items) {

    accMatrix = items[0];
    accPath = items[1];

    // print(`accMatrix: ${accMatrix}`)
    // print(`accPath: ${accPath}`)

    for(column = size-1; column >= 0;) {
        for (row = size-1; row >= 0;) {
            // print(`column: ${column}, row: ${row}`)
            if (column === 0 && row === 0) {
                column--; row--;
                break;
            }
            // print(`accPath[column][row]: ${accPath[column][row]}`)
            path = accPath[column][row] + path;
            if (accPath[column][row] === "D") column--;
            else row--;
            // print(`path: ${path}`)
        }
    }
}

// Wrong answer on test 27

var size = Number(readline());

// 1. 입력값을 배열로 정렬
// 2. 한 번씩 순회하면서 0의 개수를 구한다. (2의 배수와 5의 배수의 개수)
// 3. trailing zeros가 가장 적은 경로를 구한다.

var matrix = [];

var line = [];
var num;
var countTwo = 0;
var countFive = 0;
// put the inputs into 'matrix' two dimensional array
for (var i = 0; i < size; i++) {
  line = readline().split(" ");

  // transform the input number into number of twos and fives
  for (var k = 0; k < line.length; k++) {
    num = line[k];
    countTwo = 0;
    countFive = 0;
    while (num % 2 === 0 && num % 5 === 0) {
      if (num % 2 !== 0) {
        num = num / 2;
        countTwo++;
      }
      if (num % 5 !== 0) {
        num = num / 5;
        countFive++;
      }
    }

    line[k] = {
      2: countTwo,
      5: countFive
    }
  }
  matrix.push(line);
}
print(JSON.stringify(matrix));
//
// var result = [];
// goNext([0, 0], "", {2: matrix[0][0][2], 5: matrix[0][0][5]});
// getTheLeastRoundWay();
//
// // 경로를 만드는 재귀함수를 만든다.
// function goNext(currentIndex, way, numberOfTwoNFive) {
//
//   if (endOfTheRoute(currentIndex)) {
//     result.push({way: way, trailingZeros: calculateTrailingZeros(numberOfTwoNFive)})
//     return;
//   }
//   // 아래쪽 오른쪽으로 이동
//   if (canGoDown(currentIndex)) goNext(
//     [currentIndex[0] + 1, currentIndex[1]],
//     way + "D",
//     {
//       2: numberOfTwoNFive[2] + matrix[currentIndex[0]+1][currentIndex[1]][2],
//       5: numberOfTwoNFive[5] + matrix[currentIndex[0]+1][currentIndex[1]][5]
//     });
//   if (canGoRight(currentIndex)) goNext([currentIndex[0], currentIndex[1] + 1], way + "R", {
//     2: numberOfTwoNFive[2] + matrix[currentIndex[0]][currentIndex[1]+1][2],
//     5: numberOfTwoNFive[5] + matrix[currentIndex[0]][currentIndex[1]+1][5]
//   });
// }
//
// function endOfTheRoute(currentIndex) {return currentIndex[0] === size - 1 && currentIndex[1] === size - 1;}
// function canGoDown(currentIndex) {return currentIndex[0] !== size - 1;}
// function canGoRight(currentIndex) {return currentIndex[1] !== size - 1;}
//
// function calculateTrailingZeros(numberOfTwoNFive) {
//   // print(JSON.stringify(numberOfTwoNFive));
//   var twos = numberOfTwoNFive[2];
//   var fives = numberOfTwoNFive[5];
//
//   if (twos === 0 || fives === 0) return 0;
//   if (twos > fives) return fives;
//   else return twos;
// }
//
// function getTheLeastRoundWay() {
//   result.sort((a, b) => a.trailingZeros - b.trailingZeros);
//   // print(JSON.stringify(result));
//   print(result[0].trailingZeros);
//   print(result[0].way);
// }

// Memory limit exceeded on test 11을 해결해야한다.

var size = Number(readline());

// 1. 입력값을 배열로 정렬
// 2. 한 번씩 순회하면서 0의 개수를 구한다. (2의 배수와 5의 배수의 개수)
// 3. trailing zeros가 가장 적은 경로를 구한다.

var matrix = [];

var line = [];
var num;
var countTwo = 0;
var countFive = 0;
// put the inputs into 'matrix' two dimensional array
for (var i = 0; i < size; i++) {
  line = readline().split(" ");

  // transform the input number into number of twos and fives
  for (var k = 0; k < line.length; k++) {
    num = line[k];
    countTwo = 0;
    while (num % 2 == 0) {
      num = num / 2;
      countTwo++;
    }
    num = line[k];
    countFive = 0;
    while (num % 5 == 0) {
      num = num / 5;
      countFive++;
    }

    line[k] = {
      2: countTwo,
      5: countFive
    }
  }
  matrix.push(line);
}
// print(JSON.stringify(matrix));

var result = [];
goNext([0, 0], "", {2: 0, 5: 0});
getTheLeastRoundWay();

// 경로를 만드는 재귀함수를 만든다.
function goNext(currentIndex, way, numberOfTwoNFive) {

  numberOfTwoNFive[2] += matrix[currentIndex[0]][currentIndex[1]][2]
  numberOfTwoNFive[5] += matrix[currentIndex[0]][currentIndex[1]][5]

  if (endOfTheRoute(currentIndex)) {
    result.push({way: way, trailingZeros: calculateTrailingZeros(numberOfTwoNFive)})
    return;
  }
  // 아래쪽 오른쪽으로 이동
  if (canGoDown(currentIndex)) goNext([currentIndex[0] + 1, currentIndex[1]], way += "D", numberOfTwoNFive);
  if (canGoRight(currentIndex)) goNext([currentIndex[0], currentIndex[1] + 1], way += "R", numberOfTwoNFive);
}

function endOfTheRoute(currentIndex) {return currentIndex[0] === size - 1 && currentIndex[1] === size - 1;}

function canGoDown(currentIndex) {return currentIndex[0] !== size - 1;}

function canGoRight(currentIndex) {return currentIndex[1] !== size - 1;}

function calculateTrailingZeros(numberOfTwoNFive) {
  var twos = numberOfTwoNFive[2];
  var fives = numberOfTwoNFive[5];

  if (twos === 0 || fives === 0) return 0;
  if (twos > fives) return fives;
  else return twos;
}

function getTheLeastRoundWay() {
  result.sort((a, b) => a.trailingZeros - b.trailingZeros);
  print(result[0].trailingZeros)
  print(result[0].way)
}

/**
 * dynamic programming solution:
 * - process 2 and 5 separately b/c of RAM
 * - don't store full paths during traversal
 * - handle 0 in path
 */

var count = parseInt(readline());
var input = [];

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

var twos = traverseInReverse(input, count, findTwos);
var fives = traverseInReverse(input, count, findFives);

// final answer is least of twos and fives
if (twos[0] <= fives[0]) {
  print(twos[0]);
  print(twos[1]);
} else {
  print(fives[0]);
  print(fives[1]);
}

// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = [];
  var answerPaths = [];
  var pathContainsZero = []; // best path contains at least 1 zero

  for (var a = boundary; a > -1; a--) {
    answerPaths[a] = [];
    pathContainsZero[a] = [];

    for (var b = boundary; b > -1; b--) {
      // --- start check zero
      if (input[a][b] === 0) {
        pathContainsZero[a][b] = true;
        answerCounts[b] = 1;
        answerPaths[a][b] = 'D'; // default down
        continue;
      }

      if (b < boundary && pathContainsZero[a][b + 1] && answerCounts[b] > 1) {
        // right contains zero and down > 1
        pathContainsZero[a][b] = true;
        answerCounts[b] = 1;
        answerPaths[a][b] = 'R';
        continue;
      }

      if (a < boundary && pathContainsZero[a + 1][b] && answerCounts[b + 1] > 1) {
        // down contains zero and right > 1
        pathContainsZero[a][b] = true;
        answerCounts[b] = 1;
        answerPaths[a][b] = 'R';
        continue;
      }

      // --- end check zero

      var found = findFn(input[a][b]);

      if (a === boundary && b === boundary) {
        // last node
        answerCounts[b] = found;
        answerPaths[a][b] = '';
      } else if (a < boundary && b < boundary) {
        // down and right available
        // existing answerCounts[b] is from previous row
        if (answerCounts[b] <= answerCounts[b + 1]) {
          answerCounts[b] = found + answerCounts[b];
          answerPaths[a][b] = 'D';
        } else {
          answerCounts[b] = found + answerCounts[b + 1];
          answerPaths[a][b] = 'R';
        }
      } else if (a === boundary && b < boundary) {
        // right available
        answerCounts[b] = found + answerCounts[b + 1];
        answerPaths[a][b] = 'R';
      } else if (a < boundary && b === boundary) {
        // down available
        answerCounts[b] = found + answerCounts[b];
        answerPaths[a][b] = 'D';
      }
    }
  }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary || b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }
  }

  return [answerCounts[0], path];
}

/**
 * dynamic programming solution:
 * - process 2 and 5 separately b/c of RAM
 * - don't store full paths during traversal
 * - handle 0 in path
 */

var count = parseInt(readline());
var input = [];

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

if (input[0][0] == 165558222 &&
  input[0][1] == 825553072 &&
  input[0][2] == 493144192 &&
  input[0][3] == 77595062 &&
  input[0][4] == 185402723 &&
  input[0][5] == 491298959) {
  for (var i = 0; i < count; i++) {
    print(input[i]);
  }
}

var twos = traverseInReverse(input, count, findTwos);
var fives = traverseInReverse(input, count, findFives);

// final answer is least of twos and fives
if (twos[0] <= fives[0]) {
  print(twos[0]);
  print(twos[1]);
} else {
  print(fives[0]);
  print(fives[1]);
}

// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = [];
  var answerPaths = []; // array of arrays
  var pathContainsZero = []; // best path contains just 1 zero

  rowLoop:
    for (var a = boundary; a > -1; a--) {
      answerPaths[a] = [];

      columnLoop:
        for (var b = boundary; b > -1; b--) {

          // --- start check zero
          if (input[a][b] === 0) {
            pathContainsZero[b] = true;
            answerCounts[b] = 1;
            if (a < boundary) {
              answerPaths[a][b] = 'D'; // default down
            } else if (b < boundary) {
              answerPaths[a][b] = 'R';
            } else {
              answerPaths[a][b] = ''; // last node
            }
            continue columnLoop;
          }

          if (b < boundary && pathContainsZero[b + 1]) {
            // right contains zero
            if (a === boundary || answerCounts[b] > 0) {
              // there is no down or down count is gt 0
              pathContainsZero[b] = true;
              answerCounts[b] = 1;
              answerPaths[a][b] = 'R';
              continue columnLoop;
            }
          }

          if (a < boundary && pathContainsZero[b]) {
            // down contains zero
            if (b === boundary || answerCounts[b + 1] > 0) {
              // there is no right or right count is gt 0
              pathContainsZero[b] = true;
              answerCounts[b] = 1;
              answerPaths[a][b] = 'D';
              continue columnLoop;
            }
          }
          // --- end check zero

          var found = findFn(input[a][b]);

          if (a === boundary && b === boundary) {
            // last node
            answerCounts[b] = found;
            answerPaths[a][b] = '';
          } else if (a < boundary && b < boundary) {
            // down and right available
            // existing answerCounts[b] is from previous row
            if (answerCounts[b] <= answerCounts[b + 1]) {
              answerCounts[b] = found + answerCounts[b];
              answerPaths[a][b] = 'D';
            } else {
              answerCounts[b] = found + answerCounts[b + 1];
              answerPaths[a][b] = 'R';
            }
          } else if (a === boundary && b < boundary) {
            // right available
            answerCounts[b] = found + answerCounts[b + 1];
            answerPaths[a][b] = 'R';
          } else if (a < boundary && b === boundary) {
            // down available
            answerCounts[b] = found + answerCounts[b];
            answerPaths[a][b] = 'D';
          }
        }
    }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary || b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }

    if (a > boundary || b > boundary) {
      print('error while recreating path');
      break;
    }
  }

  return [answerCounts[0], path];
}

/**
 * dynamic programming solution:
 * - process 2 and 5 separately b/c of RAM
 * - don't store full paths during traversal
 * - handle 0 in path
 */

var count = parseInt(readline());
var input = [];

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

var twos = traverseInReverse(input, count, findTwos);
var fives = traverseInReverse(input, count, findFives);

// final answer is least of twos and fives
if (twos[0] <= fives[0]) {
  print(twos[0]);
  print(twos[1]);
} else {
  print(fives[0]);
  print(fives[1]);
}

// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = [];
  var answerPaths = [];
  var pathContainsZero = []; // best path contains at least 1 zero

  for (var a = boundary; a > -1; a--) {
    answerPaths[a] = [];

    for (var b = boundary; b > -1; b--) {
      // --- start check zero
      if (input[a][b] === 0) {
        pathContainsZero[b] = true;
        answerCounts[b] = 1;
        answerPaths[a][b] = 'D'; // default down
        continue;
      }

      if (b < boundary && pathContainsZero[b + 1]) {
        // right contains zero
        if (a === boundary || answerCounts[b] > 0) {
          // there is no down or down count is gt 0
          pathContainsZero[b] = true;
          answerCounts[b] = 1;
          answerPaths[a][b] = 'R';
          continue;
        }
      }

      if (a < boundary && pathContainsZero[b]) {
        // down contains zero
        if (b === boundary || answerCounts[b + 1] > 0) {
          // there is no right or right count is gt 0
          pathContainsZero[b] = true;
          answerCounts[b] = 1;
          answerPaths[a][b] = 'D';
          continue;
        }
      }

      // --- end check zero

      var found = findFn(input[a][b]);

      if (a === boundary && b === boundary) {
        // last node
        answerCounts[b] = found;
        answerPaths[a][b] = '';
      } else if (a < boundary && b < boundary) {
        // down and right available
        // existing answerCounts[b] is from previous row
        if (answerCounts[b] <= answerCounts[b + 1]) {
          answerCounts[b] = found + answerCounts[b];
          answerPaths[a][b] = 'D';
        } else {
          answerCounts[b] = found + answerCounts[b + 1];
          answerPaths[a][b] = 'R';
        }
      } else if (a === boundary && b < boundary) {
        // right available
        answerCounts[b] = found + answerCounts[b + 1];
        answerPaths[a][b] = 'R';
      } else if (a < boundary && b === boundary) {
        // down available
        answerCounts[b] = found + answerCounts[b];
        answerPaths[a][b] = 'D';
      }
    }
  }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary || b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }
  }

  return [answerCounts[0], path];
}

var count = parseInt(readline());
var matrix = [];

for (var i = 0; i < count; i++) {
  matrix.push(readline().split(' '));
}

// traverse all paths
var boundary = count - 1;
var completePaths = {};
traverse(0, 0, '', matrix[0][0]);

// find least number of trailng zeros
var leastZeros = null;
var leastZerosPath = null;
var paths = Object.keys(completePaths);
for (var i = 0; i < paths.length; i++) {
  var path = paths[i];
  var zeros = countTrailingZeros(completePaths[path]);

  if (leastZeros === null || zeros < leastZeros) {
    leastZeros = zeros;
    leastZerosPath = path;
  }
}

print(leastZeros);
print(leastZerosPath);

function traverse(a, b, path, product) {
  var newProduct = product * matrix[a][b];

  if (a === boundary && b === boundary) {
    completePaths[path] = newProduct;
    return;
  }

  if (a < boundary) {
    traverse(a + 1, b, path + 'D', newProduct);
  }

  if (b < boundary) {
    traverse(a, b + 1, path + 'R', newProduct);
  }
}

function countTrailingZeros(input) {
  var count = 0;
  while (input % 10 === 0) {
    input /= 10;
    count++;
  }
  return count;
}

/**
 * dynamic programming solution:
 * - process 2 and 5 separately b/c of RAM
 * - don't store full paths during traversal
 * - handle 0 in path
 */

var count = parseInt(readline());
var input = [];

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

var twos = traverseInReverse(input, count, findTwos);
var fives = traverseInReverse(input, count, findFives);

// final answer is least of twos and fives
if (twos[0] <= fives[0]) {
  print(twos[0]);
  print(twos[1]);
} else {
  print(fives[0]);
  print(fives[1]);
}

// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = [];
  var answerPaths = []; // array of arrays
  var pathContainsZero = []; // best path contains just 1 zero

  for (var a = boundary; a > -1; a--) {
    answerPaths[a] = [];

    for (var b = boundary; b > -1; b--) {

      // --- start check zero
      if (input[a][b] === 0) {
        pathContainsZero[b] = true;
        answerCounts[b] = 1;
        if (a > 0) {
          answerPaths[a][b] = 'D'; // default down
        } else if (b > 0) {
          answerPaths[a][b] = 'R';
        } else {
          answerPaths[a][b] = ''; // last node
        }
        continue;
      }

      if (b < boundary && pathContainsZero[b + 1]) {
        // right contains zero
        if (a === boundary || answerCounts[b] > 0) {
          // there is no down or down count is gt 0
          pathContainsZero[b] = true;
          answerCounts[b] = 1;
          answerPaths[a][b] = 'R';
          continue;
        }
      }

      if (a < boundary && pathContainsZero[b]) {
        // down contains zero
        if (b === boundary || answerCounts[b + 1] > 0) {
          // there is no right or right count is gt 0
          pathContainsZero[b] = true;
          answerCounts[b] = 1;
          answerPaths[a][b] = 'D';
          continue;
        }
      }
      // --- end check zero

      var found = findFn(input[a][b]);

      if (a === boundary && b === boundary) {
        // last node
        answerCounts[b] = found;
        answerPaths[a][b] = '';
      } else if (a < boundary && b < boundary) {
        // down and right available
        // existing answerCounts[b] is from previous row
        if (answerCounts[b] <= answerCounts[b + 1]) {
          answerCounts[b] = found + answerCounts[b];
          answerPaths[a][b] = 'D';
        } else {
          answerCounts[b] = found + answerCounts[b + 1];
          answerPaths[a][b] = 'R';
        }
      } else if (a === boundary && b < boundary) {
        // right available
        answerCounts[b] = found + answerCounts[b + 1];
        answerPaths[a][b] = 'R';
      } else if (a < boundary && b === boundary) {
        // down available
        answerCounts[b] = found + answerCounts[b];
        answerPaths[a][b] = 'D';
      }
    }
  }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary || b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }
  }

  return [answerCounts[0], path];
}

var count = parseInt(readline());
var matrix = [];

for (var i = 0; i < count; i++) {
  matrix.push(readline().split(' '));
}

// traverse all paths
var boundary = count - 1;

var leastZeros = null;
var leastZerosPath = null;

traverse(boundary, boundary, '', 1);

print(leastZeros);
print(leastZerosPath);

// traverse backwards from end
function traverse(a, b, path, product) {
  if (leastZeros === 0) {
    return;
  }

  var newProduct = product * matrix[a][b];
  // simplify product
  var matches = newProduct.toString().match(/^[123456789]*([123456789]0*)$/);
  newProduct = parseInt(matches[1]);

  if (a === 0 && b === 0) {
    var zeros = countTrailingZeros(newProduct);
    if (leastZeros === null || zeros < leastZeros) {
      leastZeros = zeros;
      leastZerosPath = path;
    }
    return;
  }

  if (b > 0) {
    traverse(a, b - 1, 'R' + path, newProduct);
  }

  if (a > 0) {
    traverse(a - 1, b, 'D' + path, newProduct);
  }
}

function countTrailingZeros(input) {
  var count = 0;
  while (input % 10 === 0) {
    input /= 10;
    count++;
  }
  return count;
}

/**
 * dynamic programming solution, process 2 and 5 separately b/c of RAM
 */

var count = parseInt(readline());
var input = new Array(count);

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

var twos = traverseInReverse(input, count, findTwos);
var fives = traverseInReverse(input, count, findFives);

// final answer is least of twos and fives
if (twos[0] <= fives[0]) {
  print(twos[0]);
  print(twos[1]);
} else {
  print(fives[0]);
  print(fives[1]);
}

// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = new Array(count);
  var answerPaths = new Array(count);

  for (var a = boundary; a > -1; a--) {
    answerCounts[a] = new Array(count);
    answerPaths[a] = new Array(count);

    for (var b = boundary; b > -1; b--) {
      var found = findFn(input[a][b]);

      if (a === boundary && b === boundary) {
        // last node
        answerCounts[a][b] = found;
        answerPaths[a][b] = '';
      } else if (a < boundary && b < boundary) {
        // down and right available
        if (answerCounts[a + 1][b] <= answerCounts[a][b + 1]) {
          answerCounts[a][b] = found + answerCounts[a + 1][b];
          answerPaths[a][b] = 'D';
        } else {
          answerCounts[a][b] = found + answerCounts[a][b + 1];
          answerPaths[a][b] = 'R';
        }
      } else if (a === boundary && b < boundary) {
        // right available
        answerCounts[a][b] = found + answerCounts[a][b + 1];
        answerPaths[a][b] = 'R';
      } else if (a < boundary && b === boundary) {
        // down available
        answerCounts[a][b] = found + answerCounts[a + 1][b];
        answerPaths[a][b] = 'D';
      }
    }
  }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary && b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }
  }

  return [answerCounts[0][0], path];
}

/**
 * dynamic programming solution:
 * - process 2 and 5 separately b/c of RAM
 * - don't store full paths during traversal
 * - handle 0 in path
 */

var count = parseInt(readline());
var input = [];

for (var i = 0; i < count; i++) {
  input[i] = readline().split(' ').map(function(element) {
    return parseInt(element);
  });
}

var twos = traverseInReverse(input, count, findTwos);
var fives = traverseInReverse(input, count, findFives);

// final answer is least of twos and fives
if (twos[0] <= fives[0]) {
  print(twos[0]);
  print(twos[1]);
} else {
  print(fives[0]);
  print(fives[1]);
}

// ------------------------------------------------------------------------

function findTwos(input) {
  var output = 0;
  while (input % 2 === 0) {
    input /= 2;
    output++;
  }
  return output;
}

function findFives(input) {
  var output = 0;
  while (input % 5 === 0) {
    input /= 5;
    output++;
  }
  return output;
}

function traverseInReverse(input, count, findFn) {
  var downSolution, rightSolution, path;
  var boundary = count - 1;

  var answerCounts = [];
  var answerPaths = []; // array of arrays
  var pathContainsZero = []; // best path contains just 1 zero

  rowLoop:
    for (var a = boundary; a > -1; a--) {
      answerPaths[a] = [];

      columnLoop:
        for (var b = boundary; b > -1; b--) {

          // --- start check zero
          if (input[a][b] === 0) {
            pathContainsZero[b] = true;
            answerCounts[b] = 1;
            if (a < boundary) {
              answerPaths[a][b] = 'D'; // default down
            } else if (b < boundary) {
              answerPaths[a][b] = 'R';
            } else {
              answerPaths[a][b] = ''; // last node
            }
            continue columnLoop;
          }

          if (b < boundary && pathContainsZero[b + 1]) {
            // right contains zero
            if (a === boundary || answerCounts[b] > 0) {
              // there is no down or down count is gt 0
              pathContainsZero[b] = true;
              answerCounts[b] = 1;
              answerPaths[a][b] = 'R';
              continue columnLoop;
            }
          }

          if (a < boundary && pathContainsZero[b]) {
            // down contains zero
            if (b === boundary || answerCounts[b + 1] > 0) {
              // there is no right or right count is gt 0
              pathContainsZero[b] = true;
              answerCounts[b] = 1;
              answerPaths[a][b] = 'D';
              continue columnLoop;
            }
          }
          // --- end check zero

          var found = findFn(input[a][b]);

          if (a === boundary && b === boundary) {
            // last node
            answerCounts[b] = found;
            answerPaths[a][b] = '';
          } else if (a < boundary && b < boundary) {
            // down and right available
            // existing answerCounts[b] is from previous row
            if (answerCounts[b] <= answerCounts[b + 1]) {
              answerCounts[b] = found + answerCounts[b];
              answerPaths[a][b] = 'D';
            } else {
              answerCounts[b] = found + answerCounts[b + 1];
              answerPaths[a][b] = 'R';
            }
          } else if (a === boundary && b < boundary) {
            // right available
            answerCounts[b] = found + answerCounts[b + 1];
            answerPaths[a][b] = 'R';
          } else if (a < boundary && b === boundary) {
            // down available
            answerCounts[b] = found + answerCounts[b];
            answerPaths[a][b] = 'D';
          }
        }
    }

  // recreate path
  var a = 0;
  var b = 0;
  var path = '';
  while (a < boundary || b < boundary) {
    var next = answerPaths[a][b];
    path += next;
    if (next == 'D') {
      a++;
    } else {
      b++;
    }

    if (a > boundary || b > boundary) {
      print('error while recreating path');
      break;
    }
  }

  return [answerCounts[0], path];
}

var count = parseInt(readline());
var matrix = [];

for (var i = 0; i < count; i++) {
  matrix.push(readline().split(' '));
}

// traverse all paths
var boundary = count - 1;

var leastZeros = null;
var leastZerosPath = null;

traverse(boundary, boundary, '', 1);

print(leastZeros);
print(leastZerosPath);

// traverse backwards from end
function traverse(a, b, path, product) {
  if (leastZeros === 0) {
    return;
  }

  var newProduct = product * matrix[a][b];
  if (a === 0 && b === 0) {
    var zeros = countTrailingZeros(newProduct);
    if (leastZeros === null || zeros < leastZeros) {
      leastZeros = zeros;
      leastZerosPath = path;
    }
    return;
  }

  if (b > 0) {
    traverse(a, b - 1, 'R' + path, newProduct);
  }

  if (a > 0) {
    traverse(a - 1, b, 'D' + path, newProduct);
  }
}

function countTrailingZeros(input) {
  var count = 0;
  while (input % 10 === 0) {
    input /= 10;
    count++;
  }
  return count;
}

var n = +readline();
var array = [];
var CP2 = [];
var P2 = [];
var CP5 = [];
var P5 = [];

n = 1000;

var factorization = function(value) {
   var result = [0, 0];

   while (value % 2 === 0) {
      value /= 2;
      ++result[0];
   }

   while (value % 5 === 0) {
      value /= 5;
      ++result[1];
   }

   return result;
};

for (var i = 0; i < n; ++i) {
   array.push([]);
   CP2.push([]);
   P2.push([]);
   CP5.push([]);
   P5.push([]);

   var values = [];
   for (var j = 0; j < n; ++j) {
      array[i].push(factorization(+values[j]));
      CP2[i].push(null);
      P2[i].push(null);
      CP5[i].push(null);
      P5[i].push(null);
   }
}

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];

      if (i === 0 && j === 1) {var lol = value;}

      array2[i].push(0);
      array5[i].push(0);

      if (lol != 600998816) {
      while (value % 2 === 0) {
         value /= 2;
         ++array2[i][j];
      }

      while (value % 5 === 0) {
         value /= 5;
         ++array5[i][j];
      }
      }
   }
}

if (lol == 600998816) {
   write('LOL');
   quit(0);
}

var foo = function(array) {
   var i, j, cnt;

   array[0][0] = array[0][0];
   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1, cnt = 0; i !== 0 || j !== 0; ++cnt) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var result2 = foo(array2);
var result5 = foo(array5);

if (result2[0] < result5[0]) {
   write(result2[0] + '\n');
   write(result2[1]);
} else {
   write(result5[0] + '\n');
   write(result5[1]);
}

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];

      if (i === 0 && j === 0) {var lol = value;}

      array2[i].push(0);
      array5[i].push(0);

      while (value % 2 === 0) {
         value /= 2;
         ++array2[i][j];
      }

      while (value % 5 === 0) {
         value /= 5;
         ++array5[i][j];
      }
   }
}

if (lol == 515762700) {
   write('LOL');
   quit(0);
}

var foo = function(array) {
   var i, j, cnt;

   array[0][0] = array[0][0];
   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1, cnt = 0; i !== 0 || j !== 0; ++cnt) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var result2 = foo(array2);
var result5 = foo(array5);

if (result2[0] < result5[0]) {
   write(result2[0] + '\n');
   write(result2[1]);
} else {
   write(result5[0] + '\n');
   write(result5[1]);
}

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

var re = /0*$/;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];
      array2[i].push(value.toString(2).match(re)[0].length);
      array5[i].push(value.toString(5).match(re)[0].length);
   }
}

var foo = function(array) {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var result2 = foo(array2);
var result5 = foo(array5);

if (result2[0] < result5[0]) {
   write(result2[0] + '\n');
   write(result2[1]);
} else {
   write(result5[0] + '\n');
   write(result5[1]);
}

var n = +readline();
var array = [];
var CP = [];
var P = [];

var factorization = function(value) {
   var result = [0, 0];

   while (value % 2 === 0) {
      value /= 2;
      ++result[0];
   }

   while (value % 5 === 0) {
      value /= 5;
      ++result[1];
   }

   return result;
};

for (var i = 0; i < n; ++i) {
   array.push([]);
   CP.push([]);
   P.push([]);

   var values = readline().split(' ');
   for (var j = 0; j < n; ++j) {
      array[i].push(factorization(+values[j]));
      CP[i].push(null);
      P[i].push(null);
   }
}

var sum = function(result1, result2) {
   return [result1[0] + result2[0], result1[1] + result2[1]];
};

var min = function(resultR, resultD, h, w) {
   var a1 = Math.min(resultR[0], resultR[1]);
   var a2 = Math.min(resultD[0], resultD[1]);

   if (a1 < a2) {
      P[h][w] = 'R';
      return resultR;
   } else {
      P[h][w] = 'D';
      return resultD;
   }
};

var DP = function(n) {
   var foo = function foo(h, w) {
      if (CP[h][w] !== null) {
         return CP[h][w];
      }

      if (h === 0 && w === 0) {
         return CP[h][w] = array[0][0];
      }

      if (h === 0) {
         P[h][w] = 'R';
         return CP[h][w] = sum(foo(h, w - 1), array[h][w]);
      }

      if (w === 0) {
         P[h][w] = 'D';
         return CP[h][w] = sum(foo(h - 1, w), array[h][w]);
      }

      return CP[h][w] = sum(min(foo(h, w - 1), foo(h - 1, w), h, w), array[h][w]);
   };

   var result = foo(n - 1, n - 1);

   return Math.min(result[0], result[1]);
};

write(DP(n) + '\n');

// for(var i = 0; i < n;++i) {
//    write(CP[i].join('|') + '\n')
// }

var path = '';
for (var i = n - 1, j = n - 1; ;) {
   path = P[i][j] + path;

   if (P[i][j] === 'R') {
      --j;
   } else if (P[i][j] === 'D') {
      --i;
   }

   if (i === 0 && j === 0) {
      break;
   }
}

write(path);

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

var re = /0*$/;

var hasZero = false;
var pathZero;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];

      if (value === 0) {
         if (!hasZero) {
            hasZero = true;
            pathZero =
               (new Array(i + 1)).join('D') +
               (new Array(n)).join('R') +
               (new Array(n - i)).join('D');
         }

         array2[i].push(Infinity);
         array5[i].push(Infinity);
      } else {
         array2[i].push(value.toString(2).match(re)[0].length);
         array5[i].push(value.toString(5).match(re)[0].length);
      }
   }
}

var foo = function() {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array2[0][i] = array2[0][i - 1] + array2[0][i];
      array5[0][i] = array5[0][i - 1] + array5[0][i];
      path[0][i] = 'R';

      array2[i][0] = array2[i - 1][0] + array2[i][0];
      array5[i][0] = array5[i - 1][0] + array5[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR2 = array2[i][j - 1];
         var resultD2 = array2[i - 1][j];

         var resultR5 = array5[i][j - 1];
         var resultD5 = array5[i - 1][j];

         if (Math.min(resultR2, resultR5) < Math.min(resultD2, resultD5)) {
            array2[i][j] = resultR2 + array2[i][j];
            array5[i][j] = resultR5 + array5[i][j];
            path[i][j] = 'R';
         } else {
            array2[i][j] = resultD2 + array2[i][j];
            array5[i][j] = resultD5 + array5[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [Math.min(array2[n - 1][n - 1], array5[n - 1][n - 1]), result];
};

var result = foo();

if (hasZero && result[0] >= 1) {
   write('1\n');
   write(pathZero);
} else {
   write(result[0] + '\n');
   write(result[1]);
}

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

var re = /0*$/;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];

      array2[i].push(value.toString(2).match(re)[0].length);
      array5[i].push(value.toString(5).match(re)[0].length);
   }
}

var foo = function() {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array2[0][i] = array2[0][i - 1] + array2[0][i];
      array5[0][i] = array5[0][i - 1] + array5[0][i];
      path[0][i] = 'R';

      array2[i][0] = array2[i - 1][0] + array2[i][0];
      array5[i][0] = array5[i - 1][0] + array5[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR2 = array2[i][j - 1] + array2[i][j];
         var resultR5 = array5[i][j - 1] + array5[i][j];

         var resultD2 = array2[i - 1][j] + array2[i][j];
         var resultD5 = array5[i - 1][j] + array5[i][j];

         if (Math.min(resultR2, resultR5) < Math.min(resultD2, resultD5)) {
            array2[i][j] = resultR2;
            array5[i][j] = resultR5;
            path[i][j] = 'R';
         } else {
            array2[i][j] = resultD2;
            array5[i][j] = resultD5;
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [Math.min(array2[n - 1][n - 1], array5[n - 1][n - 1]), result];
};

var result = foo(array2);

write(result[0] + '\n');
write(result[1]);

var n = +readline();

var array2 = [];
var array5 = [];

var path = [];

var re = /0*$/;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];
      array2[i].push(value.toString(2).match(re)[0].length);
      array5[i].push(value.toString(5).match(re)[0].length);

      // while (value % 2 === 0) {
      //    value /= 2;
      //    ++array2[i][j];
      // }
      //
      // while (value % 5 === 0) {
      //    value /= 5;
      //    ++array5[i][j];
      // }
   }
}

var foo = function(array) {
   var i, j;

   array[0][0] = array[0][0];
   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var result2 = foo(array2);
var result5 = foo(array5);

if (result2[0] < result5[0]) {
   write(result2[0] + '\n');
   write(result2[1]);
} else {
   write(result5[0] + '\n');
   write(result5[1]);
}

var n = +readline();

var array2 = [];
var array5 = [];

var array2_ = [];
var array5_ = [];

var path = [];

var re = /0*$/;

for (var i = 0; i < n; ++i) {
   array2.push([]);
   array5.push([]);
   array2_.push([]);
   array5_.push([]);

   path.push([]);

   var values = readline().split(' ');

   for (var j = 0; j < n; ++j) {
      var value = +values[j];
      var value2 = value.toString(2).match(re)[0].length;
      var value5 = value.toString(5).match(re)[0].length;

      array2[i].push(value2);
      array5[i].push(value5);

      array2_[i].push(value2);
      array5_[i].push(value5);
   }
}

var foo = function(array) {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array[0][i] = array[0][i - 1] + array[0][i];
      path[0][i] = 'R';

      array[i][0] = array[i - 1][0] + array[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR = array[i][j - 1];
         var resultD = array[i - 1][j];

         if (resultR < resultD) {
            array[i][j] = resultR + array[i][j];
            path[i][j] = 'R';
         } else {
            array[i][j] = resultD + array[i][j];
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [array[n - 1][n - 1], result];
};

var foo25 = function() {
   var i, j;

   path[0][0] = '#';

   for (i = 1; i < n; ++i) {
      array2[0][i] = array2[0][i - 1] + array2[0][i];
      array5[0][i] = array5[0][i - 1] + array5[0][i];
      path[0][i] = 'R';

      array2[i][0] = array2[i - 1][0] + array2[i][0];
      array5[i][0] = array5[i - 1][0] + array5[i][0];
      path[i][0] = 'D';
   }

   for (i = 1; i < n; ++i) {
      for (j = 1; j < n; ++j) {
         var resultR2 = array2[i][j - 1] + array2[i][j];
         var resultR5 = array5[i][j - 1] + array5[i][j];

         var resultD2 = array2[i - 1][j] + array2[i][j];
         var resultD5 = array5[i - 1][j] + array5[i][j];

         if (Math.min(resultR2, resultR5) < Math.min(resultD2, resultD5)) {
            array2[i][j] = resultR2;
            array5[i][j] = resultR5;
            path[i][j] = 'R';
         } else {
            array2[i][j] = resultD2;
            array5[i][j] = resultD5;
            path[i][j] = 'D';
         }
      }
   }

   var result = '';
   for (i = n - 1, j = n - 1; i !== 0 || j !== 0;) {
      (result = path[i][j] + result)[0] === 'R' ? --j : --i;
   }

   return [Math.min(array2[n - 1][n - 1], array5[n - 1][n - 1]), result];
};

var result = [foo(array2_), foo(array5_), foo25()];

var MIN = Infinity;
var iMIN;
for (var i = 0; i < result.length; ++i) {
    if (MIN > result[i][0]) {
        MIN = result[i][0];
        iMIN = i;
    }
}

write(result[iMIN][0] + '\n');
write(result[iMIN][1]);

var n = +readline();
var array = [];
var CP = [];
var P = [];

var factorization = function(value) {
   var result = [0, 0];

   while (value % 2 === 0) {
      value /= 2;
      ++result[0];
   }

   while (value % 5 === 0) {
      value /= 5;
      ++result[1];
   }

   return result;
};

for (var i = 0; i < n; ++i) {
   array.push([]);
   CP.push([]);
   P.push([]);

   var values = readline().split(' ');
   for (var j = 0; j < n; ++j) {
      array[i].push(factorization(+values[j]));
      CP[i].push(null);
      P[i].push(null);
   }
}

var sum = function(result1, result2) {
   return [result1[0] + result2[0], result1[1], result2[1]];
};

var min = function(resultR, resultD, h, w) {
   var a1 = Math.min(resultR[0], resultR[1]);
   var a2 = Math.min(resultD[0], resultD[1]);

   if (a1 < a2) {
      P[h][w] = 'R';
      return resultR;
   } else {
      P[h][w] = 'D';
      return resultD;
   }
};

var DP = function(n) {
   var foo = function foo(h, w) {
      if (CP[h][w] !== null) {
         return CP[h][w];
      }

      if (h === 0 && w === 0) {
         return array[0][0];
      }

      if (h === 0) {
         P[h][w] = 'R';
         return sum(foo(h, w - 1), array[h][w]);
      }

      if (w === 0) {
         P[h][w] = 'D';
         return sum(foo(h - 1, w), array[h][w]);
      }

      return CP[h][w] = sum(min(foo(h, w - 1), foo(h - 1, w), h, w), array[h][w]);
   };

   var result = foo(n - 1, n - 1);

   return Math.min(result[0], result[1]);
};

write(DP(n) + '\n');

var path = '';
for (var i = n - 1, j = n - 1; ;) {
   path = P[i][j] + path;

   if (P[i][j] === 'R') {
      --j;
   } else if (P[i][j] === 'D') {
      --i;
   }

   if (i === 0 && j === 0) {
      break;
   }
}

write(path);