#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long Mod = 1e9 + 7;
const int N = 1e5 + 7;
int n, q, u, v, k;
vector<int> G[N];
int inTime[N], tme, par[20][N], dep[N], used[N], V[N], xhr[N];
int info[N];
void dfs(int s, int p) {
  inTime[s] = ++tme;
  for (auto it : G[s]) {
    if (it != p) {
      par[0][it] = s;
      dep[it] = dep[s] + 1;
      dfs(it, s);
    }
  }
}
void pre() {
  for (int k = 1; k < 20; k++) {
    for (int i = 1; i <= n; i++) par[k][i] = par[k - 1][par[k - 1][i]];
  }
}
int LCA(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  int diff = dep[v] - dep[u];
  for (int i = 0; i < 20; i++)
    if (diff & (1 << i)) v = par[i][v];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--) {
    if (par[i][u] != par[i][v]) {
      u = par[i][u];
      v = par[i][v];
    }
  }
  return par[0][u];
}
bool cmp(int u, int v) { return inTime[u] < inTime[v]; }
int Root, Ans, fat[N], qzi;
vector<pair<int, int> > g[N];
void findAns(int s, int p) {
  info[s] = 0;
  int ec = 0;
  for (auto it : g[s]) {
    if (it.first == p) continue;
    if (xhr[s] == qzi && xhr[it.first] == qzi && it.second == 1) Ans = -N;
    findAns(it.first, s);
    if (info[it.first]) ec++;
  }
  if (ec > 1) {
    if (xhr[s] == qzi) {
      Ans += ec;
      info[s] = 1;
    } else {
      Ans++;
    }
  } else if (ec == 1) {
    if (xhr[s] == qzi) {
      Ans++;
    }
    info[s] = 1;
  } else {
    info[s] = (xhr[s] == qzi);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, -1);
  pre();
  cin >> q;
  for (int z = 1; z <= q; z++) {
    qzi = z;
    cin >> k;
    vector<int> node(k);
    for (int i = 0; i < k; i++) cin >> node[i];
    for (auto it : node) xhr[it] = z;
    sort((node).begin(), (node).end(), cmp);
    used[node[0]] = z;
    V[1] = node[0];
    int o = 1;
    for (int i = 1; i < k; i++) {
      int ec = LCA(node[i], node[i - 1]);
      if (used[node[i]] != z) {
        ++o;
        V[o] = node[i];
        used[node[i]] = z;
      }
      if (used[ec] != z) {
        used[ec] = z;
        ++o;
        V[o] = ec;
      }
    }
    sort(V + 1, V + o + 1, cmp);
    Root = V[1];
    for (int i = 2; i <= o; i++) {
      fat[V[i]] = LCA(V[i], V[i - 1]);
    }
    for (int i = 2; i <= o; i++) {
      int oi = dep[V[i]] - dep[fat[V[i]]];
      g[fat[V[i]]].push_back(make_pair((V[i]), (oi)));
      g[V[i]].push_back(make_pair((fat[V[i]]), (oi)));
    }
    Ans = 0;
    findAns(Root, -1);
    Ans = max(Ans, -1);
    cout << Ans << '\n';
    for (int i = 1; i <= o; i++) g[V[i]].clear();
  }
  return 0;
}
