Higher Math Lesson

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

문제

Henry is sleeping at a boring higher math lesson in National Search University of This and That. When he suddenly wakes up the teacher asks him to solve the following problem. Given an n×nn \times n matrix AA of integers Henry must find invertible integer matrices LL and RR such that the following conditions are satisfied:

  • B=LARB = LAR is a diagonal matrix;
  • there is such jj (0jn0 \le j \le n) that b_i,i=0b\_{i,i}=0 if and only if i>ji > j;
  • for all ii from 2 to jj the number b_i,ib\_{i,i} is divisible by b_i1,i1b\_{i-1,i-1}.

An integer matrix CC is called invertible if there exist an integer matrix C1C^{-1} such that CC1=ICC^{-1}=I where II is a unit matrix.

Henry has been sleeping for most of lessons, so he doesn't know how to do it. So he asks you to help.

입력

The input file contains multiple test cases.

Each test case starts with an integer nn --- size of a matrix, followed by nn lines of nn integers each --- the given matrix (2n52 \le n \le 5, elements of matrices are from 10-10 to 1010).

Input is followed by a line with n=0n = 0. Each input file contains at most 100 test cases.

출력

For each test case print four integer matrices: LL, L1L^{-1}, RR and R1R^{-1}. It is guaranteed that such matrices always exist. Separate matrices by a blank line. If there are several solutions, print any one.