#include <bits/stdc++.h>
using namespace std;
struct node {
  int e;
  long long dis;
};
bool qaq;
int n, m;
int tot;
vector<int> g[100005];
vector<node> fake_g[100005];
int dfn[100005];
long long dep[100005];
int dp[100005][25];
int nk;
int k[100005];
int sta[100005];
int t[100005];
long long dp_summ[100005];
int top = 1;
bool f[100005];
bool up_f[100005];
void read(int &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while ('0' > c || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  x *= f;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
bool cmp(int a, int b) { return dfn[a] < dfn[b]; }
void dfs(int u, int fat) {
  dfn[u] = ++tot;
  dep[u] = dep[fat] + 1;
  for (int i = 1; i <= 20; i++) dp[u][i] = dp[dp[u][i - 1]][i - 1];
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v != fat) {
      dp[v][0] = u;
      dfs(v, u);
    }
  }
}
void solve_lca(int u, int v, int &lca) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (dep[dp[u][i]] >= dep[v]) u = dp[u][i];
  if (u == v) {
    lca = u;
    return;
  }
  for (int i = 20; i >= 0; i--) {
    if (dp[u][i] != dp[v][i]) {
      u = dp[u][i];
      v = dp[v][i];
    }
  }
  lca = dp[u][0];
  return;
}
int f_abs(int x) {
  if (x < 0) return -x;
  return x;
}
void insert(int x) {
  if (!top) {
    sta[++top] = x;
    return;
  }
  int lca;
  solve_lca(x, sta[top], lca);
  while (dep[sta[top - 1]] > dep[lca] && top > 1) {
    fake_g[sta[top - 1]].push_back(
        (node){sta[top], f_abs(dep[sta[top]] - dep[sta[top - 1]])});
    fake_g[sta[top]].push_back(
        (node){sta[top - 1], f_abs(dep[sta[top]] - dep[sta[top - 1]])});
    top--;
  }
  if (dep[lca] < dep[sta[top]]) {
    fake_g[lca].push_back((node){sta[top], f_abs(dep[sta[top]] - dep[lca])});
    fake_g[sta[top]].push_back((node){lca, f_abs(dep[sta[top]] - dep[lca])});
    top--;
  }
  if (!top || dep[sta[top]] < dep[lca]) {
    sta[++top] = lca;
  }
  sta[++top] = x;
}
void build() {
  top = 0;
  if (k[1] != 1)
    sta[++top] = 1;
  else
    sta[top] = 0;
  for (int i = 1; i <= nk; i++) {
    insert(k[i]);
    f[k[i]] = 1;
  }
  while (top > 1) {
    fake_g[sta[top]].push_back(
        (node){sta[top - 1], f_abs(dep[sta[top]] - dep[sta[top - 1]])});
    fake_g[sta[top - 1]].push_back(
        (node){sta[top], f_abs(dep[sta[top]] - dep[sta[top - 1]])});
    top--;
  }
}
void solve_dp(int u, int fa) {
  int tem = 0;
  dp_summ[u] = 0;
  if (f[u] == 1) {
    for (int i = 0; i < fake_g[u].size(); i++) {
      int v = fake_g[u][i].e;
      if (v != fa) {
        solve_dp(v, u);
        dp_summ[u] += dp_summ[v];
        if (f[v] == 1 && dep[v] - dep[u] == 1) qaq = 1;
        if (up_f[v]) dp_summ[u]++;
        up_f[v] = 0;
        f[v] = 0;
      }
    }
    up_f[u] = 1;
    f[u] = 1;
  } else {
    for (int i = 0; i < fake_g[u].size(); i++) {
      int v = fake_g[u][i].e;
      if (v != fa) {
        solve_dp(v, u);
        dp_summ[u] += dp_summ[v];
        if (up_f[v]) tem++;
        up_f[v] = 0;
        f[v] = 0;
      }
    }
    if (tem > 1) {
      dp_summ[u]++;
      up_f[u] = 0;
    } else if (tem == 1) {
      up_f[u] = 1;
    }
  }
  fake_g[u].clear();
}
int main() {
  read(n);
  for (int i = 1, x, y; i < n; i++) {
    read(x);
    read(y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  read(m);
  for (int i = 1; i <= m; i++) {
    read(nk);
    for (int j = 1; j <= nk; j++) read(k[j]);
    sort(k + 1, k + nk + 1, cmp);
    top = 1;
    sta[1] = 1;
    qaq = 0;
    build();
    solve_dp(1, 0);
    up_f[1] = 0;
    f[1] = 0;
    if (qaq)
      write(-1);
    else
      write(dp_summ[1]);
    putchar('\n');
  }
  return 0;
}
