Triangle Tiling
시간 제한5초메모리 제한1024 MB
변 길이 n인 삼각 격자에서 위쪽 삼각형 n개를 제거한 뒤, 남은 영역을 단위 마름모로 채울 수 있는지 판정하고 한 가지 타일링을 출력한다.
문제
Chiaki has an equilateral triangle with side length . She would like to tile the triangle using unit rhombi with angles equal to and .

An equilateral triangle with side length , Three types of rhombus numbered from to from left to right.
Chiaki soon figures out it's an impossible task. So she cuts out exactly 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 .

입력
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:
The first line contains an integer () -- the side length of the equilateral triangle.
The -th line the following lines contains a binary string with length , where means the -th upward triangle was cut out.
It is guaranteed that the sum of over all test cases does not exceed .
출력
For each test case, output a valid tiling. A valid tiling consists of lines and the -th line contains characters. The -th character should be:
- '-': if the -th upward triangle was cut out.
- '1': if the -th upward triangle was coverd by the first type rhombus.
- '2': if the -th upward triangle was coverd by the second type rhombus.
- '3': if the -th upward triangle was coverd by the third type rhombus.
If there is no solution, output "Impossible!" (without the quotes) instead.