Matrices and Determinants

시간 제한1초메모리 제한2048 MB

요약
작은 정수 행렬 A마다 행렬식이 0이 아니고 서로 같은 두 행렬 B, C의 곱으로 나타낼 수 있는지 판정하고, 가능하면 그러한 B와 C를 출력한다.
난이도

어려움10점 중 8점

유형
수학, 정수론, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

Given an n×nn \times n integer matrix AA, you should find two n×nn \times n integer matrices BB and CC such that B⋅C=AB \cdot C = A and det(B)=det(C)≠0\mathrm{det}(B) = \mathrm{det}(C) \neq 0. There may exist multiple solutions or no solution.

Note: det(M)\mathrm{det}(M) denotes the determinant of matrix MM.

입력

The first line contains one integer TT (1≤T≤10,0001 \le T \le 10\\,000) denoting the number of test cases. For each test case:

The first line contains one integer nn (1≤n≤41 \le n \le 4) denoting the size of the given matrix.

In the following nn lines, the ii-th line contains nn integers A_i,jA\_{i,j} (∣A_i,j∣≤10|A\_{i,j}| \le 10 for 1≤j≤n1 \le j \le n) denoting the given matrix.

출력

For each test case:

The first line must contain one string "Yes" (without quotes) if a solution exists, or "No" (without quotes) if there is no solution. If a solution exists:

Each of the following nn lines contains nn integers B_i,jB\_{i,j} (∣B_i,j∣≤1018|B\_{i,j}| \le 10^{18}) denoting the matrix BB.

Each of the following nn lines contains nn integers C_i,jC\_{i,j} (∣C_i,j∣≤1018|C\_{i,j}| \le 10^{18}) denoting the matrix CC.

If multiple solutions exist, print any one of them.

예제1

  1. 예제 1

    입력
    3
    2
    2 0
    0 2
    2
    2 1
    1 2
    1
    1
    
    예상 출력
    Yes
    2 0
    0 1
    1 0
    0 2
    No
    Yes
    -1
    -1