#include <bits/stdc++.h>
using namespace std;
int const MAXN = 300010;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
struct graph {
  int h[MAXN], tot;
  struct edge {
    int to, next;
  } e[MAXN << 1];
  void add(int u, int v) {
    e[++tot] = (edge){v, h[u]}, h[u] = tot;
    e[++tot] = (edge){u, h[v]}, h[v] = tot;
  }
} G, G1;
int n, q, top, dfncnt, ans;
int a[MAXN], Stack[MAXN], siz[MAXN], tag[MAXN], dfn[MAXN];
int fa[MAXN][20], dep[MAXN];
void dfs1(int x, int pa) {
  fa[x][0] = pa;
  dfn[x] = ++dfncnt;
  for (int i = 1; i <= 19; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = G.h[x]; i; i = G.e[i].next) {
    int to = G.e[i].to;
    if (to == fa[x][0]) continue;
    dep[to] = dep[x] + 1;
    dfs1(to, x);
  }
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
bool cmp(int a, int b) { return dfn[a] < dfn[b]; }
void build() {
  G1.h[1] = 0;
  sort(a + 1, a + a[0] + 1, cmp);
  Stack[top = 1] = 1;
  for (int i = 1; i <= a[0]; i++) {
    G1.h[a[i]] = 0;
    tag[a[i]] = 1;
    if (a[i] == 1) continue;
    int LCA = lca(a[i], Stack[top]);
    if (LCA != Stack[top]) {
      while (dep[Stack[top - 1]] > dep[LCA]) {
        G1.add(Stack[top], Stack[top - 1]);
        top--;
      }
      if (LCA != Stack[top - 1]) {
        G1.h[LCA] = 0;
        G1.add(Stack[top], LCA);
        Stack[top] = LCA;
      } else {
        G1.add(Stack[top], Stack[top - 1]);
        top--;
      }
    }
    Stack[++top] = a[i];
  }
  for (int i = 1; i < top; i++) {
    G1.add(Stack[i], Stack[i + 1]);
  }
}
int dfsv(int x, int pa) {
  int res = 0;
  for (int i = G1.h[x]; i; i = G1.e[i].next) {
    int to = G1.e[i].to;
    if (to == pa) continue;
    if (fa[to][0] == x && tag[x] && tag[to]) return ans = -1;
    int k = dfsv(to, x);
    if (k == -1) return ans = -1;
    res += k;
  }
  if (tag[x]) {
    if (res) ans += res;
    return 1;
  } else {
    if (res > 1) {
      ans++;
      return 0;
    }
    return res;
  }
}
signed main() {
  n = read();
  for (int i = 1; i <= n - 1; i++) {
    int u = read(), v = read();
    G.add(u, v);
  }
  dep[1] = 1;
  dfs1(1, 1);
  q = read();
  for (int i = 1; i <= q; i++) {
    a[0] = read();
    for (int j = 1; j <= a[0]; j++) a[j] = read();
    ans = 0;
    if (a[0] == 1) {
      printf("%d\n", 0);
      continue;
    }
    build();
    dfsv(1, 1);
    printf("%d\n", ans);
    for (int j = 1; j <= a[0]; j++) tag[a[j]] = 0;
  }
  return 0;
}
