#abc276h. [abc276_h]Construct a Matrix

[abc276_h]Construct a Matrix

Problem Statement

Determine whether there is an NN-by-NN matrix XX that satisfies the following conditions, and present one such matrix if it exists. (Let xi,jx_{i,j} denote the element of XX at the ii-th row from the top and jj-th column from the left.)

  • xi,jin0,1,2x_{i,j} \\in \\{ 0,1,2 \\} for every ii and jj (1leqi,jleqN)(1 \\leq i,j \\leq N).
  • The following holds for each i=1,2,ldots,Qi=1,2,\\ldots,Q.
    • Let $P = \\prod_{a_i \\leq j \\leq b_i} \\prod_{c_i \\leq k \\leq d_i} x_{j,k}$. Then, PP is congruent to eie_i modulo 33.

Constraints

  • 1leqN,Qleq20001 \\leq N,Q \\leq 2000
  • 1leqaileqbileqN1 \\leq a_i \\leq b_i \\leq N
  • 1leqcileqdileqN1 \\leq c_i \\leq d_i \\leq N
  • eiin0,1,2e_i \\in \\{0,1,2 \\}
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN QQ a1a_1 b1b_1 c1c_1 d1d_1 e1e_1 vdots\\vdots aQa_Q bQb_Q cQc_Q dQd_Q eQe_Q

Output

If no matrix XX satisfies the conditions, print No.

If there is a matrix XX that satisfies them, print Yes in the first line and one such instance of XX in the following format in the second and subsequent lines.

x1,1x_{1,1} x1,2x_{1,2} ldots\\ldots x1,Nx_{1,N} x2,1x_{2,1} x2,2x_{2,2} ldots\\ldots x2,Nx_{2,N} vdots\\vdots xN,1x_{N,1} xN,2x_{N,2} ldots\\ldots xN,Nx_{N,N}

If multiple matrices satisfy the conditions, any of them will be accepted.


Sample Input 1

2 3
1 1 1 2 0
1 2 2 2 1
2 2 1 2 2

Sample Output 1

Yes
0 2
1 2

For example, for i=2i=2, we have $P = \\prod_{a_2 \\leq j \\leq b_2} \\prod_{c_2 \\leq k \\leq d_2} x_{j,k}= \\prod_{1 \\leq j \\leq 2} \\prod_{2 \\leq k \\leq 2} x_{j,k}=x_{1,2} \\times x_{2,2}$.
In this sample output, we have x1,2=2x_{1,2}=2 and x2,2=2x_{2,2}=2, so P=2times2=4P=2 \\times 2 = 4, which is congruent to e2=1e_2=1 modulo 33.
It can be similarly verified that the condition is also satisfied for i=1i=1 and i=3i=3.


Sample Input 2

4 4
1 4 1 4 0
1 4 1 4 1
1 4 1 4 2
1 4 1 4 0

Sample Output 2

No