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;
template <typename _Tp>
inline void IN(_Tp &dig) {
  char c;
  bool flag = 0;
  dig = 0;
  while (c = getchar(), !isdigit(c))
    if (c == '-') flag = 1;
  while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
  if (flag) dig = -dig;
}
struct graph {
  int head[(400005)], nxt[(400005) << 1], to[(400005) << 1], w[(400005) << 1],
      sz;
  void init() { memset(head, -1, sizeof(head)), sz = 0; }
  graph() { init(); }
  void push(int a, int b, int c) {
    nxt[sz] = head[a], to[sz] = b, w[sz] = c, head[a] = sz++;
  }
  int &operator[](const int a) { return to[a]; }
} g;
int n, pre[(400005)][(19) + 1], dep[(400005)], mx[(400005)][(19) + 1],
    id[(400005)], dfn;
int m, k, h[(400005)], sta[(400005)], top, MX;
int speed[(400005)];
long long f[(400005)];
int book[(400005)];
void Init(int a, int fa) {
  pre[a][0] = fa, dep[a] = dep[fa] + 1, id[a] = ++dfn;
  for (int i = 1; i <= (19); i += 1) {
    pre[a][i] = pre[pre[a][i - 1]][i - 1];
  }
  for (int i = g.head[a]; ~i; i = g.nxt[i])
    if (g[i] != fa) Init(g[i], a);
}
int lca(int a, int b) {
  MX = dep[a] + dep[b];
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = (19); i >= 0; i -= 1)
    if (dep[pre[b][i]] >= dep[a]) b = pre[b][i];
  if (a == b) {
    MX -= 2 * dep[a];
    return a;
  }
  for (int i = (19); i >= 0; i -= 1)
    if (pre[a][i] != pre[b][i]) {
      a = pre[a][i], b = pre[b][i];
    }
  MX -= 2 * dep[pre[a][0]];
  return pre[a][0];
}
bool cmp(int a, int b) { return id[a] < id[b]; }
vector<int> v;
vector<array<int, 2>> adj[(400005)];
int aff[(400005)], lab[(400005)], ph[(400005)];
void Dfs(int a) {
  v.push_back(a);
  adj[a].clear();
  for (int i = g.head[a]; ~i; i = g.nxt[i]) {
    Dfs(g[i]);
  }
}
int main(int argc, char const *argv[]) {
  IN(n);
  for (int i = 1, a, b, c; i < n; i += 1)
    IN(a), IN(b), g.push(a, b, 1), g.push(b, a, 1);
  Init(1, 0), IN(m);
  while (m--) {
    int k1, k2;
    IN(k1);
    IN(k2);
    k = k1;
    for (int i = 1; i <= k1; i += 1) {
      IN(h[i]), book[h[i]] = 1;
      lab[h[i]] = i;
      IN(speed[i]);
    }
    for (int i = 1; i <= k2; i += 1) {
      IN(ph[i]);
    }
    for (int i = 1; i <= k2; i++) {
      if (!book[ph[i]]) h[++k] = ph[i];
    }
    sort(h + 1, h + 1 + k, cmp);
    sta[top = 1] = 1, g.sz = 0, g.head[1] = -1;
    for (int i = 1, l; i <= k; i += 1)
      if (h[i] != 1) {
        l = lca(sta[top], h[i]);
        if (l != sta[top]) {
          while (id[l] < id[sta[top - 1]]) {
            lca(sta[top - 1], sta[top]);
            g.push(sta[top - 1], sta[top], MX);
            top--;
          }
          if (id[l] > id[sta[top - 1]]) {
            g.head[l] = -1, lca(l, sta[top]);
            g.push(l, sta[top], MX), sta[top] = l;
          } else
            lca(l, sta[top]), g.push(l, sta[top--], MX);
        }
        g.head[h[i]] = -1, sta[++top] = h[i];
      }
    for (int i = 1; i < top; i += 1)
      lca(sta[i], sta[i + 1]), g.push(sta[i], sta[i + 1], MX);
    v.clear();
    Dfs(1);
    for (auto a : v) {
      for (int i = g.head[a]; ~i; i = g.nxt[i]) {
        adj[a].push_back({g[i], g.w[i]});
        adj[g[i]].push_back({a, g.w[i]});
      }
    }
    priority_queue<array<int, 4>, vector<array<int, 4>>, greater<array<int, 4>>>
        q;
    for (auto a : v) {
      aff[a] = -1;
      if (book[a]) {
        q.push({0, lab[a], a, 0});
      }
    }
    while (!q.empty()) {
      auto p = q.top();
      q.pop();
      int a = p[2];
      if (aff[a] != -1) continue;
      aff[a] = p[1];
      for (auto c : adj[a]) {
        q.push({(p[3] + c[1] + speed[p[1]] - 1) / speed[p[1]], p[1], c[0],
                p[3] + c[1]});
      }
    }
    for (int i = 1; i <= k; i += 1) book[h[i]] = 0;
    for (int i = 1; i <= k2; i += 1) {
      cout << aff[ph[i]] << " ";
      assert(aff[ph[i]] != -1);
    }
    cout << "\n";
  }
  return 0;
}