Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daughter's marriage, reforms must be finished as soon as possible.

The kingdom currently consists of n cities. Cities are connected by n - 1 bidirectional road, such that one can get from any city to any other city. As the King had to save a lot, there is only one path between any two cities.

What is the point of the reform? The key ministries of the state should be relocated to distinct cities (we call such cities important). However, due to the fact that there is a high risk of an attack by barbarians it must be done carefully. The King has made several plans, each of which is described by a set of important cities, and now wonders what is the best plan.

Barbarians can capture some of the cities that are not important (the important ones will have enough protection for sure), after that the captured city becomes impassable. In particular, an interesting feature of the plan is the minimum number of cities that the barbarians need to capture in order to make all the important cities isolated, that is, from all important cities it would be impossible to reach any other important city.

Help the King to calculate this characteristic for each of his plan.

Input

The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cities in the kingdom.

Each of the next n - 1 lines contains two distinct integers ui, vi (1 ≤ ui, vi ≤ n) — the indices of the cities connected by the i-th road. It is guaranteed that you can get from any city to any other one moving only along the existing roads.

The next line contains a single integer q (1 ≤ q ≤ 100 000) — the number of King's plans.

Each of the next q lines looks as follows: first goes number ki — the number of important cities in the King's plan, (1 ≤ ki ≤ n), then follow exactly ki space-separated pairwise distinct numbers from 1 to n — the numbers of important cities in this plan.

The sum of all ki's does't exceed 100 000.

Output

For each plan print a single integer — the minimum number of cities that the barbarians need to capture, or print  - 1 if all the barbarians' attempts to isolate important cities will not be effective.

Examples

Input

4
1 3
2 3
4 3
4
2 1 2
3 2 3 4
3 1 2 4
4 1 2 3 4


Output

1
-1
1
-1


Input

7
1 2
2 3
3 4
1 5
5 6
5 7
1
4 2 4 6 7


Output

2

Note

In the first sample, in the first and the third King's plan barbarians can capture the city 3, and that will be enough. In the second and the fourth plans all their attempts will not be effective.

In the second sample the cities to capture are 3 and 5.
#include <bits/stdc++.h>
using namespace std;
long long dfn[1000000], siz[1000000], dep[1000000], to[1000000], nxt[1000000],
    head[1000000], w[1000000], cnt, tot;
long long son[1000000], top[1000000], z[1000000], mn[1000000], a[1000000],
    f[1000000], b[1000000], fl[1000000], tt, n, m, k, inf = 999999999;
vector<long long> v[1000000];
bool cmp(long long x, long long y) { return dfn[x] < dfn[y]; }
void add(long long x, long long y) {
  to[++cnt] = y;
  nxt[cnt] = head[x];
  head[x] = cnt;
}
void dfs1(long long x, long long fa) {
  dfn[x] = ++tot;
  siz[x] = 1;
  dep[x] = dep[fa] + 1;
  f[x] = fa;
  for (long long i = head[x]; i; i = nxt[i]) {
    if (to[i] == fa) continue;
    dfs1(to[i], x);
    siz[x] += siz[to[i]];
    if (siz[son[x]] < siz[to[i]]) son[x] = to[i];
  }
}
void dfs2(long long x, long long fa) {
  top[x] = fa;
  if (son[x]) dfs2(son[x], fa);
  for (long long i = head[x]; i; i = nxt[i]) {
    if (to[i] == f[x] || to[i] == son[x]) continue;
    dfs2(to[i], to[i]);
  }
}
long long lca(long long x, long long y) {
  while (top[x] != top[y])
    dep[top[x]] > dep[top[y]] ? x = f[top[x]] : y = f[top[y]];
  return dep[x] > dep[y] ? y : x;
}
long long dp(long long x) {
  long long ans = 0, sum = 0;
  for (auto u : v[x]) ans += dp(u), sum += b[u];
  if (fl[x])
    b[x] = 1, ans += sum;
  else if (sum > 1)
    b[x] = 0, ans++;
  else
    b[x] = sum;
  return v[x].clear(), ans;
}
long long build() {
  for (long long i = 1; i <= k; i++)
    if (fl[f[a[i]]]) return -1;
  sort(a + 1, a + k + 1, cmp);
  for (long long i = 1; i <= k; i++) {
    if (!tt) {
      z[++tt] = a[i];
      continue;
    }
    long long la = lca(a[i], z[tt]);
    while (dep[z[tt - 1]] >= dep[la]) v[z[tt - 1]].push_back(z[tt]), tt--;
    if (la != z[tt]) v[la].push_back(z[tt]), z[tt] = la;
    z[++tt] = a[i];
  }
  while (tt) v[z[tt - 1]].push_back(z[tt]), tt--;
  return dp(z[1]);
}
signed main() {
  long long x, y, z;
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++)
    scanf("%lld%lld", &x, &y), add(x, y), add(y, x);
  dfs1(1, 0);
  dfs2(1, 1);
  scanf("%lld", &m);
  while (m--) {
    scanf("%lld", &k);
    for (long long i = 1; i <= k; i++) scanf("%lld", &a[i]), fl[a[i]] = 1;
    printf("%lld\n", build());
    for (long long i = 1; i <= k; i++) fl[a[i]] = 0;
  }
  return 0;
}
