There are n cities in Treeland connected with n - 1 bidirectional roads in such that a way that any city is reachable from any other; in other words, the graph of cities and roads is a tree. Treeland is preparing for a seasonal virus epidemic, and currently, they are trying to evaluate different infection scenarios.

In each scenario, several cities are initially infected with different virus species. Suppose that there are k_i virus species in the i-th scenario. Let us denote v_j the initial city for the virus j, and s_j the propagation speed of the virus j. The spread of the viruses happens in turns: first virus 1 spreads, followed by virus 2, and so on. After virus k_i spreads, the process starts again from virus 1.

A spread turn of virus j proceeds as follows. For each city x not infected with any virus at the start of the turn, at the end of the turn it becomes infected with virus j if and only if there is such a city y that:

  * city y was infected with virus j at the start of the turn;
  * the path between cities x and y contains at most s_j edges;
  * all cities on the path between cities x and y (excluding y) were uninfected with any virus at the start of the turn.



Once a city is infected with a virus, it stays infected indefinitely and can not be infected with any other virus. The spread stops once all cities are infected.

You need to process q independent scenarios. Each scenario is described by k_i virus species and m_i important cities. For each important city determine which the virus it will be infected by in the end.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of cities in Treeland.

The following n - 1 lines describe the roads. The i-th of these lines contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n) — indices of cities connecting by the i-th road. It is guaranteed that the given graph of cities and roads is a tree.

The next line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of infection scenarios. q scenario descriptions follow.

The description of the i-th scenario starts with a line containing two integers k_i and m_i (1 ≤ k_i, m_i ≤ n) — the number of virus species and the number of important cities in this scenario respectively. It is guaranteed that ∑_{i = 1}^ q k_i and ∑_{i = 1}^ q m_i do not exceed 2 ⋅ 10^5.

The following k_i lines describe the virus species. The j-th of these lines contains two integers v_j and s_j (1 ≤ v_j ≤ n, 1 ≤ s_j ≤ 10^6) – the initial city and the propagation speed of the virus species j. It is guaranteed that the initial cities of all virus species within a scenario are distinct.

The following line contains m_i distinct integers u_1, …, u_{m_i} (1 ≤ u_j ≤ n) — indices of important cities.

Output

Print q lines. The i-th line should contain m_i integers — indices of virus species that cities u_1, …, u_{m_i} are infected with at the end of the i-th scenario.

Example

Input


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


Output


1 2
1 1
1 1 1
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005, maxk = 25;
int n, Q, cnt, stp, top, Ps;
int p[maxn], fore[maxn][maxk], dep[maxn], dfn[maxn], ok[maxn], stk[maxn],
    ans[maxn], fa[maxn], f[maxn], pos[maxn], spd[maxn], P[maxn];
vector<int> v[maxn];
inline int cmp(int x, int y) { return dfn[x] < dfn[y]; }
void dfs(int x, int last) {
  dep[x] = dep[last] + 1, fore[x][0] = last, dfn[x] = ++cnt;
  for (int i = 1; i <= 20; i++) fore[x][i] = fore[fore[x][i - 1]][i - 1];
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i];
    if (y == last) continue;
    dfs(y, x);
  }
}
int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  for (int i = 20; i >= 0; i--)
    if (dep[fore[a][i]] >= dep[b]) a = fore[a][i];
  if (a == b) return a;
  for (int i = 20; i >= 0; i--)
    if (fore[a][i] != fore[b][i]) a = fore[a][i], b = fore[b][i];
  return fore[a][0];
}
inline void clr(int x) { f[x] = fa[x] = 0, P[++Ps] = x; }
inline int calc(int a, int b) {
  int z = lca(pos[a], b), d = dep[pos[a]] + dep[b] - 2 * dep[z];
  return ((d + spd[a] - 1) / spd[a]);
}
int update(int now, int a, int b) {
  if (a == 0 || b == 0) return a + b;
  int da = calc(a, now), db = calc(b, now);
  if (da != db) return da < db ? a : b;
  return a < b ? a : b;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y), v[y].push_back(x);
  }
  dfs(1, 0);
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int k, m, x;
    stp++, cnt = Ps = 0;
    scanf("%d%d", &k, &m);
    for (int j = 1; j <= k; j++)
      scanf("%d%d", &pos[j], &spd[j]), ok[pos[j]] = stp, p[++cnt] = pos[j];
    for (int j = 1; j <= m; j++) scanf("%d", &ans[j]), p[++cnt] = ans[j];
    sort(p + 1, p + 1 + cnt, cmp);
    top = 0, stk[++top] = 1, clr(1);
    for (int j = 1; j <= cnt; j++) {
      int x = p[j];
      if (x == 1) continue;
      int z = lca(x, stk[top]);
      if (z != stk[top]) {
        while (top > 0 && dfn[z] < dfn[stk[top - 1]])
          fa[stk[top]] = stk[top - 1], top--;
        if (dfn[z] > dfn[stk[top - 1]])
          fa[stk[top]] = z, top--, stk[++top] = z, clr(z);
        else
          fa[stk[top]] = stk[top - 1], top--;
      }
      stk[++top] = x, clr(x);
    }
    while (top > 1) fa[stk[top]] = stk[top - 1], top--;
    sort(P + 1, P + 1 + Ps, cmp), Ps = unique(P + 1, P + 1 + Ps) - P - 1;
    for (int j = k; j >= 1; j--) f[pos[j]] = j;
    for (int j = Ps; j >= 1; j--)
      if (fa[P[j]]) f[fa[P[j]]] = update(fa[P[j]], f[fa[P[j]]], f[P[j]]);
    for (int j = 1; j <= Ps; j++)
      if (fa[P[j]]) f[P[j]] = update(P[j], f[P[j]], f[fa[P[j]]]);
    for (int j = 1; j <= m; j++) printf("%d%c", f[ans[j]], j == m ? '\n' : ' ');
  }
  return 0;
}
