#include <bits/stdc++.h>
using namespace std;
const int N = 1E5 + 5;
int n, x, y, m, p[N], k, l[N], sum, dep[N], fa[N][21], lca, ans, pre[N], ne[N],
    t, last, pp, p2;
struct data {
  int x, p, y;
  friend bool operator<(data a, data b) {
    if (a.x == b.x) return a.p < b.p;
    return dep[a.x] < dep[b.x];
  }
} P;
bool oo, o[N], o2[N];
vector<int> G[N];
priority_queue<data> q;
int comp(const int& a, const int& b) { return l[a] < l[b]; }
void dfs(int x) {
  l[x] = ++sum;
  for (int i = 0; i < G[x].size(); i++)
    if ((y = G[x][i]) != fa[x][0]) {
      fa[y][0] = x;
      dep[y] = dep[x] + 1;
      for (int j = 1; (1 << j) <= dep[y]; j++)
        fa[y][j] = fa[fa[y][j - 1]][j - 1];
      dfs(y);
    }
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[x] - (1 << i) >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void add(int x, int y) {
  if (!p[x] || !p[y]) return;
  P.p = x;
  P.y = y;
  x = p[x];
  y = p[y];
  P.x = LCA(x, y);
  q.push(P);
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k;
    oo = 1;
    ans = t = last = 0;
    for (int j = 1; j <= k; j++) scanf("%d", &p[j]), o[p[j]] = 1;
    sort(p + 1, p + k + 1, comp);
    for (int j = 1; j <= k; j++)
      if (p[j] != p[last]) {
        pre[j] = last;
        ne[last] = j;
        add(last, j);
        last = j;
      }
    ne[last] = pre[0] = 0;
    while (!q.empty()) {
      P = q.top();
      q.pop();
      lca = P.x;
      x = P.p;
      y = P.y;
      if (ne[x] != y || pre[y] != x) continue;
      if (p[x] != p[y]) ans++;
      if (o[lca]) {
        if (dep[lca] + 1 == dep[p[y]]) oo = 0;
        ne[x] = ne[y];
        pre[ne[y]] = x;
        add(x, ne[x]);
      } else {
        for (p2 = y; LCA(p[p2], p[x]) == lca; p2 = ne[p2])
          ne[x] = ne[p2], pre[ne[p2]] = x;
        for (pp = x; LCA(p[pp], p[y]) == lca; pp = pre[pp])
          ne[pre[pp]] = p2, pre[p2] = pre[pp];
        add(pp, ne[pp]);
      }
    }
    for (int j = 1; j <= k; j++) o[p[j]] = 0, p[j] = 0;
    printf("%d\n", oo ? ans : -1);
  }
}
