{"raw_statement":[{"iden":"problem statement","content":"We have a grid with $N$ rows and $M$ columns of squares. Each integer from $1$ to $NM$ is written in this grid once. The number written in the square at the $i$\\-th row from the top and the $j$\\-th column from the left is $A_{ij}$.\nYou need to rearrange these numbers as follows:\n\n1.  First, for each of the $N$ rows, rearrange the numbers written in it as you like.\n2.  Second, for each of the $M$ columns, rearrange the numbers written in it as you like.\n3.  Finally, for each of the $N$ rows, rearrange the numbers written in it as you like.\n\nAfter rearranging the numbers, you want the number written in the square at the $i$\\-th row from the top and the $j$\\-th column from the left to be $M\\times (i-1)+j$. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective."},{"iden":"constraints","content":"*   $1 \\leq N,M \\leq 100$\n*   $1 \\leq A_{ij} \\leq NM$\n*   $A_{ij}$ are distinct."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$A_{11}$ $A_{12}$ $...$ $A_{1M}$\n$:$\n$A_{N1}$ $A_{N2}$ $...$ $A_{NM}$"},{"iden":"sample input 1","content":"3 2\n2 6\n4 3\n1 5"},{"iden":"sample output 1","content":"2 6 \n4 3 \n5 1 \n2 1 \n4 3 \n5 6"},{"iden":"sample input 2","content":"3 4\n1 4 7 10\n2 5 8 11\n3 6 9 12"},{"iden":"sample output 2","content":"1 4 7 10 \n5 8 11 2 \n9 12 3 6 \n1 4 3 2 \n5 8 7 6 \n9 12 11 10"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}