{"problem":{"name":"Paint","description":{"content":"There is a grid with $H$ rows and $W$ columns. Initially, all cells are painted with color $0$. You will perform the following operations in the order $i = 1, 2, \\ldots, M$. *   If $T_i = 1$, repaint","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc346_e"},"statements":[{"statement_type":"Markdown","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$.\n\n## Constraints\n\n*   $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.\n\n## Input\n\nThe 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$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc346_e","tags":[],"sample_group":[["3 4 4\n1 2 5\n2 4 0\n1 3 3\n1 3 2","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$."],["1 1 5\n1 1 1\n1 1 10\n2 1 100\n1 1 1000\n2 1 10000","1\n10000 1"],["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","5\n6 5\n7 5\n8 5\n9 5\n10 5"]],"created_at":"2026-03-03 11:01:14"}}