시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 512 MB1000.000%

문제

Consider a binary operation ◦ defined on numbers 1 through n:

◦ : {1, . . . , n} × {1, . . . , n} → {1, . . . , n}.

Let us define its associativity degree as the number of triplets i, j, k ∈ {1, . . . , n} for which ◦ is associative:

i ◦ (j ◦ k) = (i ◦ j) ◦ k.

Your task is, given n and k, to construct an operation ◦ such that its associativity degree is exactly k.

입력

The first line of input contains two integers n and q (1 ≤ n ≤ 64, 1 ≤ q · n2 ≤ 106).

The i-th of the next q lines contains a single integer ki (0 ≤ ki ≤ n3).

It is guaranteed that all ki are distinct.

출력

For each given value of ki, do the following:

If there is no operation ◦ with associativity degree ki for given n, output “NO” on a single line.

Otherwise, output “YES” on the first line, followed by n lines containing n integers each. The j-th integer in the i-th line must be equal to i ◦ j.

예제 입력 1

3 1
27

예제 출력 1

YES
1 1 1
1 2 3
1 3 2

예제 입력 2

1 2
0
1

예제 출력 2

NO
YES
1

노트

The operation from the first sample can be concisely described as i ◦ j = 1 + ((i − 1) · (j − 1)) mod 3, and it is fully associative.