#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int n, a, b, cur, h[maxn], nxt[maxn * 2], p[maxn * 2];
void add_edge(int x, int y) {
  cur++;
  nxt[cur] = h[x];
  h[x] = cur;
  p[cur] = y;
}
int tid, dfn[maxn], dep[maxn], lg[maxn], fa[maxn][25];
void dfs(int x, int f) {
  dfn[x] = ++tid;
  for (int j = h[x]; j; j = nxt[j])
    if (p[j] != f) fa[p[j]][0] = x, dep[p[j]] = dep[x] + 1, dfs(p[j], x);
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int k = dep[x] - dep[y];
  for (int i = lg[k]; i >= 0; i--)
    if (k & (1 << i)) x = fa[x][i];
  if (x == y) return x;
  for (int i = lg[dep[x]]; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int q, k, s[maxn], st[maxn], top, f[maxn], gg[maxn];
bool tf[maxn], jud;
bool cmp(int x, int y) { return dfn[x] < dfn[y]; }
int lst[maxn];
vector<pair<int, int> > g[maxn];
void DP(int x) {
  f[x] = 0;
  gg[x] = 0;
  for (vector<pair<int, int> >::iterator it = g[x].begin(); it != g[x].end();
       it++) {
    DP(it->first);
    f[x] += f[it->first];
    if (tf[x] && tf[it->first] && it->second == 1) jud = false;
  }
  if (tf[x]) {
    gg[x] = 1;
    for (vector<pair<int, int> >::iterator it = g[x].begin(); it != g[x].end();
         it++)
      f[x] += gg[it->first];
    return;
  } else {
    int cnt = 0;
    for (vector<pair<int, int> >::iterator it = g[x].begin(); it != g[x].end();
         it++)
      if (gg[it->first]) cnt++;
    if (cnt == 0)
      gg[x] = 0;
    else if (cnt == 1)
      gg[x] = 1;
    else
      f[x]++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) lg[i] = lg[i / 2] + 1;
  for (int i = 1; i < n; i++)
    scanf("%d%d", &a, &b), add_edge(a, b), add_edge(b, a);
  dep[1] = 1;
  dfs(1, 0);
  for (int i = 1; i <= lg[n]; i++)
    for (int j = 1; j <= n; j++) fa[j][i] = fa[fa[j][i - 1]][i - 1];
  scanf("%d", &q);
  for (int T = 1; T <= q; T++) {
    scanf("%d", &k);
    for (int i = 1; i <= k; i++) scanf("%d", s + i), tf[s[i]] = true;
    sort(s + 1, s + k + 1, cmp);
    top = 0;
    st[++top] = 0;
    for (int i = 1; i <= k; i++) {
      int t = LCA(s[i], st[top]);
      if (t != st[top]) {
        while (dfn[t] <= dfn[st[top - 1]]) {
          if (lst[st[top - 1]] < T)
            g[st[top - 1]].clear(), lst[st[top - 1]] = T;
          g[st[top - 1]].push_back({st[top], dep[st[top]] - dep[st[top - 1]]});
          top--;
        }
        if (t != st[top]) {
          if (lst[t] < T) g[t].clear(), lst[t] = T;
          g[t].push_back({st[top], dep[st[top]] - dep[t]});
          st[top] = t;
        }
      }
      st[++top] = s[i];
    }
    while (top > 1) {
      if (lst[st[top - 1]] < T) g[st[top - 1]].clear(), lst[st[top - 1]] = T;
      g[st[top - 1]].push_back({st[top], dep[st[top]] - dep[st[top - 1]]});
      top--;
    }
    jud = true;
    DP(st[1]);
    if (!jud)
      printf("-1\n");
    else
      printf("%d\n", f[st[1]]);
    for (int i = 1; i <= k; i++) tf[s[i]] = false;
  }
  return 0;
}
