Triangle Tiling

아직 제출이 없습니다시간 제한5초메모리 제한1024 MB

문제

Chiaki has an equilateral triangle with side length nn. She would like to tile the triangle using unit rhombi with angles equal to 6060^\circand 120120^\circ.

An equilateral triangle with side length 44, Three types of rhombus numbered from 11 to 33 from left to right.

Chiaki soon figures out it's an impossible task. So she cuts out exactly nn of the upward triangles from the equilateral triangle. Now, Chiaki would like to know whether it is possible to tile the remaining shape with rhombi. The figure below is an example tiling for n=4n=4.

입력

There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains an integer nn (1n50001 \le n \le 5000) -- the side length of the equilateral triangle.

The ii-th line the following nn lines contains a binary string ss with length ii, where s_j=0s\_j=0 means the jj-th upward triangle was cut out.

It is guaranteed that the sum of nn over all test cases does not exceed 50005000.

출력

For each test case,  output a valid tiling. A valid tiling consists of nn lines and the ii-th line contains ii characters. The jj-th character should be:

  • '-': if the jj-th upward triangle was cut out.
  • '1': if the jj-th upward triangle was coverd by the first type rhombus.
  • '2': if the jj-th upward triangle was coverd by the second type rhombus.
  • '3': if the jj-th upward triangle was coverd by the third type rhombus.

If there is no solution, output "Impossible!" (without the quotes) instead.