#include <bits/stdc++.h>
using namespace std;
const int INF = (-1u) / 2;
const long long int INF2 = (-1ull) / 2;
int a, b, i, d[1011000], j, k, n, m, timer = 0, l, r, x, y, us[1000100],
                                     hv[100110];
int c[1011000], cnt = 0, fl = 0, a2, a3 = -1000000, ans = 0;
vector<int> g[100110], g2[100110], vv;
int p[100110][22], ord[100110], tin[100110], tout[100110];
void deb(bool a) {
  if (a) return;
  printf("PROGRAM TERMINATED\n");
  exit(0);
}
void dfs1(int v, int pv) {
  p[v][0] = (pv == -1) ? v : pv;
  tin[v] = ++cnt;
  ord[v] = tin[v];
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == pv) continue;
    d[to] = d[v] + 1;
    dfs1(to, v);
  }
  tout[v] = cnt;
}
bool cmp(int a, int b) { return (ord[a] <= ord[b]); }
int take_par(int v, int k) {
  if (k == 0) return v;
  for (int i = 20; i >= 0; i--) {
    if ((1 << i) <= k) {
      k -= (1 << i);
      v = p[v][i];
    }
  }
  return v;
}
int lca(int a, int b) {
  if (d[a] < d[b]) swap(a, b);
  a = take_par(a, d[a] - d[b]);
  if (a == b) return a;
  for (int i = 20; i >= 0; i--) {
    if (p[a][i] != p[b][i]) {
      a = p[a][i];
      b = p[b][i];
    }
  }
  deb(p[a][0] == p[b][0]);
  return p[a][0];
}
bool is_par(int p, int v) {
  deb(ord[v] != tin[p]);
  if (ord[v] <= tout[p] && ord[v] > tin[p]) return 1;
  return 0;
}
int dfs(int v) {
  if (us[v] == ans) {
    for (int i = 0; i < g2[v].size(); i++) {
      if (dfs(g2[v][i])) fl++;
    }
    return 1;
  } else {
    int son = 0;
    for (int i = 0; i < g2[v].size(); i++) {
      if (dfs(g2[v][i])) {
        son++;
        if (son == 2) fl++;
      }
    }
    return (son == 1);
  }
}
int solve() {
  ans++;
  if (vv.size()) vv.clear();
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &a);
    us[a] = ans;
    hv[a] = ans;
    vv.push_back(a);
  }
  if (k == 1) return 0;
  sort(vv.begin(), vv.end(), cmp);
  deb(ord[vv[0]] < ord[vv[1]]);
  for (int i = 0; i < k; i++) {
    if (vv[i] != 1 && us[p[vv[i]][0]] == ans) return -1;
  }
  for (int i = 0; i < k - 1; i++) {
    a = lca(vv[i], vv[i + 1]);
    if (hv[a] != ans) vv.push_back(a);
    hv[a] = ans;
  }
  sort(vv.begin(), vv.end(), cmp);
  stack<int> s;
  for (int i = 0; i < vv.size(); i++) {
    while (!s.empty() && !is_par(s.top(), vv[i])) s.pop();
    if (!s.empty()) {
      g2[s.top()].push_back(vv[i]);
    }
    s.push(vv[i]);
  }
  fl = 0;
  dfs(vv[0]);
  for (int i = 0; i < vv.size(); i++)
    if (g2[vv[i]].size()) g2[vv[i]].clear();
  return fl;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(1, -1);
  for (j = 1; j <= 20; j++) {
    for (i = 1; i <= n; i++) {
      p[i][j] = p[p[i][j - 1]][j - 1];
    }
  }
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    printf("%d\n", solve());
  }
  return 0;
}
