La omul care mi-i drag
Treabă n-am dar cale-mi fac
Iar la cel ce mi-i urât
Treabă am dar nu mă duc
You are given an n×n grid of nonzero digits. The value of the c-th cell from the r-th row is known to be arc. Note that 1≤arc≤9.
A DR-path is a sequence of cells (r1,c1),(r2,c2),…,(rk,ck) which satisfies the following constraints:
- (r1,c1)=(1,1)
- (rk,ck)=(n,n)
- For all 1≤i<k, (ri+1,ci+1)=(ri+1,ci) or (ri+1,ci+1)=(ri,ci+1).
The value of a DR-path (r1,c1),(r2,c2),…,(rk,ck) is equal to:
φ(ar1c1⋅ar2c2⋅…⋅arkck)where φ(x) denotes the number of integers 1≤y≤x for which gcd(x,y)=1. Note that, based on this definition, φ(1)=1.
Task
Find any DR-path (r1,c1),(r2,c2),…,(rk,ck) with the maximum value. For that DR-path you will have to print a string s of length k−1 which is defined in the following way:
si={D,R,if (ri+1,ci+1)=(ri+1,ci)otherwise
Each test contains multiple test cases. The first line of input contains a single integer t — the number of test cases.
The first line of each test case contains a single integer n — the size of the grid.
Each of the next n lines of input contains a string of n digits. The i-th of these lines will contain the string ai1ai2…ain.
Output data
For each test case, print a string of D's and R's corresponding to any DR-path with the maximum value.
Constraints and clarifications
- 1≤t≤105
- 2≤n≤1 000
- 1≤aij≤9
- The sum of n2 across all test cases does not exceed 106.
Example
stdin
4
3
188
956
671
2
12
21
2
69
76
4
9667
7181
5934
7522
stdout
DRDR
DR
RD
RRDDRD
In the first test case, the DR-path (1,1),(2,1),(2,2),(3,2),(3,3) has a value of φ(1⋅9⋅5⋅7⋅1)=144. We can show that no other DR-paths have a higher value.
In the second test case, all DR-paths have a value of φ(2)=1.
In the third test case, the DR-path (1,1),(1,2),(2,2) has a value of φ(6⋅9⋅6)=108. We can show that no other DR-paths have a higher value.