{"problem":{"name":"Scalene Triangle Area","description":{"content":"We have an $N \\times N$ grid. The square at the $i$\\-th row from the top and $j$\\-th column from the left in this grid is called $(i,j)$.   Each square of the grid has at most one piece.   The state o","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc260_g"},"statements":[{"statement_type":"Markdown","content":"We have an $N \\times N$ grid. The square at the $i$\\-th row from the top and $j$\\-th column from the left in this grid is called $(i,j)$.  \nEach square of the grid has at most one piece.  \nThe state of the grid is given by $N$ strings $S_i$:\n\n*   if the $j$\\-th character of $S_i$ is `O`, then $(i,j)$ has a piece on it;\n*   if the $j$\\-th character of $S_i$ is `X`, then $(i,j)$ has no piece on it.\n\nYou are given an integer $M$. Using this $M$, we define that a piece $P$ placed at $(s,t)$ covers a square $(u,v)$ if all of the following conditions are satisfied:\n\n*   $s \\le u \\le N$\n*   $t \\le v \\le N$\n*   $(u - s) + \\frac{(v - t)}{2} < M$\n\nFor each of $Q$ squares $(X_i,Y_i)$, find how many pieces cover the square.\n\n## Constraints\n\n*   $N$, $M$, $X_i$, $Y_i$, and $Q$ are integers.\n*   $1 \\le N \\le 2000$\n*   $1 \\le M \\le 2 \\times N$\n*   $S_i$ consists of `O` and `X`.\n*   $1 \\le Q \\le 2 \\times 10^5$\n*   $1 \\le X_i,Y_i \\le N$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$\n$S_1$\n$S_2$\n$\\vdots$\n$S_N$\n$Q$\n$X_1$ $Y_1$\n$X_2$ $Y_2$\n$\\vdots$\n$X_Q$ $Y_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc260_g","tags":[],"sample_group":[["4 2\nOXXX\nXXXX\nXXXX\nXXXX\n6\n1 1\n1 4\n2 2\n2 3\n3 1\n4 4","1\n1\n1\n0\n0\n0\n\nOnly Square $(1,1)$ contains a piece, which covers the following `#` squares:\n\n####\n##..\n....\n...."],["5 10\nOOOOO\nOOOOO\nOOOOO\nOOOOO\nOOOOO\n5\n1 1\n2 3\n3 4\n4 2\n5 5","1\n6\n12\n8\n25"],["8 5\nOXXOXXOX\nXOXXOXOX\nXOOXOOXO\nOXOOXOXO\nOXXOXXOX\nXOXXOXOX\nXOOXOOXO\nOXOOXOXO\n6\n7 2\n8 1\n4 5\n8 8\n3 4\n1 7","5\n3\n9\n14\n5\n3"]],"created_at":"2026-03-03 11:01:14"}}