#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> mp[1000010];
int dep[1000010], f[1000010];
int num, lg2[1000010], fir[1000010], st[1000010 << 1][20];
void dfs(int x, int fa) {
  f[x] = fa;
  dep[x] = dep[fa] + 1;
  st[++num][0] = x;
  fir[x] = num;
  for (int i = mp[x].size() - 1; i >= 0; i--) {
    int y = mp[x][i];
    if (y == fa) continue;
    dfs(y, x);
    st[++num][0] = x;
  }
}
int getlca(int x, int y) {
  x = fir[x], y = fir[y];
  if (x > y) swap(x, y);
  int k = lg2[y - x + 1];
  if (dep[st[x][k]] > dep[st[y - (1 << k) + 1][k]])
    return st[y - (1 << k) + 1][k];
  return st[x][k];
}
int m;
int a[1000010];
int cmp(int x, int y) { return fir[x] < fir[y]; }
int d[1000010], top;
int cnt2, s2[1000010];
struct edge {
  int num, next;
} mp2[1000010 << 1];
void init(int x, int y) {
  mp2[++cnt2].next = s2[x];
  mp2[cnt2].num = y;
  s2[x] = cnt2;
}
int siz[1000010];
int ans;
void dfs2(int x, int fa) {
  if (siz[x]) {
    for (int i = s2[x]; i; i = mp2[i].next) {
      int y = mp2[i].num;
      if (y == fa) continue;
      dfs2(y, x);
      if (siz[y]) {
        siz[y] = 0;
        ++ans;
      }
    }
  } else {
    for (int i = s2[x]; i; i = mp2[i].next) {
      int y = mp2[i].num;
      if (y == fa) continue;
      dfs2(y, x);
      siz[x] += siz[y];
      siz[y] = 0;
    }
    if (siz[x] > 1) {
      ++ans;
      siz[x] = 0;
    }
  }
  s2[x] = 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    mp[x].push_back(y);
    mp[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= num; i++) lg2[i] = log2(i);
  int T = log2(num);
  for (int i = 1; i <= T; i++)
    for (int j = 1; j <= num; j++) {
      if (dep[st[j][i - 1]] > dep[st[j + (1 << (i - 1))][i - 1]])
        st[j][i] = st[j + (1 << (i - 1))][i - 1];
      else
        st[j][i] = st[j][i - 1];
    }
  scanf("%d", &m);
  while (m--) {
    cnt2 = 0;
    int k;
    scanf("%d", &k);
    for (int i = 1; i <= k; i++) scanf("%d", &a[i]), siz[a[i]] = 1;
    int t = 1;
    for (int i = 1; i <= k; i++)
      if (siz[f[a[i]]]) {
        printf("-1\n");
        t = 0;
        break;
      }
    if (!t) {
      for (int i = 1; i <= k; i++) siz[a[i]] = 0;
      continue;
    }
    ans = 0;
    sort(a + 1, a + k + 1, cmp);
    int rt = a[1];
    for (int i = 2; i <= k; i++) rt = getlca(rt, a[i]);
    d[top = 1] = rt;
    for (int i = 1; i <= k; i++) {
      int lca = getlca(d[top], a[i]);
      while (dep[lca] < dep[d[top - 1]]) {
        init(d[top - 1], d[top]);
        --top;
      }
      if (dep[lca] < dep[d[top]]) init(lca, d[top--]);
      if (d[top] != lca) d[++top] = lca;
      if (d[top] != a[i]) d[++top] = a[i];
    }
    while (top > 1) init(d[top - 1], d[top]), --top;
    dfs2(rt, rt);
    siz[rt] = 0;
    printf("%d\n", ans);
  }
}
