A graph is called planar, if it can be drawn in such a way that its edges intersect only at their vertexes.

An articulation point is such a vertex of an undirected graph, that when removed increases the number of connected components of the graph.

A bridge is such an edge of an undirected graph, that when removed increases the number of connected components of the graph.

You've got a connected undirected planar graph consisting of *n* vertexes, numbered from 1 to *n*, drawn on the plane. The graph has no bridges, articulation points, loops and multiple edges. You are also given *q* queries. Each query is a cycle in the graph. The query response is the number of graph vertexes, which (if you draw a graph and the cycle on the plane) are located either inside the cycle, or on it. Write a program that, given the graph and the queries, will answer each query.
The first line contains two space-separated integers *n* and *m* (3 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>) — the number of vertexes and edges of the graph. Next *m* lines contain the edges of the graph: the *i*-th line contains two space-separated integers *u*<sub class="lower-index">*i*</sub> and *v*<sub class="lower-index">*i*</sub> (1 ≤ *u*<sub class="lower-index">*i*</sub>, *v*<sub class="lower-index">*i*</sub> ≤ *n*) — the numbers of vertexes, connecting the *i*-th edge. The next *n* lines contain the positions of the planar graph vertexes on the plane: the *i*-th line contains a pair of space-separated integers *x*<sub class="lower-index">*i*</sub> and *y*<sub class="lower-index">*i*</sub> (|*x*<sub class="lower-index">*i*</sub>|, |*y*<sub class="lower-index">*i*</sub>| ≤ 10<sup class="upper-index">9</sup>) — the coordinates of the *i*-th vertex of the graph on the plane. 

The next line contains integer *q* (1 ≤ *q* ≤ 10<sup class="upper-index">5</sup>) — the number of queries. Then follow *q* lines that describe the queries: the *i*-th line contains the sequence of space-separated integers *k*<sub class="lower-index">*i*</sub>, *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*k*<sub class="lower-index">*i*</sub></sub> (1 ≤ *a*<sub class="lower-index">*j*</sub> ≤ *n*; *k*<sub class="lower-index">*i*</sub> &gt; 2), where *k*<sub class="lower-index">*i*</sub> is the cycle length in the *i*-th query, *a*<sub class="lower-index">*j*</sub> are numbers of the vertexes that form a cycle. The numbers of vertexes in the cycle are given in the clockwise or counterclockwise order. The given cycles are simple, that is they cannot go through a graph vertex more than once. The total length of all cycles in all queries does not exceed 10<sup class="upper-index">5</sup>.

It is guaranteed that the given graph contains no bridges, articulation points, loops and multiple edges. It is guaranteed that the edge segments can have common points only at the graph's vertexes.
l=input()
l=l.split(' ')
m=int(l.pop())
n=int(l.pop())
edges=[]
for k in range(m):
    l=input()
    l=l.split(' ')
    b=int(l.pop())
    a=int(l.pop())
    edges.append([a,b])
positions=[]
for k in range(n):
    l=input()
    l=l.split(' ')
    b=int(l.pop())
    a=int(l.pop())
    positions.append([a,b])
q=int(input())
queries=[]
for k in range(q):
    l=input()
    l=l.split(' ')
    r=len(l)
    liste=[]
    for k in range(r):
        liste.append(positions[int(l[k])-1])
    queries.append(liste)

def distance(a,b):
    return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)

def point_in_poly(x,y,poly):

    n = len(poly)
    inside = False

    p1x,p1y = poly[0]
    for i in range(n+1):
        p2x,p2y = poly[i % n]
        if y > min(p1y,p2y):
            if y <= max(p1y,p2y):
                if x <= max(p1x,p2x):
                    if p1y != p2y:
                        xints = (y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x
                    if p1x == p2x or x <= xints:
                        inside = not inside
        p1x,p1y = p2x,p2y

    return inside



for k in range(q):
    V=queries[k]
    compteur=0
    for point in positions:
        if point_in_poly(point[0],point[1],V)==True and point not in V:
            compteur+=1
    compteur+=len(V)-1
    print(compteur)























    