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 inf = 0x3f3f3f3f;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, st[400030], Q, m, k, cnt, head[400030];
int son[400030], top[400030], siz[400030], dep[400030], f[400030], dfn[400030],
    num, a[400030], b[400030], p[400030], s[400030];
vector<int> bin;
struct Edge {
  int to, nxt;
} edge[400030 << 1];
void add(int a, int b) {
  cnt++;
  edge[cnt].to = b;
  edge[cnt].nxt = head[a];
  head[a] = cnt;
}
void dfs1(int u, int fa, int deep) {
  dep[u] = deep;
  f[u] = fa;
  siz[u] = 1;
  int maxson = -1;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v == fa) continue;
    dfs1(v, u, deep + 1);
    siz[u] += siz[v];
    if (siz[v] > maxson) {
      maxson = siz[v];
      son[u] = v;
    }
  }
}
void dfs2(int u, int topf) {
  top[u] = topf;
  dfn[u] = ++num;
  if (!son[u]) return;
  dfs2(son[u], topf);
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v == son[u] || v == f[u]) continue;
    dfs2(v, v);
  }
}
int LCA(int x, int y) {
  while (top[x] ^ top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = f[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  return x;
}
inline int Abs(int x) { return x >= 0 ? x : -x; }
int step[400030], col[400030], vis[400030], dis[400030], from[400030];
struct QAQ {
  int dis, step, col, from;
  bool operator<(const QAQ y) const {
    return step == y.step ? col < y.col : step < y.step;
  }
} g[400030];
priority_queue<pair<QAQ, int>, vector<pair<QAQ, int> >,
               greater<pair<QAQ, int> > >
    q;
void Dijkstra(int n) {
  for (int i = 0; i < bin.size(); i++) {
    int u = bin[i];
    g[u].step = g[u].dis = inf, g[u].col = g[u].from = 0;
    vis[u] = 0;
  }
  for (int i = 1; i <= m; i++) {
    g[a[i]].col = i, g[a[i]].from = a[i];
    g[a[i]].step = g[a[i]].dis = 0;
    q.push(make_pair(g[a[i]], a[i]));
  }
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i; i = edge[i].nxt) {
      int v = edge[i].to;
      QAQ nw = g[u];
      nw.dis += Abs(dep[u] - dep[v]);
      nw.step = (nw.dis - 1) / s[nw.from] + 1;
      if (nw < g[v]) {
        g[v] = nw;
        q.push(make_pair(g[v], v));
      }
    }
  }
}
bool cmp(int i, int j) { return dfn[i] < dfn[j]; }
void Solve(int n) {
  sort(p + 1, p + n + 1, cmp);
  n = unique(p + 1, p + n + 1) - p - 1;
  static int top;
  st[top = 1] = 1;
  bin.clear();
  bin.push_back(1);
  for (int i = 1; i <= n; i++) {
    int u = p[i];
    if (u == 1) continue;
    int lca = LCA(st[top], u);
    while (top > 1 && dfn[st[top - 1]] >= dfn[lca]) {
      bin.push_back(st[top]);
      add(st[top - 1], st[top]), add(st[top], st[top - 1]), --top;
    }
    if (lca ^ st[top]) {
      bin.push_back(st[top]);
      add(st[top], lca), add(lca, st[top]), --top;
      st[++top] = lca;
    }
    st[++top] = u;
  }
  while (top > 1)
    bin.push_back(st[top]), add(st[top - 1], st[top]),
        add(st[top], st[top - 1]), --top;
  Dijkstra(n);
  for (int i = 1; i <= k; i++) {
    printf("%d ", g[b[i]].col);
  }
  printf("\n");
  for (int i = 0; i < bin.size(); i++) {
    head[bin[i]] = 0;
  }
  cnt = 0;
}
int main() {
  n = read();
  for (int i = 1; i <= n - 1; i++) {
    int u = read(), v = read();
    add(u, v), add(v, u);
  }
  dfs1(1, 0, 1);
  dfs2(1, 1);
  memset(head, 0, sizeof(head));
  cnt = 0;
  Q = read();
  while (Q--) {
    m = read(), k = read();
    int tot = 0;
    for (int i = 1; i <= m; i++) {
      a[i] = read(), p[++tot] = a[i];
      s[a[i]] = read();
    }
    for (int i = 1; i <= k; i++) {
      b[i] = read(), p[++tot] = b[i];
    }
    Solve(tot);
  }
  return 0;
}