#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 1e6 + 10;
struct Edge {
  int to, next;
} edge[2 * MAXN];
int head[MAXN], cnt;
int st[MAXN][21], deep[MAXN], dfn[MAXN], tim;
void Init() {
  cnt = 0;
  memset(head, -1, sizeof(head));
}
void addedge(int u, int v) {
  edge[cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}
void dfs(int u, int far) {
  st[u][0] = far;
  dfn[u] = ++tim;
  deep[u] = deep[far] + 1;
  for (int i = 1; (1 << i) <= deep[u]; i++) st[u][i] = st[st[u][i - 1]][i - 1];
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (v != far) dfs(v, u);
  }
}
int lca(int u, int v) {
  if (deep[u] > deep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (deep[u] <= deep[v] - (1 << i)) v = st[v][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (st[u][i] == st[v][i]) continue;
    u = st[u][i], v = st[v][i];
  }
  return st[u][0];
}
vector<int> G[MAXN];
int stk[MAXN], top, mk[MAXN];
int n, q, k, h[MAXN], ans, dp[MAXN];
int dis(int u, int v) { return deep[u] + deep[v] - 2 * deep[lca(u, v)]; }
void solve(int u, int fa) {
  if (ans == -1) return;
  int num = 0;
  for (int i = 0; i < (int)G[u].size(); i++) {
    int v = G[u][i];
    if (v != fa) {
      solve(v, u);
      if (ans == -1) return;
      if (mk[u] && mk[v] && dis(u, v) == 1) return ans = -1, void();
      if (dp[v]) num++;
    }
  }
  if (mk[u]) {
    if (num == 0)
      dp[u] = 1;
    else if (num == 1)
      ans++, dp[u] = 1;
    else
      ans = ans + num, dp[u] = 1;
  } else {
    if (num == 0)
      dp[u] = 0;
    else if (num == 1)
      dp[u] = 1;
    else
      ans++, dp[u] = 0;
  }
}
int main(void) {
  Init();
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v), addedge(v, u);
  }
  dfs(1, 0);
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &k);
    for (int i = 0; i < k; i++) scanf("%d", &h[i]), mk[h[i]] = 1;
    stk[top = 1] = 1;
    G[1].clear();
    sort(h, h + k, [](int x, int y) { return dfn[x] < dfn[y]; });
    for (int i = 0; i < k; i++) {
      if (h[i] == 1) continue;
      int com = lca(stk[top], h[i]);
      if (com != stk[top]) {
        while (dfn[com] < dfn[stk[top - 1]])
          G[stk[top - 1]].push_back(stk[top]), top--;
        if (dfn[com] > dfn[stk[top - 1]]) {
          G[com].clear();
          G[com].push_back(stk[top]);
          stk[top] = com;
        } else
          G[com].push_back(stk[top--]);
      }
      stk[++top] = h[i];
      G[h[i]].clear();
    }
    while (top >= 2) G[stk[top - 1]].push_back(stk[top]), top--;
    ans = 0;
    solve(1, 0);
    printf("%d\n", ans);
    for (int i = 0; i < k; i++) mk[h[i]] = 0;
  }
  return 0;
}
