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>
template <class T>
struct _iter_wrapper {
  T begin_, end_;
  T begin() { return begin_; }
  T end() { return end_; }
};
template <class T>
_iter_wrapper<const T*> span(const T* arr, int n) {
  return _iter_wrapper<const T*>{arr, arr + n};
}
template <class T, int N>
_iter_wrapper<const T*> span(const T (&arr)[N]) {
  return span(arr, N);
}
using namespace std;
using namespace rel_ops;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;
using Vll = vector<ll>;
using Vull = vector<ull>;
using Pii = pair<int, int>;
template <class T, class V>
auto operator<<(T& out, V val) -> decltype(val.print(0), out) {
  out << "{";
  val.print();
  return out << "}";
}
template <class T, class V>
auto operator<<(T& out, V val) -> decltype(get<1>(val), out) {
  return out << "(" << val.first << ", " << val.second << ")";
}
template <class T, class V>
auto operator<<(T& out, V val) -> decltype((val).begin(), (val).end(), out) {
  out << "[";
  bool comma = false;
  for (auto elem : val) {
    if (comma) out << ", ";
    out << elem;
    comma = true;
  }
  return out << "]";
}
void DD(...) {}
template <class T, class... S>
void DD(const char* format, T elem, S... rest) {
  int braces = 0;
  while (*format && (braces > 0 || *format != ',')) {
    if (*format == '(' || *format == '[' || *format == '{' || *format == '<') {
      braces++;
    }
    if (*format == ')' || *format == ']' || *format == '}' || *format == '>')
      braces--;
    cerr << *format++;
  }
  cerr << ": " << elem << *format++;
  DD(format, rest...);
}
template <class... T>
void _printDebug(int line, const char* format, T... elems) {
  cerr << '<';
  if (line < 10) cerr << '0';
  if (line < 100) cerr << '0';
  cerr << line << "> ";
  DD(format, elems...);
  cerr << endl;
}
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  run();
  return 0;
}
struct vec2 {
  using T = ll;
  T first{0}, second{0};
  vec2() {}
  vec2(T a, T b) : first(a), second(b) {}
  vec2 operator+(vec2 r) const { return {first + r.first, second + r.second}; }
  vec2 operator-(vec2 r) const { return {first - r.first, second - r.second}; }
  vec2 operator*(T r) const { return {first * r, second * r}; }
  vec2 operator/(T r) const { return {first / r, second / r}; }
  T dot(vec2 r) const { return first * r.first + second * r.second; }
  T cross(vec2 r) const { return first * r.second - second * r.first; }
  T dist2() const { return first * first + second * second; }
  bool operator==(vec2 r) const {
    return first == r.first && second == r.second;
  }
  bool upper() const { return second > 0 || (second == 0 && first > 0); }
  bool operator<(vec2 r) const {
    if (upper() != r.upper()) return upper();
    return cross(r) > 0;
  }
  void print(...) { cerr << first << ',' << second; }
};
struct Vert {
  Vi edges, edgesPos;
  vector<ll> prefs;
  vec2 pos;
  bool visited{false};
  void print(...) {
    DD("edges, edgesPos, prefs, pos, visited", edges, edgesPos, prefs, pos,
       visited);
  };
};
int n, m;
vector<Vert> V;
ll dfs(int i, int from = -1) {
  if (V[i].visited) return 0;
  ll sum = 0;
  V[i].visited = true;
  V[i].prefs.push_back(0);
  for (auto& e : (V[i].edges)) {
    if (e != from) sum += dfs(e, i);
    V[i].prefs.push_back(-sum);
  }
  sum++;
  ll sub = 0;
  for (int j = (0); j < (int((V[i].edges).size())); j++) {
    if (V[i].edges[j] == from) sub = sum;
    V[i].prefs[j + 1] += sub;
  }
  return sum;
}
void query() {
  int k;
  cin >> k;
  Vi cycle(k);
  for (auto& v : (cycle)) cin >> v;
  ll sum = 0;
  for (int i = (0); i < (k); i++) {
    int cur = cycle[i];
    int next = cycle[(i + 1) % k];
    sum += (V[next].pos.first - V[cur].pos.first) *
           (V[next].pos.second + V[cur].pos.second);
  }
  if (sum > 0) reverse((cycle).begin(), (cycle).end());
  ll ans = 0;
  for (int i = (0); i < (k); i++) {
    int prev = cycle[(i - 1 + k) % k];
    int next = cycle[(i + 1) % k];
    int cur = cycle[i];
    auto& vert = V[cur];
    auto cmp = [&](int a, int b) { return vert.edges[a] < b; };
    int begin =
        *lower_bound((vert.edgesPos).begin(), (vert.edgesPos).end(), prev, cmp);
    int end =
        *lower_bound((vert.edgesPos).begin(), (vert.edgesPos).end(), next, cmp);
    if (begin < end) {
      ans += vert.prefs[end] - vert.prefs[begin + 1];
    } else {
      ans += vert.prefs[int((vert.edges).size())] - vert.prefs[begin + 1];
      ans += vert.prefs[end];
    }
  }
  cout << ans << endl;
}
void run() {
  cin >> n >> m;
  V.resize(n + 1);
  for (int i = (0); i < (m); i++) {
    int a, b;
    cin >> a >> b;
    V[a].edges.push_back(b);
    V[b].edges.push_back(a);
  }
  int leftMost = 1;
  for (int i = (1); i < (int((V).size())); i++) {
    cin >> V[i].pos.first >> V[i].pos.second;
    if (V[i].pos.first < V[leftMost].pos.first) leftMost = i;
  }
  V[0].pos = V[leftMost].pos - vec2(10, 0);
  V[0].edges.push_back(leftMost);
  V[leftMost].edges.push_back(0);
  for (int i = (0); i < (int((V).size())); i++) {
    auto& vert = V[i];
    sort((vert.edges).begin(), (vert.edges).end(), [&](int l, int r) {
      return V[l].pos - vert.pos < V[r].pos - vert.pos;
    });
    vert.edgesPos.resize(int((vert.edges).size()));
    iota((vert.edgesPos).begin(), (vert.edgesPos).end(), 0);
    sort((vert.edgesPos).begin(), (vert.edgesPos).end(),
         [&](int l, int r) { return vert.edges[l] < vert.edges[r]; });
  }
  dfs(0);
  int q;
  cin >> q;
  while (q--) query();
}