{"problem":{"name":"Rearranging","description":{"content":"There is a grid with $N$ rows and $M$ columns. The square at the $i$\\-th row from the top and the $j$\\-th column from the left contains the integer $A_{i,j}$.   Here, the squares contain $M$ occurrenc","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc317_g"},"statements":[{"statement_type":"Markdown","content":"There is a grid with $N$ rows and $M$ columns. The square at the $i$\\-th row from the top and the $j$\\-th column from the left contains the integer $A_{i,j}$.  \nHere, the squares contain $M$ occurrences of each of $1,\\ldots,N$, for a total of $NM$ integers.\nYou perform the following operations to swap the numbers written on the squares.\n\n*   For $i=1,\\ldots,N$ in this order, do the following.\n    *   Freely rearrange the numbers written in the $i$\\-th row. That is, freely choose a permutation $P=(P_{1},\\ldots,P_{M})$ of $1,\\ldots,M$, and replace $A_{i,1},\\ldots,A_{i,M}$ with $A_{i,P_{1}},\\ldots,A_{i,P_{M}}$ simultaneously.\n\nYour goal is to perform the operations so that each column contains each of $1,\\ldots,N$ once. Determine if this is possible, and if so, print such a resulting grid.\n\n## Constraints\n\n*   $1 \\leq N,M \\leq 100$\n*   $1 \\leq A_{i,j} \\leq N$\n*   All input values are integers.\n*   The $NM$ numbers $A_{1,1},\\ldots,A_{N,M}$ contain exactly $M$ occurrences of each of $1,\\ldots,N$.\n\n## Input\n\nThe Input is given from Standard Input in the following format:\n\n$N$ $M$\n$A_{1,1}$ $\\ldots$ $A_{1,M}$\n$\\vdots$\n$A_{N,1}$ $\\ldots$ $A_{N,M}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc317_g","tags":[],"sample_group":[["3 2\n1 1\n2 3\n2 3","Yes\n1 1\n3 2\n2 3\n\nAlso, the following output is accepted.\n\nYes\n1 1\n2 3\n3 2"],["4 4\n1 2 3 4\n1 1 1 2\n3 2 2 4\n4 4 3 3","Yes\n1 4 3 2\n2 1 1 1\n4 2 2 3\n3 3 4 4"]],"created_at":"2026-03-03 11:01:14"}}