QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#12098. Army Training

統計

The Byteland Army plans to conduct the greatest military exercise in its history this weekend. The exercise will take place on the training ground in Northern Bytetown. The officers of Byteland Army know this training ground perfectly; they do not, however, know the assignments. This is why they requested your help, recruit!

Your superiors know exactly where the strategic spots on the training ground are located. During the exercise they will be asked multiple times to capture various areas of the training ground. One of the most crucial decisions will be the allocation of forces and determining the strength needed to capture a particular area - this strength should be proportional to the number of strategic spots in the attacked area. Your task is to determine for each area, represented as a polygon with vertices in the strategic spots, the number of strategic spots lying strictly inside the interior of the area.

Input Format

In the first line of the standard input two integers $n$ and $m$ are given ($3 ≤ n ≤ 1\,000$, $1 ≤ m ≤ 100\,000$), denoting respectively the number of strategic spots on the training ground and the number of queries. The strategic spots are numbered from $1$ to $n$.

The next $n$ lines give descriptions of the strategic spots. In the ith line two integers $x_{i}$ and $y_{i}$ ($-10^{9} ≤ x_{i}, y_{i}≤ 10^{9}$) are given, denoting the coordinates of the ith strategic spot. No three strategic spots are collinear.

The next m rows contain the descriptions of the m queries. Each description begins with an integer $k_{j}$ ($3 ≤ k_{j} ≤ n$), denoting the number of vertices of the polygon. It is followed by $k_{j}$ different integers from the interval $[1, n]$, which denote the identifiers of strategic spots that are subsequent vertices of the polygon. All the given polygons will be simple (i.e., without self-intersections), and their vertices are given in the clockwise order. The sum of all the numbers $k_{j}$ does not exceed $1\,000\,000$.

Output Format

Your program should write $m$ lines to the standard output. The jth line should contain one integer, being the number of strategic spots in the interior of the polygon described in the jth query.

Example

Input

6 4
0 0
0 5
5 0
11 10
5 5
2 1
4 1 2 4 3
4 1 2 5 3
3 6 2 4
3 1 2 6

Output

2
1
1
0
problem_12098_1.gif

The circles in the figure depict strategic spots, while the numbers next to the circles - their identifiers. The figure shows the areas from the first (continuous lines) and third (dashed lines, filled in yellow) query.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.