{"raw_statement":[{"iden":"problem statement","content":"We have $HW$ cards arranged in a matrix with $H$ rows and $W$ columns.  \nFor each $i=1, \\ldots, N$, the card at the $A_i$\\-th row from the top and $B_i$\\-th column from the left has a number $i$ written on it. The other $HW-N$ cards have nothing written on them.\nWe will repeat the following two kinds of operations on these cards as long as we can.\n\n*   If there is a row without a numbered card, remove all the cards in that row and fill the gap by shifting the remaining cards upward.\n*   If there is a column without a numbered card, remove all the cards in that column and fill the gap by shifting the remaining cards to the left.\n\nFind the position of each numbered card after the end of the process above. It can be proved that these positions are uniquely determined without depending on the order in which the operations are done."},{"iden":"constraints","content":"*   $1 \\leq H,W \\leq 10^9$\n*   $1 \\leq N \\leq \\min(10^5,HW)$\n*   $1 \\leq A_i \\leq H$\n*   $1 \\leq B_i \\leq W$\n*   All pairs $(A_i,B_i)$ are distinct.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$H$ $W$ $N$\n$A_1$ $B_1$\n$\\vdots$\n$A_N$ $B_N$"},{"iden":"sample input 1","content":"4 5 2\n3 2\n2 5"},{"iden":"sample output 1","content":"2 1\n1 2\n\nLet `*` represent a card with nothing written on it. The initial arrangement of cards is:\n\n*****\n****2\n*1***\n*****\n\nAfter the end of the process, they will be arranged as follows:\n\n*2\n1*\n\nHere, the card with $1$ is at the $2$\\-nd row from the top and $1$\\-st column from the left, and the card with $2$ is at the $1$\\-st row from the top and $2$\\-nd column from the left."},{"iden":"sample input 2","content":"1000000000 1000000000 10\n1 1\n10 10\n100 100\n1000 1000\n10000 10000\n100000 100000\n1000000 1000000\n10000000 10000000\n100000000 100000000\n1000000000 1000000000"},{"iden":"sample output 2","content":"1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n10 10"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}