{"raw_statement":[{"iden":"problem statement","content":"We have $N$ polygons on the $xy$\\-plane.  \nEvery side of these polygons is parallel to the $x$\\- or $y$\\-axis, and every interior angle is $90$ or $270$ degrees. All of these polygons are simple.  \nThe $i$\\-th polygon has $M_i$ corners, the $j$\\-th of which is $(x_{i, j}, y_{i, j})$.  \nThe sides of this polygon are segments connecting the $j$\\-th and $(j+1)$\\-th corners. (Assume that $(M_i+1)$\\-th corner is the $1$\\-st corner.)\nA polygon is simple when...for any two of its sides that are not adjacent, they do not intersect (cross or touch) each other.\nYou are given $Q$ queries. For each $i = 1, 2, \\dots, Q$, the $i$\\-th query is as follows.\n\n*   Among the $N$ polygons, how many have the point $(X_i + 0.5, Y_i + 0.5)$ inside them?"},{"iden":"constraints","content":"*   $1 \\leq N \\leq 10^5$\n*   $4 \\leq M_i \\leq 10^5$\n*   Each $M_i$ is even.\n*   $\\sum_i M_i \\leq 4 \\times 10^5$\n*   $0 \\leq x_{i, j}, y_{i, j} \\leq 10^5$\n*   $(x_{i, j}, y_{i, j}) \\neq (x_{i, k}, y_{i, k})$ if $j \\neq k$.\n*   $x_{i, j} = x_{i, j+1}$ for $j = 1, 3, \\dots M_i-1$.\n*   $y_{i, j} = y_{i, j+1}$ for $j = 2, 4, \\dots M_i$. (Assume $y_{i, M_i +1} = y_{i, 1}$.)\n*   The given polygons are simple.\n*   $1 \\leq Q \\leq 10^5$\n*   $0 \\leq X_i, Y_i \\lt 10^5$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$M_1$\n$x_{1, 1}$ $y_{1, 1}$ $x_{1, 2}$ $y_{1, 2}$ $\\dots$ $x_{1, M_1}$ $y_{1, M_1}$\n$M_2$\n$x_{2, 1}$ $y_{2, 1}$ $x_{2, 2}$ $y_{2, 2}$ $\\dots$ $x_{2, M_2}$ $y_{2, M_2}$\n$\\vdots$\n$M_N$\n$x_{N, 1}$ $y_{N, 1}$ $x_{N, 2}$ $y_{N, 2}$ $\\dots$ $x_{N, M_N}$ $y_{N, M_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":"3\n4\n1 2 1 4 3 4 3 2\n4\n2 5 2 3 5 3 5 5\n4\n5 6 5 5 3 5 3 6\n3\n1 4\n2 3\n4 5"},{"iden":"sample output 1","content":"0\n2\n1\n\n![image](https://img.atcoder.jp/ghi/5fccf008dddd93f10ebfc7f13d04a0e0.png)  \nNote that different polygons may cross or touch each other."},{"iden":"sample input 2","content":"2\n4\n12 3 12 5 0 5 0 3\n12\n1 1 1 9 10 9 10 0 4 0 4 6 6 6 6 2 8 2 8 7 2 7 2 1\n4\n2 6\n4 4\n6 3\n1 8"},{"iden":"sample output 2","content":"0\n2\n1\n1\n\n![image](https://img.atcoder.jp/ghi/1c97f791a2aadcf5637b1f10736fb820.png)  \nAlthough the polygons are simple, they may not be convex."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}