ccf#AHOI2007B. 宫殿大门 (Palace Gates)
宫殿大门 (Palace Gates)
Description
The password box was finally opened, and lying inside was an ancient treasure map. A treasure left by an ancient monarch, it was hidden in an underground palace, undiscovered so far. To obtain the treasure, you must crack numerous mechanisms. Xiao Keke is not afraid. As his good friends, you just started the treasure hunt. After overcoming all hardships, you came to the entrance of the underground palace and encountered your first trouble. The gate of the palace could not be opened. After careful observation, Xiao Keke discovered that there are some numbers on the left half of the door, arranged like a matrix of dimensions , and the corresponding position of the right half of the door also has the same numbers, but the numbers are all . These s can be changed into other numbers, even negative numbers, but the arrangement method will not change.
Little Coco carefully studied the treasure map and found that to open this door, the numbers on the right half of the door must be changed according to a certain rule. If assuming that the left matrix is , and the changed right matrix is , this rule is that the product matrix of matrix satisfies , and .
Among them, is:
- If , ;
- Otherwise, .
Namely, is the inverse matrix of .
Can you help Coco open this door?
Input Format
The first line of the input file contains an integer .
In the next lines, each line contains numbers, and each element of is given in row major order, namely:
Output Format
The output file contains lines: each line has integers, and it is between and , every two adjacent numbers separated by a space; that is, the matrix expressed in the row major order.
The input data ensures that this matrix exists, each element of is an integer, and it is between and .
Special note: Because the test adopts the file comparison method, if a number in the result is , the program should output 0
instead of -0
.
3
1 -1 1
0 1 2
1 0 4
4 4 -3
2 3 -2
-1 -1 1
Constraints
For data, , .