#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
inline void priv(vector<int> a) {
  for (int i = 0; i < ((int)(a).size()); ++i)
    printf("%d%c", a[i], i == (int)(a).size() - 1 ? '\n' : ' ');
}
const int MX = 100005, INF = 1001001001;
const long long int LINF = 1e18;
const double eps = 1e-10;
struct hl {
  int n, oi;
  vector<vector<int> > to, d;
  vector<int> vd, vk, pv, dep, od;
  int root;
  hl() {}
  hl(int mx) : n(mx), to(mx), vd(mx), vk(mx), dep(mx), od(mx), oi(0) {}
  void add(int a, int b) {
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int dfs(int v, int de = 0, int p = -1) {
    od[v] = oi++;
    dep[v] = de;
    vector<pair<int, int> > rs;
    for (int i = 0; i < ((int)(to[v]).size()); ++i) {
      int u = to[v][i];
      if (u == p) continue;
      rs.push_back(pair<int, int>(dfs(u, de + 1, v), u));
    }
    if ((int)(rs).size()) {
      sort(rs.begin(), rs.end());
      vd[v] = vd[rs[0].second];
      pv[vd[v]] = p;
      d[vd[v]].push_back(v);
      vk[v] = -(int)(d[vd[v]]).size();
      return rs[0].first -
             ((int)(rs).size() != 1 && rs[0].first == rs[1].first);
    } else {
      vd[v] = (int)(d).size();
      vk[v] = -1;
      d.push_back(vector<int>(1, v));
      pv.push_back(p);
      return 1;
    }
  }
  void init(int v = 0) {
    dfs(root = v);
    for (int i = 0; i < ((int)(d).size()); ++i)
      reverse(d[i].begin(), d[i].end());
    for (int i = 0; i < ((int)(vk).size()); ++i)
      vk[i] += (int)(d[vd[i]]).size();
  }
  int lca(int a, int b) {
    int p = vd[a];
    vector<int> ap(1, p);
    while (pv[p] != -1) ap.push_back(p = vd[pv[p]]);
    reverse(ap.begin(), ap.end());
    ap.push_back(-2);
    p = vd[b];
    vector<int> bp(1, p);
    while (pv[p] != -1) bp.push_back(p = vd[pv[p]]);
    reverse(bp.begin(), bp.end());
    bp.push_back(-3);
    int pi = 1;
    while (ap[pi] == bp[pi]) ++pi;
    p = ap[pi - 1];
    int ai = vd[a] == p ? vk[a] : vk[pv[ap[pi]]];
    int bi = vd[b] == p ? vk[b] : vk[pv[bp[pi]]];
    return d[p][min(ai, bi)];
  }
  int solve(vector<int>& a) {
    sort(a.begin(), a.end(), [&](int i, int j) { return od[i] < od[j]; });
    vector<int> p = a;
    int m = (int)(a).size();
    for (int i = 0; i < (m - 1); ++i) {
      int c = lca(a[i], a[i + 1]);
      if (c != a[i]) a.push_back(c);
    }
    sort(a.begin(), a.end(), [&](int i, int j) { return od[i] < od[j]; });
    a.erase(unique(a.begin(), a.end()), a.end());
    m = (int)(a).size();
    vector<vector<int> > g(m);
    vector<int> s(1, 0);
    for (int i = 0; i < (m - 1); ++i) {
      int c = lca(a[i], a[i + 1]);
      if (a[i] == c)
        s.push_back(i);
      else {
        while (a[s.back()] != c) s.pop_back();
      }
      int pa = s.back();
      g[pa].push_back(i + 1);
    }
    vector<int> b(m);
    int pi = 0;
    for (int i = 0; i < (m); ++i) {
      if (pi < (int)(p).size() && a[i] == p[pi]) b[i] = 1, pi++;
    }
    int res = 0;
    vector<int> dp(m, 0);
    for (int i = (m)-1; i >= 0; --i) {
      int cnt = 0;
      bool ok = false;
      for (int u : g[i]) {
        if (dp[u] == 1) {
          int len = dep[a[u]] - dep[a[i]];
          if (b[i]) {
            if (len == 1) return -1;
            res++;
          } else {
            cnt++;
            if (len > 1) ok = true;
          }
        } else if (dp[u] == 2) {
          if (b[i]) {
            res++;
          } else {
            cnt++;
            ok = true;
          }
        }
      }
      if (b[i])
        dp[i] = 1;
      else if (cnt == 1) {
        dp[i] = 2;
      } else if (cnt >= 2) {
        res++;
      }
    }
    return res;
  }
};
int main() {
  int n, q;
  scanf("%d", &n);
  hl g(n);
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g.add(a, b);
  }
  g.init();
  scanf("%d", &q);
  for (int qi = 0; qi < (q); ++qi) {
    int m;
    scanf("%d", &m);
    vector<int> a(m);
    for (int i = 0; i < (m); ++i) scanf("%d", &a[i]);
    for (int i = 0; i < (m); ++i) a[i]--;
    int ans = g.solve(a);
    printf("%d\n", ans);
  }
  return 0;
}
