{"problem":{"name":"Simplified Reversi","description":{"content":"There is a grid with $N$ rows and $N$ columns of squares. Let $(i, j)$ be the square at the $i$\\-th row from the top and the $j$\\-th column from the left. Each of the central $(N-2) \\times (N-2)$ squa","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc179_f"},"statements":[{"statement_type":"Markdown","content":"There is a grid with $N$ rows and $N$ columns of squares. Let $(i, j)$ be the square at the $i$\\-th row from the top and the $j$\\-th column from the left.\nEach of the central $(N-2) \\times (N-2)$ squares in the grid has a black stone on it. Each of the $2N - 1$ squares on the bottom side and the right side has a white stone on it.\n$Q$ queries are given. We ask you to process them in order. There are two kinds of queries. Their input format and description are as follows:\n\n*   `1 x`: Place a white stone on $(1, x)$. After that, for each black stone between $(1, x)$ and the first white stone you hit if you go down from $(1, x)$, replace it with a white stone.\n*   `2 x`: Place a white stone on $(x, 1)$. After that, for each black stone between $(x, 1)$ and the first white stone you hit if you go right from $(x, 1)$, replace it with a white stone.\n\nHow many black stones are there on the grid after processing all $Q$ queries?\n\n## Constraints\n\n*   $3 \\leq N \\leq 2\\times 10^5$\n*   $0 \\leq Q \\leq \\min(2N-4,2\\times 10^5)$\n*   $2 \\leq x \\leq N-1$\n*   Queries are pairwise distinct.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $Q$\n$Query_1$\n$\\vdots$\n$Query_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc179_f","tags":[],"sample_group":[["5 5\n1 3\n2 3\n1 4\n2 2\n1 2","1\n\nAfter each query, the grid changes in the following way:\n![image](https://img.atcoder.jp/ghi/31ba2cd6b3155b137f0e007299225028.png)"],["200000 0","39999200004"],["176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282","31159505795"]],"created_at":"2026-03-03 11:01:14"}}