#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, m;
vector<int> g[MAXN];
int parent[MAXN];
void dfs(int cur) {
  for (int nx : g[cur]) {
    if (nx != parent[cur]) {
      parent[nx] = cur;
      dfs(nx);
    }
  }
}
int on[MAXN];
vector<int> v;
vector<int> pt[MAXN];
map<int, int> mp[MAXN];
int ans[MAXN];
void answer(int cur) {
  for (int nx : g[cur]) {
    if (nx != parent[cur]) {
      answer(nx);
    }
  }
  for (int x : pt[cur]) {
    mp[cur][x] = 1;
  }
  set<int> cleared;
  for (int nx : g[cur]) {
    if (nx != parent[cur]) {
      if (mp[cur].size() < mp[nx].size()) swap(mp[cur], mp[nx]);
      for (auto x : mp[nx]) {
        if ((mp[cur][x.first] += x.second) > 1) {
          cleared.insert(x.first);
        }
      }
    }
  }
  for (int x : pt[cur]) {
    auto it = mp[cur].find(x);
    if (it->second > 1) {
      ans[x] += it->second - 1;
      it->second = 1;
      cleared.erase(x);
    }
  }
  for (int x : cleared) {
    mp[cur].erase(x);
    ans[x]++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, a, b; i < n; i++) {
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1);
  scanf("%d", &m);
  for (int i = 1, a; i <= m; i++) {
    scanf("%d", &a);
    v.resize(a);
    for (int k = 0, b; k < a; k++) {
      scanf("%d", &b);
      on[b] = true;
      v[k] = b;
    }
    bool ok = true;
    for (int k = 0; k < a && ok; k++)
      if (on[parent[v[k]]]) ok = false;
    if (ok) {
      for (int k = 0; k < a; k++) pt[v[k]].push_back(i);
    } else {
      ans[i] = -1;
    }
    for (int k = 0; k < a; k++) on[v[k]] = false;
  }
  answer(1);
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
