{"raw_statement":[{"iden":"problem statement","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."},{"iden":"constraints","content":"*   $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$"},{"iden":"input","content":"Input 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$"},{"iden":"sample input 1","content":"4 2\nOXXX\nXXXX\nXXXX\nXXXX\n6\n1 1\n1 4\n2 2\n2 3\n3 1\n4 4"},{"iden":"sample output 1","content":"1\n1\n1\n0\n0\n0\n\nOnly Square $(1,1)$ contains a piece, which covers the following `#` squares:\n\n####\n##..\n....\n...."},{"iden":"sample input 2","content":"5 10\nOOOOO\nOOOOO\nOOOOO\nOOOOO\nOOOOO\n5\n1 1\n2 3\n3 4\n4 2\n5 5"},{"iden":"sample output 2","content":"1\n6\n12\n8\n25"},{"iden":"sample input 3","content":"8 5\nOXXOXXOX\nXOXXOXOX\nXOOXOOXO\nOXOOXOXO\nOXXOXXOX\nXOXXOXOX\nXOOXOOXO\nOXOOXOXO\n6\n7 2\n8 1\n4 5\n8 8\n3 4\n1 7"},{"iden":"sample output 3","content":"5\n3\n9\n14\n5\n3"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}