Problem: 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.

Input

The first line contains two space-separated integers n and m (3 ≤ n, m ≤ 105) — 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 ui and vi (1 ≤ ui, vi ≤ 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 xi and yi (|xi|, |yi| ≤ 109) — the coordinates of the i-th vertex of the graph on the plane. 

The next line contains integer q (1 ≤ q ≤ 105) — the number of queries. Then follow q lines that describe the queries: the i-th line contains the sequence of space-separated integers ki, a1, a2, ..., aki (1 ≤ aj ≤ n; ki > 2), where ki is the cycle length in the i-th query, aj 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 105.

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.

Output

For each query print a single integer — the number of vertexes inside the cycle or on it. Print the answers in the order, in which the queries follow in the input. Separate the numbers by spaces.

Examples

Input

3 3
1 2
2 3
3 1
0 0
1 0
0 1
1
3 1 2 3


Output

3


Input

5 8
1 2
2 3
3 4
4 1
1 5
2 5
3 5
4 5
0 0
2 0
2 2
0 2
1 1
1
4 1 2 3 4


Output

5


Input

4 5
1 2
2 3
3 4
4 1
2 4
0 0
1 0
1 1
0 1
3
3 1 2 4
3 4 2 3
4 1 2 3 4


Output

3
3
4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
namespace {
template <class free>
inline void read(free& x) {
  x ^= x;
  register char c;
  while (c = getchar(), c == ' ' || c == '\n' || c == '\r')
    ;
  register bool check(false);
  if (c == '-') check = true, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (check) x = ~x + 1;
}
template <class f1, class... f2>
inline void read(f1& x, f2&... y) {
  read(x), read(y...);
}
}  // namespace
template <class free>
struct Vector {
  free* a;
  int n, n1;
  inline Vector() { a = 0, n = n1 = 0; }
  inline void push_back(const free& x) {
    if (n < n1)
      a[n++] = x;
    else {
      free* a1(new free[n1 = n1 ? n1 << 1 : 1]);
      memcpy(a1, a, sizeof(free) * n);
      if (a) delete[] a;
      (a = a1)[n++] = x;
    }
  }
  inline free& operator[](const int x) { return a[x]; }
  inline free& back() { return a[n - 1]; }
};
struct data {
  int to, w, op;
  long double w1;
  inline bool operator<(const data& x) const { return w1 < x.w1 - 1e-11; }
};
struct point {
  int x, y;
  inline long long operator*(const point& A) const {
    return x * 1ll * A.y - y * 1ll * A.x;
  }
} a[300050];
bool is[300050];
Vector<data> ar[300050];
int sz[300050], a1[300050];
inline int query(Vector<data>&, long double);
inline void dfs(int, int), link(int, int);
int main() {
  int n, m, q;
  read(n, m);
  for (int i(1), u, v; i <= m; ++i) read(u, v), link(u, v);
  for (int i(1); i <= n; ++i) read(a[i].x, a[i].y);
  {
    int i1(0);
    for (int i(1); i <= n; ++i)
      if (!i1 || a[i].x < a[i1].x) i1 = i;
    link(i1, ++n), a[n] = {-0x3f3f3f3f, 0}, dfs(n, 0);
  }
  for (int i(1), j, i1; i <= n; ++i) {
    for (j = 0; j < ar[i].n; ++j)
      i1 = ar[i][j].to, ar[i][j].w1 = atan2(a[i1].y - a[i].y, a[i1].x - a[i].x);
    sort(ar[i].a, ar[i].a + ar[i].n);
    for (j = 0; j < ar[i].n; ++j) ar[i][j].w += j ? ar[i][j - 1].w : 0;
  }
  read(q);
  for (int i(1), j, K; i <= q; ++i) {
    read(K);
    long long mj(0);
    int ans(0);
    for (j = 1; j <= K; ++j) read(a1[j]);
    for (j = 1; j <= K; ++j) mj += a[a1[j]] * a[a1[j % K + 1]];
    if (mj < 0) reverse(a1 + 1, a1 + K + 1);
    for (j = 1; j <= K; ++j) {
      int i1(a1[j % K + 1]), i2(a1[j == 1 ? K : j - 1]);
      i1 = query(ar[a1[j]], atan2(a[i1].y - a[a1[j]].y, a[i1].x - a[a1[j]].x));
      i2 = query(ar[a1[j]], atan2(a[i2].y - a[a1[j]].y, a[i2].x - a[a1[j]].x));
      if (i2 < i1)
        ans += ar[a1[j]][i1 - 1].w - ar[a1[j]][i2].w;
      else
        ans += i1 ? ar[a1[j]][i1 - 1].w : 0,
            ans += ar[a1[j]].back().w - ar[a1[j]][i2].w;
    }
    printf("%d\n", ans);
  }
  return 0;
}
inline int query(Vector<data>& x, long double v) {
  int l(0), r(x.n - 1), mid;
  while (mid = l + r >> 1, l <= r)
    x[mid].w1 < v - 1e-11 ? l = mid + 1 : r = mid - 1;
  return l;
}
inline void link(int u, int v) {
  ar[u].push_back({v, 0, ar[v].n});
  ar[v].push_back({u, 0, ar[u].n - 1});
}
inline void dfs(int x, int fa) {
  sz[x] = is[x] = 1;
  int b1(-1);
  for (int i(0), i1; i < ar[x].n; ++i)
    if (!is[i1 = ar[x][i].to])
      dfs(i1, x), sz[x] += sz[i1];
    else if (i1 == fa)
      b1 = i;
  if (~b1) ar[x][b1].w = sz[x], ar[fa][ar[x][b1].op].w = -sz[x];
}