#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O2")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long int N = 1e5 + 10, mod = 1e9 + 7, inf = 1e18, dlt = 12251;
int h[N], tin[N], dp[N];
int par[N][20], t, ans;
vector<int> adj[N], g[N];
bool mark[N], vis[N], visi[N];
void pre(int v, int p) {
  t++;
  tin[v] = t;
  for (int u : adj[v]) {
    if (u == p) continue;
    h[u] = h[v] + 1;
    par[u][0] = v;
    pre(u, v);
  }
  t++;
}
inline int getpar(int v, int k) {
  if (h[v] < k) return 0;
  for (int i = 19; i >= 0; i--) {
    if (k >= (1 << i)) {
      v = par[v][i];
      k -= (1 << i);
    }
  }
  return v;
}
inline int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  v = getpar(v, h[v] - h[u]);
  if (u == v) return u;
  for (int i = 19; i >= 0; i--) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
void dfs(int v, int p) {
  visi[v] = 1;
  int cnt = 0;
  for (int u : g[v]) {
    if (u == p) continue;
    dfs(u, v);
    dp[v] += dp[u];
    if (dp[u]) cnt++;
  }
  if (!mark[v]) {
    if (dp[v] > 1) {
      dp[v] = 0;
      ans++;
    }
    return;
  }
  if (dp[v]) ans += cnt;
  dp[v] = 1;
  return;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  pre(1, -1);
  for (int j = 1; j < 20; j++) {
    for (int i = 1; i < n + 1; i++) {
      if (h[i] < (1 << j)) continue;
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int k;
    vector<pair<int, int> > ve;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int u;
      cin >> u;
      ve.push_back({tin[u], u});
      mark[u] = 1;
      vis[u] = 1;
    }
    sort(ve.begin(), ve.end());
    bool f = 1;
    mark[ve[0].second] = 1;
    for (int i = 1; i < k; i++) {
      if (mark[par[ve[i].second][0]]) {
        cout << -1 << '\n';
        f = 0;
        break;
      }
      int w = lca(ve[i].second, ve[i - 1].second);
      if (!vis[w]) {
        ve.push_back({tin[w], w});
        vis[w] = 1;
      }
    }
    if (!f) {
      for (pair<int, int> u : ve) {
        mark[u.second] = 0;
        vis[u.second] = 0;
      }
      continue;
    }
    sort(ve.begin(), ve.end());
    int sz = ve.size();
    for (int i = 1; i < sz; i++) {
      int w = lca(ve[i].second, ve[i - 1].second);
      g[ve[i].second].push_back(w);
      g[w].push_back(ve[i].second);
    }
    dfs(ve[0].second, -1);
    cout << ans << '\n';
    ans = 0;
    for (pair<int, int> u : ve) {
      mark[u.second] = 0;
      g[u.second].clear();
      dp[u.second] = 0;
      vis[u.second] = 0;
      visi[u.second] = 0;
    }
  }
}
