#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 1e9;
const long long INF64 = 1e18;
const double EPS = 1e-9;
const double PI = acos(-1);
const long long MD = 1951513443;
const long long T = 26;
const int N = 100100;
const int M = 340;
int n, q, ans[N];
vector<int> g[N];
vector<int> a[N];
multiset<int> *s[N];
void dfs(int v, int p) {
  vector<int> aa;
  for (int i = 0; i < int(int((g[v]).size())); i++) {
    int u = g[v][i];
    if (u == p) continue;
    dfs(u, v);
    if (int((*s[v]).size()) < int((*s[u]).size())) swap(s[v], s[u]);
    multiset<int>::iterator it = s[u]->begin();
    for (int j = 0; j < int(s[u]->size()); j++) {
      if (s[v]->find(*it) != s[v]->end()) aa.push_back(*it);
      s[v]->insert(*it);
      it++;
    }
  }
  for (int i = 0; i < int(int((a[v]).size())); i++) {
    int k = a[v][i];
    if (s[v]->find(k) != s[v]->end()) {
      if (ans[k] != -1) ans[k] += s[v]->count(k);
      s[v]->erase(k);
    }
  }
  for (int i = 0; i < int(int((aa).size())); i++) {
    int k = aa[i];
    if (s[v]->find(k) != s[v]->end()) {
      if (ans[k] == -1) {
        s[v]->erase(k);
      } else {
        ans[k]++;
        s[v]->erase(k);
      }
    }
  }
  for (int i = 0; i < int(int((a[v]).size())); i++) {
    if (p != -1) {
      int j = int(lower_bound((a[p]).begin(), (a[p]).end(), a[v][i]) -
                  a[p].begin());
      if (j < int((a[p]).size()) && a[v][i] == a[p][j]) {
        ans[a[v][i]] = -1;
        s[v]->erase(a[v][i]);
      } else
        s[v]->insert(a[v][i]);
    } else
      s[v]->insert(a[v][i]);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) s[i] = new multiset<int>;
  for (int i = 0; i < int(n - 1); i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    g[first].push_back(second);
    g[second].push_back(first);
  }
  cin >> q;
  for (int u = 0; u < int(q); u++) {
    int k;
    scanf("%d", &k);
    for (int i = 0; i < int(k); i++) {
      int first;
      scanf("%d", &first);
      a[first].push_back(u);
    }
  }
  for (int i = 1; i <= n; i++) sort((a[i]).begin(), (a[i]).end());
  dfs(1, -1);
  for (int i = 0; i < int(q); i++) printf("%d\n", ans[i]);
  return 0;
}
