After many sleepless nights trying to beat Limbo on Geometry Dash, you finally gave in and fell asleep in your chair. In your astral journey, you found keys arranged in the form of a matrix with rows and columns. We denote with the key at row and column . The matrix is indexed from . Each key has an associated color. The colors of the keys are distinct.
The following operations can be performed on this assembly of keys:
X0
- swap with ; with ; with ; with ;X1
- swap with ; with ; with ; with ;Ol
- ; ; ; ; ; ; ; rotate circularly to the left;Or
- ; ; ; ; ; ; ; rotate circularly to the right;ol
- ; ; ; and ; ; ; rotate circularly to the left;or
- ; ; ; and ; ; ; rotate circularly to the right;S
- swap with ; with ; with ; with ;R
- rotate the matrix by degrees.
Task
Only one of these keys is the correct one. For simplicity, we will consider that the correct key is always initially located at . You are bored and apply exactly random operations. After you finish applying the operations, display for each position in the matrix the probability in the form that the correct key will be at after the operations, modulo .
Constraints and clarifications:
- For of the tests:
- For of the tests:
- It can be proven that all probabilities can be represented as an irreductible fraction of the form .
Example 1:
stdin
0
stdout
1 0
0 0
0 0
0 0
Explanation
No operations are performed. The correct key remains in cell ().
Example 2:
stdin
1
stdout
0 250000002
250000002 125000001
125000001 0
0 250000002
Explanation:
There are exactly possible sequences of moves.
For , there is no sequence of move after which the correct key is in cell .
For , there are sequences of move after which the correct key is in cell : Or
and or
.
For , there are sequences of move after which the correct key is in cell : Ol
and ol
.
For , there is sequence of move after which the correct key is in cell : X0
.
For , there is sequence of move after which the correct key is in cell : S
.
For , there is no sequence of move after which the correct key is in cell .
For , there is no sequence of move after which the correct key is in cell .
For , there are sequences of move after which the correct key is in cell : R
and X1
.
Example 3:
stdin
26
stdout
265464296 292931484
340193730 718335589
531664420 909806279
957068525 984535713
Explanation:
In the Limbo level from Geometry Dash, exactly random moves are applied each time.
Example 4:
stdin
69420
stdout
595491153 534885681
436356732 994853266
255146743 813643277
715114328 654508856