Problem: 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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + ch - '0', ch = getchar();
  return f * s;
}
struct edge {
  int to, lt;
} e[400010 << 1];
int in[400010], cnt, f[400010][20], dep[400010], dfn[400010], tms;
void add(int x, int y) {
  e[++cnt].to = y;
  e[cnt].lt = in[x];
  in[x] = cnt;
  e[++cnt].to = x;
  e[cnt].lt = in[y];
  in[y] = cnt;
}
void dfs(int x, int fr) {
  dfn[x] = ++tms;
  for (int i = 1; i < 20; i++) f[x][i] = f[f[x][i - 1]][i - 1];
  for (int i = in[x]; i; i = e[i].lt) {
    int y = e[i].to;
    if (y == fr) continue;
    f[y][0] = x;
    dep[y] = dep[x] + 1;
    dfs(y, x);
  }
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int len = dep[x] - dep[y];
  for (int i = 0; i < 20; i++)
    if (len >> i & 1) x = f[x][i];
  if (x == y) return x;
  for (int i = 19; ~i; i--)
    if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
vector<int> t[400010];
int stk[400010], n, q;
void Add(int x, int y) { t[x].push_back(y); }
void insert(int x) {
  if (!stk[0]) return stk[++stk[0]] = x, void();
  int lca = LCA(x, stk[stk[0]]);
  if (stk[stk[0]] != lca)
    while (stk[0] > 1) {
      int z = stk[stk[0] - 1];
      if (dfn[z] < dfn[lca]) {
        Add(lca, stk[stk[0]]), stk[stk[0]] = lca;
        break;
      } else if (dfn[z] == dfn[lca]) {
        Add(lca, stk[stk[0]]);
        stk[0]--;
        break;
      } else
        Add(z, stk[stk[0]]), stk[0]--;
    }
  if (x != stk[stk[0]]) stk[++stk[0]] = x;
}
bool cmp(int x, int y) { return dfn[x] < dfn[y]; }
int p[400010], c[400010], s[400010];
int build(int sz) {
  sort(p + 1, p + sz + 1, cmp);
  int lca = p[1];
  for (int i = 2; i <= sz; i++) lca = LCA(lca, p[i]);
  insert(lca);
  for (int i = 1; i <= sz; i++) insert(p[i]);
  while (stk[0] > 1) Add(stk[stk[0] - 1], stk[stk[0]]), stk[0]--;
  stk[0] = 0;
  return lca;
}
long long getval(int x, int y) { return 1ll * x * (n + 1) + y; }
struct node {
  long long val;
  int poi;
} w[400010];
bool operator<(node a, node b) { return a.val < b.val; }
int dis(int x, int y) { return dep[x] + dep[y] - 2 * dep[LCA(x, y)]; }
void dp(int x) {
  w[x] = (node){c[x] ? getval(0, c[x]) : getval(n, n), x};
  for (int i = 0; i < t[x].size(); i++) {
    int y = t[x][i];
    dp(y);
    int p = w[y].poi;
    if (c[p])
      w[x] = min(w[x], (node){getval((dis(p, x) - 1) / s[p] + 1, c[p]), p});
  }
}
void dp2(int x, int p) {
  if (c[p])
    w[x] = min(w[x], (node){getval((dis(p, x) - 1) / s[p] + 1, c[p]), p});
  for (int i = 0; i < t[x].size(); i++) {
    int y = t[x][i];
    dp2(y, w[x].poi);
  }
}
void clear(int x) {
  for (int i = 0; i < t[x].size(); i++) clear(t[x][i]);
  t[x].resize(0);
  c[x] = 0;
}
int qry[400010];
int main() {
  n = read();
  for (int i = 1; i < n; i++) add(read(), read());
  q = read();
  dfs(1, 0);
  while (q--) {
    int k = read(), m = read();
    for (int i = 1; i <= k; i++) p[i] = read(), c[p[i]] = i, s[p[i]] = read();
    for (int i = 1; i <= m; i++) p[i + k] = qry[i] = read();
    int rt = build(m + k);
    dp(rt);
    dp2(rt, rt);
    for (int i = 1; i <= m; i++) printf("%d ", c[w[qry[i]].poi]);
    printf("\n");
    clear(rt);
  }
  return 0;
}