English
Desc
There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that
- starts in the upper left cell of the matrix;
- each following cell is to the right or down from the current cell;
- the way ends in the bottom right cell.
Moreover, if we multiply together all the numbers along the way, the result should be the least “round”. In other words, it should end in the least possible number of zeros.
Input
The first line contains an integer number n (2 ≤ n ≤ 1000), n is the size of the matrix. Then follow n lines containing the matrix elements (non-negative integer numbers not exceeding 109).
Output
In the first line print the least number of trailing zeros. In the second line print the correspondent way itself.
Examples
input
3
1 2 3
4 5 6
7 8 9
output
0
DDRR
中文
简介
存在由非负整数组成的正方形矩阵n × n。你应该找到这样的一条路将所有数连起来,求积。
- 开始于左上方;
- 每个数从左边或者下边来链接下一个数;
- 结束于右下角。
此外,如果我们将所有数字相乘,积的结尾有最少的零。
输入格式
第一行包含的整数n(2 ≤ n ≤ 1000),n是矩阵的大小。然后按照包含矩阵元素的n行(非负整数不超过 109 )。
输出格式
在第一行打印最少数量的尾随零。在第二行则输出路径(由D和R组成,分别代表下和右)。
测试用例
测试输入
3
1 2 3
4 5 6
7 8 9
测试输出
0
DDRR