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 n×nn\times n, and the corresponding position of the right half of the door also has the same n×nn\times n numbers, but the numbers are all 00. These 00s 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 n×nn\times n matrix is ​​AA, and the changed right n×nn\times n matrix is BB, this rule is that the product matrix CC of matrix A,BA, B satisfies Ci,j=k=1nai,k×bk,jC_{i,j}=\sum_{k=1}^n a_{i,k}\times b_{k,j}, and C=A×B=EnC=A\times B=E_n​.

Among them, EnE_n​ is:

  • If i=ji=j, Ei,j=1E_{i,j}=1;
  • Otherwise, Ei,j=0E_{i,j}=0.

Namely, BB is the inverse matrix of AA.

Can you help Coco open this door?

Input Format

The first line of the input file contains an integer nn.

In the next nn lines, each line contains nn numbers, and each element of AA is given in row major order, namely:

A1,1,A1,2,,A1,n,A_{1,1}, A_{1,2},\dots ,A_{1,n},

A2,1,A2,2,,A2,n,A_{2,1}, A_{2,2},\dots ,A_{2,n},

\dots

An,1,An,2,,An,nA_{n,1}, A_{n,2}, \dots,A_{n,n}

Output Format

The output file contains nn lines: each line has nn integers, and it is between 2×109-2\times 10^9 and 2×1092\times 10^9, every two adjacent numbers separated by a space; that is, the matrix BB expressed in the row major order.

The input data ensures that this matrix BB exists, each element of BB is an integer, and it is between 2×109-2\times 10^9 and 2×1092\times 10^9.

Special note: Because the test adopts the file comparison method, if a number in the result is 00, 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 100%100\% data, 1n2001\le n\le 200, 2×109Ai,j,Bi,j2×109-2\times 10^9 \le A_{i,j},B_{i,j}\le 2\times 10^9.