#include <bits/stdc++.h>
const int N = 100005, bit = 21;
int n, q, cnt, e_cnt, v_cnt, top;
int heads[N], vheads[N], a[N], stk[N], f[bit][N], dep[N], dfn[N];
bool key[N], c[N];
struct Edge {
  int v, nxt;
} e[N << 1], g[N << 1];
inline void add(int u, int v, int *heads, Edge *e, int &e_cnt) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}
void dfs(int x, int fa) {
  dfn[x] = ++cnt;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      dep[v] = dep[x] + 1, f[0][v] = x;
      dfs(v, x);
    }
  }
}
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  for (int i = bit - 1; ~i; --i)
    if (dep[f[i][x]] >= dep[y]) x = f[i][x];
  if (x == y) return x;
  for (int i = bit - 1; ~i; --i)
    if (f[i][x] != f[i][y]) x = f[i][x], y = f[i][y];
  return f[0][x];
}
inline bool cmp(const int &lhs, const int &rhs) { return dfn[lhs] < dfn[rhs]; }
inline void link(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  add(y, x, vheads, g, v_cnt);
}
int solve(int x) {
  int sum = 0, cnt = 0;
  for (int i = vheads[x], v; i; i = g[i].nxt) {
    v = g[i].v;
    sum += solve(v);
    if (c[v]) ++cnt;
  }
  if (key[x])
    sum += cnt, c[x] = true;
  else if (cnt > 1)
    sum += 1, c[x] = false;
  else
    c[x] = cnt ? true : false;
  key[x] = false;
  return sum;
}
inline int work() {
  int k;
  scanf("%d", &k);
  for (int j = 1; j <= k; ++j) {
    scanf("%d", &a[j]), key[a[j]] = true;
  }
  for (int j = 1; j <= k; ++j)
    for (int h = heads[a[j]]; h; h = e[h].nxt)
      if (key[e[h].v]) {
        for (int l = 1; l <= k; ++l) key[a[l]] = false;
        return -1;
      }
  std::sort(a + 1, a + k + 1, cmp);
  stk[top = 1] = a[1];
  for (int i = 2; i <= k; ++i) {
    int mlca = lca(stk[top], a[i]);
    if (mlca != stk[top]) {
      while (dfn[stk[top - 1]] > dfn[mlca]) link(stk[top], stk[top - 1]), --top;
      if (stk[top - 1] != mlca)
        vheads[mlca] = 0, link(mlca, stk[top]), stk[top] = mlca;
      else
        link(mlca, stk[top--]);
    }
    vheads[a[i]] = 0, stk[++top] = a[i];
  }
  for (int i = 1; i < top; ++i) link(stk[i], stk[i + 1]);
  return solve(stk[1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v, heads, e, e_cnt), add(v, u, heads, e, e_cnt);
  }
  dep[1] = 1;
  dfs(1, 1);
  for (int i = 1; i < bit; ++i)
    for (int j = 1; j <= n; ++j) f[i][j] = f[i - 1][f[i - 1][j]];
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) printf("%d\n", work());
  return 0;
}
