#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();
}
