#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1.01e9;
const long double EPS = 1e-9;
const long double PI = acos(-1.0L);
void precalc() {}
const int maxn = (int)1e5 + 10;
struct Graph {
  int pr[maxn];
  int n;
  int iscool[maxn];
  vector<int> cool;
  void build(int _n) { n = _n; }
  int used[maxn];
  vector<vector<int> > es;
  int depth[maxn];
  void dfs(int v) {
    used[v] = 1;
    for (int it = 0; it < ((int)(es[v]).size()); ++it) {
      int u = es[v][it];
      if (used[u]) {
        continue;
      }
      depth[u] = depth[v] + 1;
      dfs(u);
    }
  }
  int back[maxn];
  int kill[maxn];
  int solve() {
    int root = find(pr, pr + n, -1) - pr;
    assert(root != n);
    es = vector<vector<int> >(n);
    for (int i = 0; i < n; ++i) {
      if (i != root) {
        es[pr[i]].push_back(i);
      }
    }
    for (int i = 0; i < n; ++i) {
      used[i] = 0;
      iscool[i] = 0;
    }
    dfs(root);
    for (int i = 0; i < n; ++i) {
      used[i] = 0;
      kill[i] = 0;
    }
    for (int i = 0; i < ((int)(cool).size()); ++i) {
      int v = cool[i];
      iscool[v] = 1;
      used[v] = 1;
    }
    priority_queue<pair<int, int> > qs;
    for (int i = 0; i < ((int)(cool).size()); ++i) {
      int v = cool[i];
      qs.push(make_pair(depth[v], v));
    }
    int res = 0;
    while (((int)(qs).size())) {
      pair<int, int> pa = qs.top();
      qs.pop();
      int v = pa.second;
      if (kill[v]) {
        continue;
      }
      int p = pr[v];
      if (p == -1) {
        continue;
      }
      if (!used[p]) {
        used[p] = 1;
        qs.push(make_pair(depth[p], p));
        continue;
      }
      if (iscool[p]) {
        ++res;
        continue;
      }
      if (kill[p]) {
        continue;
      }
      kill[p] = 1;
      ++res;
    }
    return res;
  }
} small;
int n, q;
vector<vector<int> > es;
bool read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].push_back(t), es[t].push_back(s);
  }
  scanf("%d", &q);
  return 1;
}
int tme;
int starts[maxn], mends[maxn];
int used[maxn];
const int maxl = 17;
int pr[maxl][maxn];
int depth[maxn];
void dfs(int v) {
  used[v] = 1;
  starts[v] = tme++;
  for (int it = 0; it < ((int)(es[v]).size()); ++it) {
    int u = es[v][it];
    if (used[u]) {
      continue;
    }
    pr[0][u] = v;
    depth[u] = depth[v] + 1;
    dfs(u);
  }
  mends[v] = tme++;
}
int inside(int pr, int v) {
  return starts[pr] <= starts[v] && mends[v] <= mends[pr];
}
int lca(int a, int b) {
  if (depth[a] < depth[b]) {
    swap(a, b);
  }
  for (int l = maxl - 1; l >= 0 && depth[a] > depth[b]; --l) {
    if (depth[a] - (1 << l) >= depth[b]) {
      a = pr[l][a];
    }
  }
  if (a == b) {
    return a;
  }
  for (int l = maxl - 1; l >= 0; --l) {
    if (pr[l][a] != pr[l][b]) {
      a = pr[l][a], b = pr[l][b];
    }
  }
  assert(pr[0][a] == pr[0][b]);
  return pr[0][a];
}
int ids[maxn];
void build(const vector<pair<int, int> > &tosort) {
  vector<int> st;
  for (int pos = 0; pos < ((int)(tosort).size()); ++pos) {
    int v = tosort[pos].second;
    while (((int)(st).size()) > 0) {
      int pr = st.back();
      if (inside(pr, v)) {
        break;
      }
      st.pop_back();
    }
    small.pr[ids[v]] = ((int)(st).size()) > 0 ? ids[st.back()] : -1;
    st.push_back(v);
  }
}
void solve() {
  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }
  tme = 0;
  pr[0][0] = 0;
  depth[0] = 0;
  dfs(0);
  for (int l = 1; l < maxl; ++l) {
    for (int v = 0; v < n; ++v) {
      pr[l][v] = pr[l - 1][pr[l - 1][v]];
    }
  }
  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }
  for (int iter = 0; iter < q; ++iter) {
    int k;
    scanf("%d", &k);
    vector<int> cool;
    for (int i = 0; i < k; ++i) {
      int v;
      scanf("%d", &v);
      --v;
      used[v] = iter + 1;
      cool.push_back(v);
    }
    bool fail = 0;
    for (int i = 0; i < k; ++i) {
      int v = cool[i];
      if (v != 0 && used[pr[0][v]] == iter + 1) {
        fail = 1;
        break;
      }
    }
    if (fail) {
      printf("-1\n");
      continue;
    }
    vector<pair<int, int> > tosort;
    for (int i = 0; i < k; ++i) {
      int v = cool[i];
      tosort.push_back(make_pair(starts[v], v));
    }
    sort(tosort.begin(), tosort.end());
    vector<int> vers = cool;
    for (int i = 0; i < k - 1; ++i) {
      vers.push_back(lca(tosort[i].second, tosort[i + 1].second));
    }
    sort(vers.begin(), vers.end());
    vers.resize(unique(vers.begin(), vers.end()) - vers.begin());
    for (int i = 0; i < ((int)(vers).size()); ++i) {
      ids[vers[i]] = i;
    }
    small.build(((int)(vers).size()));
    small.cool.clear();
    for (int i = 0; i < ((int)(cool).size()); ++i) {
      small.cool.push_back(ids[cool[i]]);
    }
    tosort.clear();
    for (int i = 0; i < ((int)(vers).size()); ++i) {
      tosort.push_back(make_pair(starts[vers[i]], vers[i]));
    }
    sort(tosort.begin(), tosort.end());
    build(tosort);
    printf("%d\n", small.solve());
  }
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
