#include <bits/stdc++.h>
using namespace std;
int N, Q;
vector<vector<int> > adj;
vector<set<int> > grp;
vector<int> dep, tin, tout;
vector<vector<int> > par;
int num = 0;
void dfs(int now, int bf) {
  tin[now] = num++;
  if (bf != -1) par[now][0] = bf;
  for (int i = 1; i < 18; i++) {
    int tmp = par[now][i - 1];
    if (tmp == -1) break;
    par[now][i] = par[tmp][i - 1];
  }
  for (int i = 0; i < adj[now].size(); i++) {
    int nxt = adj[now][i];
    if (nxt == bf) continue;
    dep[nxt] = dep[now] + 1;
    dfs(nxt, now);
  }
  tout[now] = num - 1;
}
void preproc() {
  dep.resize(N);
  tin.resize(N);
  tout.resize(N);
  par = vector<vector<int> >(N, vector<int>(18, -1));
  dep[0] = 0;
  dfs(0, -1);
}
int lca(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  int dx = dep[y] - dep[x];
  for (int i = 0; i < 18; i++) {
    if (dx & (1 << i)) y = par[y][i];
  }
  if (x == y) return x;
  for (int i = 18; i--;) {
    if (par[x][i] != par[y][i]) {
      x = par[x][i];
      y = par[y][i];
    }
  }
  return par[x][0];
}
int K;
vector<int> V;
vector<vector<int> > adj2;
map<int, int> imp;
bool cmp(int a, int b) { return tin[a] < tin[b]; }
vector<int> dp, rem;
void dfs2(int now, int bf) {
  int cnt = 0;
  for (int i = 0; i < adj2[now].size(); i++) {
    int nxt = adj2[now][i];
    if (nxt == bf) continue;
    dfs2(nxt, now);
    dp[now] += dp[nxt];
    if (rem[nxt] > 0) cnt++;
  }
  if (imp[V[now]]) {
    dp[now] += cnt;
    rem[now] = 1;
  } else {
    if (cnt > 1) {
      dp[now]++;
      rem[now] = 0;
    } else
      rem[now] = cnt;
  }
}
void get_dp() {
  dp.clear();
  rem.clear();
  dp = rem = vector<int>(V.size(), 0);
  dfs2(0, -1);
}
void solve() {
  sort(V.begin(), V.end(), cmp);
  for (int i = 0; i < K - 1; i++) {
    int x = lca(V[i], V[i + 1]);
    V.push_back(x);
  }
  sort(V.begin(), V.end(), cmp);
  V.resize(unique(V.begin(), V.end()) - V.begin());
  stack<int> st;
  adj2.clear();
  adj2.resize(V.size());
  for (int i = V.size(); i--;) {
    while (!st.empty() && tin[V[st.top()]] <= tout[V[i]]) {
      adj2[i].push_back(st.top());
      adj2[st.top()].push_back(i);
      st.pop();
    }
    st.push(i);
  }
  bool ok = true;
  for (int i = 0; i < V.size(); i++) {
    for (int j = 0; j < adj2[i].size(); j++) {
      int k = adj2[i][j];
      int u = V[i], v = V[k];
      if (!imp[u] || !imp[v]) continue;
      if (grp[u].find(v) != grp[u].end()) {
        ok = false;
        break;
      }
    }
  }
  if (!ok) {
    printf("-1\n");
    return;
  }
  get_dp();
  printf("%d\n", dp[0]);
}
int main() {
  scanf("%d", &N);
  adj.resize(N);
  grp.resize(N);
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    grp[u].insert(v);
    grp[v].insert(u);
  }
  preproc();
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++) {
    scanf("%d", &K);
    V.clear();
    V.resize(K);
    imp.clear();
    for (int j = 0; j < K; j++) {
      scanf("%d", &V[j]);
      V[j]--;
      imp[V[j]] = 1;
    }
    solve();
  }
}
