{"raw_statement":[{"iden":"statement","content":"Consider a binary operation $compose$ defined on numbers $1$ through $n$: $$\\circ : \\{1,\\dots,n\\} \\times \\{1,\\dots,n\\} \\to \\{1,\\dots,n\\}\\text{.}$$\n\nLet us define its _associativity degree_ as the number of triplets $i, j, k in {1, \\\\dots, n}$ for which $compose$ is associative: $$i \\circ (j \\circ k) = (i \\circ j) \\circ k\\text{.}$$\n\nYour task is, given $n$ and $k$, to construct an operation $compose$ such that its associativity degree is exactly $k$.\n\nThe first line of input contains two integers $n$ and $q$ ($1 <= n <= 64$, $1 <= q dot.op n^2 <= 10^6$).\n\nThe $i$-th of the next $q$ lines contains a single integer $k_i$ ($0 <= k_i <= n^3$). \n\nIt is guaranteed that all $k_i$ are distinct.\n\nFor each given value of $k_i$, do the following:\n\nIf there is no operation $compose$ with associativity degree $k_i$ for given $n$, output \"_NO_\" on a single line.\n\nOtherwise, 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 compose j$.\n\nThe operation from the first sample can be concisely described as $i compose j = 1 + ((i -1) dot.op (j -1)) bmod 3$, and it is fully associative.\n\n"},{"iden":"input","content":"The first line of input contains two integers $n$ and $q$ ($1 <= n <= 64$, $1 <= q dot.op n^2 <= 10^6$).The $i$-th of the next $q$ lines contains a single integer $k_i$ ($0 <= k_i <= n^3$). It is guaranteed that all $k_i$ are distinct."},{"iden":"output","content":"For each given value of $k_i$, do the following:If there is no operation $compose$ with associativity degree $k_i$ 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 compose j$."},{"iden":"examples","content":"Input3 1\n27\nOutputYES\n1 1 1\n1 2 3\n1 3 2\nInput1 2\n0\n1\nOutputNO\nYES\n1\n"},{"iden":"note","content":"The operation from the first sample can be concisely described as $i compose j = 1 + ((i -1) dot.op (j -1)) bmod 3$, and it is fully associative."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $, $ n \\leq 64 $.  \nLet $ \\circ : \\{1,\\dots,n\\} \\times \\{1,\\dots,n\\} \\to \\{1,\\dots,n\\} $ be a binary operation.  \nThe *associativity degree* of $ \\circ $ is:  \n$$\n\\left| \\left\\{ (i,j,k) \\in \\{1,\\dots,n\\}^3 \\mid i \\circ (j \\circ k) = (i \\circ j) \\circ k \\right\\} \\right|\n$$\n\n**Given**  \nFor each query $ k_i \\in \\mathbb{Z} $, $ 0 \\leq k_i \\leq n^3 $, determine if there exists an operation $ \\circ $ with associativity degree exactly $ k_i $.\n\n**Objective**  \nFor each $ k_i $:  \n- If no such $ \\circ $ exists, output \"NO\".  \n- Otherwise, output \"YES\" followed by an $ n \\times n $ matrix $ M $, where $ M[i][j] = i \\circ j $.","simple_statement":"Given n and q queries, for each query k, construct a binary operation on {1,...,n} such that exactly k triplets (i,j,k) satisfy i∘(j∘k) = (i∘j)∘k. If impossible, output \"NO\". Otherwise, output \"YES\" and the n×n operation table.","has_page_source":false}