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;
const int maxn = 400003, INF = 0x3f3f3f3f;
int n, Q, dep[maxn], stk[maxn], top, st[maxn][19], ord[maxn], cntst, lg[maxn],
    p[maxn], a[maxn], b[maxn], c[maxn];
vector<int> h[maxn], g[maxn];
struct data {
  int t, i;
  data() {}
  data(int _t, int _i) : t(_t), i(_i) {}
  bool operator<(const data &x) const {
    int t1 = (t + b[i] - 1) / b[i], t2 = (x.t + b[x.i] - 1) / b[x.i];
    return t1 != t2 ? t1 < t2 : i < x.i;
  }
};
data dis[maxn];
priority_queue<pair<data, int>, vector<pair<data, int> >,
               greater<pair<data, int> > >
    q;
void addedge(int u, int v) { g[u].push_back(v), g[v].push_back(u); }
void init(int u, int last) {
  st[++cntst][0] = u;
  ord[u] = cntst;
  for (int v : h[u]) {
    if (v == last) continue;
    dep[v] = dep[u] + 1;
    init(v, u);
    st[++cntst][0] = u;
  }
}
int MIN(int x, int y) { return ord[x] < ord[y] ? x : y; }
void initst() {
  for (int l = 1; (1 << l) <= cntst; l++) {
    for (int i = 1; i + (1 << l) - 1 <= cntst; i++) {
      st[i][l] = MIN(st[i][l - 1], st[i + (1 << (l - 1))][l - 1]);
    }
  }
}
int lca(int x, int y) {
  int l = ord[x], r = ord[y];
  if (l > r) swap(l, r);
  int tmp = lg[r - l + 1];
  return MIN(st[l][tmp], st[r - (1 << tmp) + 1][tmp]);
}
bool cmp(int x, int y) { return ord[x] < ord[y]; }
void build(int p[], int &k) {
  sort(p + 1, p + k + 1, cmp);
  k = unique(p + 1, p + k + 1) - p - 1;
  top = 0;
  for (int i = 1; i <= k; i++) {
    int u = p[i];
    if (top >= 2) {
      int l = lca(u, stk[top]);
      if (l != stk[top]) {
        while (top >= 2 && ord[stk[top - 1]] >= ord[l])
          addedge(stk[top - 1], stk[top]), top--;
        if (stk[top] != l) addedge(l, stk[top]), stk[top] = l;
      }
    }
    stk[++top] = u;
  }
  while (top >= 2) addedge(stk[top - 1], stk[top]), top--;
}
void clear(int u, int last) {
  for (int v : g[u]) {
    if (v == last) continue;
    clear(v, u);
  }
  dis[u] = data(INF, 0), g[u].clear();
}
void dijkstra(int k) {
  while (!q.empty()) q.pop();
  for (int i = 1; i <= k; i++)
    q.push(pair<data, int>(dis[a[i]] = data(0, i), a[i]));
  while (!q.empty()) {
    data x = q.top().first;
    int u = q.top().second;
    q.pop();
    if (dis[u] < x) continue;
    for (int v : g[u]) {
      data w(dis[u].t + abs(dep[u] - dep[v]), dis[u].i);
      if (w < dis[v]) {
        dis[v] = w;
        q.push(pair<data, int>(dis[v], v));
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    h[u].push_back(v), h[v].push_back(u);
  }
  init(1, 0);
  for (int i = 2; i <= cntst; i++) lg[i] = lg[i >> 1] + 1;
  initst();
  fill(dis + 1, dis + n + 1, data(INF, 0));
  b[0] = 1;
  scanf("%d", &Q);
  while (Q--) {
    int k, m, tot = 0;
    scanf("%d%d", &k, &m);
    for (int i = 1; i <= k; i++) scanf("%d%d", a + i, b + i), p[++tot] = a[i];
    for (int i = 1; i <= m; i++) scanf("%d", c + i), p[++tot] = c[i];
    p[++tot] = 1;
    build(p, tot);
    dijkstra(k);
    for (int i = 1; i <= m; i++) printf("%d ", dis[c[i]].i);
    puts("");
    clear(1, 0);
  }
  return 0;
}