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 = 2e5 + 5;
const int mlog = 19;
const int inf = 1e9;
int n, m, k, q;
vector<int> way[maxn];
int h[maxn], par[maxn][25];
int cur, st[maxn];
int virus[maxn], spread[maxn];
int city[maxn];
vector<int> vir;
int stk[maxn];
vector<pair<int, int> > edge[maxn];
struct cost {
  int len, id;
  cost(int _len = 0, int _id = 0) {
    len = _len;
    id = _id;
  }
  int step() { return (int)ceil((double)len / spread[id]); }
  bool operator<(cost a) {
    if (a.step() != step()) return step() < a.step();
    return id < a.id;
  }
};
struct node {
  int u;
  cost val;
  node(int _u = 0, cost _val = cost(inf, 0)) {
    u = _u;
    val = _val;
  }
  bool operator<(node a) const { return a.val < val; }
};
cost ans[maxn];
void dfs(int u, int last) {
  st[u] = ++cur;
  h[u] = h[last] + 1;
  par[u][0] = last;
  for (int i = 1; i <= mlog; i++) par[u][i] = par[par[u][i - 1]][i - 1];
  for (auto v : way[u])
    if (v != last) dfs(v, u);
}
int lca(int x, int y) {
  if (h[x] <= h[y]) swap(x, y);
  for (int i = mlog; i >= 0; i--)
    if (h[par[x][i]] >= h[y]) x = par[x][i];
  if (x == y) return x;
  for (int i = mlog; i >= 0; i--)
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  return par[x][0];
}
void add_edge(int x, int y) {
  int len = h[x] + h[y] - 2 * h[lca(x, y)];
  edge[x].push_back({y, len});
  edge[y].push_back({x, len});
}
void build(vector<int> vec) {
  for (auto u : vir) edge[u].clear();
  vir = vec;
  sort(vec.begin(), vec.end(), [](int u, int v) { return st[u] < st[v]; });
  int sz = 0;
  stk[++sz] = 1;
  for (auto u : vec) {
    int x = lca(u, stk[sz]);
    vir.push_back(x);
    if (x != stk[sz]) {
      while (sz >= 2 && h[stk[sz - 1]] >= h[x]) {
        add_edge(stk[sz - 1], stk[sz]);
        sz--;
      }
      if (x != stk[sz]) {
        add_edge(x, stk[sz]);
        stk[sz] = x;
      }
    }
    if (u != stk[sz]) stk[++sz] = u;
  }
  for (int i = 1; i <= sz - 1; i++) add_edge(stk[i], stk[i + 1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    way[u].push_back(v);
    way[v].push_back(u);
  }
  dfs(1, 0);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &k, &m);
    vector<int> vec;
    for (int i = 1; i <= k; i++) {
      int u, val;
      scanf("%d%d", &u, &val);
      virus[i] = u;
      spread[i] = val;
      vec.push_back(u);
    }
    for (int i = 1; i <= m; i++) {
      int u;
      scanf("%d", &u);
      city[i] = u;
      vec.push_back(u);
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    build(vec);
    spread[0] = 1;
    for (auto x : vir) ans[x] = cost(inf, 0);
    priority_queue<node> heap;
    for (int i = 1; i <= k; i++) {
      int u = virus[i];
      ans[u] = {0, i};
      heap.push(node(u, ans[u]));
    }
    while (!heap.empty()) {
      auto tmp = heap.top();
      heap.pop();
      int u = tmp.u;
      cost val = tmp.val;
      if (ans[u] < val) continue;
      for (auto t : edge[u]) {
        int v = t.first, len = t.second;
        cost nxt = cost(val.len + len, val.id);
        if (nxt < ans[v]) {
          ans[v] = nxt;
          heap.push(node(v, ans[v]));
        }
      }
    }
    for (int i = 1; i <= m; i++) printf("%d ", ans[city[i]].id);
    printf("\n");
  }
}