#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e5 + 10;
map<int, int> pp[SIZE];
set<int> cc[SIZE];
map<int, int>* ptr[SIZE];
vector<int> e[SIZE];
int gn[SIZE], an[SIZE];
void dfs(int x, int lt) {
  ptr[x] = &(pp[x]);
  set<int> cr;
  for (int i = 0; i < (((int)(e[x]).size())); ++i) {
    int y = e[x][i];
    if (y == lt) continue;
    dfs(y, x);
    if (((int)(*ptr[x]).size()) < ((int)(*ptr[y]).size())) swap(ptr[x], ptr[y]);
    for (map<int, int>::iterator it = ptr[y]->begin(); it != ptr[y]->end();
         it++) {
      int me = it->first;
      if (ptr[x]->count(me)) {
        cr.insert(me);
      }
      (*ptr[x])[me] += it->second;
    }
  }
  for (set<int>::iterator it = cc[x].begin(); it != cc[x].end(); it++) {
    if (ptr[x]->count(*it)) {
      cr.erase(*it);
      an[*it] += (*ptr[x])[*it];
    }
    (*ptr[x])[*it] = 1;
  }
  for (set<int>::iterator it = cr.begin(); it != cr.end(); it++) {
    if (ptr[x]->count(*it)) {
      ptr[x]->erase(*it);
      an[*it]++;
    }
  }
}
int main() {
  int(n);
  scanf("%d", &n);
  for (int i = (1); i < (n); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  int(q);
  scanf("%d", &q);
  for (int i = 0; i < (q); ++i) {
    scanf("%d", &(gn[i]));
    for (int j = 0; j < (gn[i]); ++j) {
      int(x);
      scanf("%d", &x);
      x--;
      cc[x].insert(i);
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (((int)(e[i]).size())); ++j) {
      int y = e[i][j];
      if (y < i) continue;
      int x = i;
      if (((int)(cc[x]).size()) > ((int)(cc[y]).size())) swap(x, y);
      for (set<int>::iterator it = cc[x].begin(); it != cc[x].end(); it++) {
        if (an[*it] == -1) continue;
        if (cc[y].count(*it)) an[*it] = -1000000000;
      }
    }
  }
  dfs(0, 0);
  for (int i = 0; i < (q); ++i) printf("%d\n", max(-1, an[i]));
  return 0;
}
