{"raw_statement":[{"iden":"problem statement","content":"There is a grid with $H$ rows and $W$ columns. Initially, all cells are painted with color $0$.\nYou will perform the following operations in the order $i = 1, 2, \\ldots, M$.\n\n*   If $T_i = 1$, repaint all cells in the $A_i$\\-th **row** with color $X_i$.\n    \n*   If $T_i = 2$, repaint all cells in the $A_i$\\-th **column** with color $X_i$.\n    \n\nAfter all operations are completed, for each color $i$ that exists on the grid, find the number of cells that are painted with color $i$."},{"iden":"constraints","content":"*   $1 \\leq H, W, M \\leq 2 \\times 10^5$\n*   $T_i \\in \\lbrace 1, 2 \\rbrace$\n*   $1 \\leq A_i \\leq H$ for each $i$ such that $T_i = 1$,\n*   $1 \\leq A_i \\leq W$ for each $i$ such that $T_i = 2$.\n*   $0 \\leq X_i \\leq 2 \\times 10^5$\n*   All input values are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$H$ $W$ $M$\n$T_1$ $A_1$ $X_1$\n$T_2$ $A_2$ $X_2$\n$\\vdots$\n$T_M$ $A_M$ $X_M$"},{"iden":"sample input 1","content":"3 4 4\n1 2 5\n2 4 0\n1 3 3\n1 3 2"},{"iden":"sample output 1","content":"3\n0 5\n2 4\n5 3\n\nThe operations will change the colors of the cells in the grid as follows:\n\n0000   0000   0000   0000   0000\n0000 → 5555 → 5550 → 5550 → 5550 \n0000   0000   0000   3333   2222\n\nEventually, there are five cells painted with color $0$, four with color $2$, and three with color $5$."},{"iden":"sample input 2","content":"1 1 5\n1 1 1\n1 1 10\n2 1 100\n1 1 1000\n2 1 10000"},{"iden":"sample output 2","content":"1\n10000 1"},{"iden":"sample input 3","content":"5 5 10\n1 1 1\n1 2 2\n1 3 3\n1 4 4\n1 5 5\n2 1 6\n2 2 7\n2 3 8\n2 4 9\n2 5 10"},{"iden":"sample output 3","content":"5\n6 5\n7 5\n8 5\n9 5\n10 5"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}