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 N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e9;
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 << 1) + (x << 3) + c - '0', c = getchar();
  return x * F;
}
const int ot = 20;
namespace Tree {
int fa[N][ot + 1], mi[N][18];
int dep[N], tot, dfn[N];
vector<pair<int, int> > G[N];
void init(int x, int f) {
  dfn[x] = ++tot;
  dep[x] = dep[f] + 1;
  for (int i = 1; i <= ot; i++)
    fa[x][i] = fa[fa[x][i - 1]][i - 1],
    mi[x][i] = min(mi[x][i - 1], mi[fa[x][i - 1]][i - 1]);
  for (pair<int, int> now : G[x]) {
    int to = now.first;
    if (to == f) continue;
    mi[to][0] = now.second;
    fa[to][0] = x;
    init(to, x);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = ot; i >= 0; i--) {
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
    if (u == v) return u;
  }
  for (int i = ot; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
int dis(int u, int v) {
  int lc = lca(u, v);
  return dep[u] + dep[v] - 2 * dep[lc];
}
};  // namespace Tree
using namespace Tree;
struct dat {
  int u, t, c, d;
};
inline bool operator<(dat x, dat y) {
  return x.t == y.t ? x.c > y.c : x.t > y.t;
}
priority_queue<dat> q;
int col[N];
namespace XTree {
int stk[N];
int b[N];
int tp, cnt, used[N];
vector<pair<int, int> > g[N];
int usd[N];
bool cmp(int x, int y) { return Tree::dfn[x] < Tree::dfn[y]; }
void addEdge(int u, int v) {
  int d = Tree::dis(u, v);
  g[u].push_back(make_pair(v, d));
  g[v].push_back(make_pair(u, d));
}
void build(int k) {
  sort(b + 1, b + 1 + k, cmp);
  k = unique(b + 1, b + 1 + k) - b - 1;
  cnt = 0;
  for (int i = 1; i <= k; ++i) {
    int u = b[i];
    usd[++cnt] = u;
    if (!tp) {
      stk[++tp] = u;
      continue;
    }
    int lca = Tree::lca(u, stk[tp]);
    while (tp && dep[stk[tp - 1]] >= dep[lca])
      addEdge(stk[tp - 1], stk[tp]), --tp;
    if (stk[tp] != lca) addEdge(lca, stk[tp]), stk[tp] = lca, usd[++cnt] = lca;
    stk[++tp] = u;
  }
  while (--tp) addEdge(stk[tp], stk[tp + 1]);
}
void clear() {
  for (int i = 1; i <= cnt; ++i) col[usd[i]] = 0, g[usd[i]].clear();
}
}  // namespace XTree
int s[N], vt[N], ut[N];
void solve() {
  while (!q.empty()) {
    dat p = q.top();
    q.pop();
    if (col[p.u]) continue;
    col[p.u] = p.c;
    for (auto e : XTree::g[p.u])
      if (!col[e.first])
        q.push((dat){e.first, (p.d + e.second - 1) / vt[p.c] + 1, p.c,
                     p.d + e.second});
  }
}
int main() {
  int n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    G[u].push_back(make_pair(v, 1));
    G[v].push_back(make_pair(u, 1));
  }
  init(1, 0);
  int Q = read();
  while (Q--) {
    int k = read(), m = read();
    int cnt = 0;
    for (int i = 1; i <= k; i++) {
      s[i] = read();
      vt[i] = read();
      XTree::b[++cnt] = s[i];
      q.push((dat){s[i], 0, i, 0});
    }
    for (int i = 1; i <= m; i++) {
      ut[i] = read();
      XTree::b[++cnt] = ut[i];
    }
    XTree::build(cnt);
    solve();
    for (int i = 1; i <= m; i++) {
      printf("%d ", col[ut[i]]);
    }
    puts("");
    XTree::clear();
  }
}