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
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T&& x) {
  cout << x << "\n";
}
template <typename T, typename... S>
void print(T&& x, S&&... y) {
  cout << x << ' ';
  print(y...);
}
const int Mod = 1000000007, Mod2 = 998244353;
const int MOD = Mod2;
const int maxn = 200005;
int n, u, v, cur, dep[maxn], id[maxn], fa[maxn][18], q, k, m, x, s[maxn];
vector<int> adj[maxn], adj2[maxn], vec, vec1, vec2, vec3;
pair<int, int> dis[maxn];
bool vis[maxn];
void dfs(int u, int par) {
  dep[u] = ~par ? dep[par] + 1 : 0;
  id[u] = cur++;
  fa[u][0] = par;
  for (int i = (1); i < ((int)(18)); i++)
    fa[u][i] = ~fa[u][i - 1] ? fa[fa[u][i - 1]][i - 1] : -1;
  for (auto v : adj[u])
    if (v != par) {
      dfs(v, u);
    }
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = (0); i < ((int)(18)); i++)
    if ((dep[v] - dep[u]) & (1ll << (i))) v = fa[v][i];
  if (u == v) return u;
  for (int i = (17); i >= ((int)(0)); i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
void build(vector<int> vec, vector<int>& vec2) {
  if (none_of(vec.begin(), vec.end(), [](int i) { return !i; }))
    vec.push_back(0);
  sort(vec.begin(), vec.end(), [](int i, int j) { return id[i] < id[j]; });
  vector<int> sk;
  vec2.clear();
  for (auto u : vec) {
    if (sk.empty()) {
      sk.push_back(u);
      adj2[u].clear();
      vec2.push_back(u);
      continue;
    }
    int v = lca(sk.back(), u);
    if (v == sk.back()) {
      sk.push_back(u);
      adj2[u].clear();
      vec2.push_back(u);
      continue;
    }
    while (((int)sk.size()) >= 2 && dep[sk[((int)sk.size()) - 2]] >= dep[v]) {
      adj2[sk.back()].push_back(sk[((int)sk.size()) - 2]);
      adj2[sk[((int)sk.size()) - 2]].push_back(sk.back());
      sk.pop_back();
    }
    if (((int)sk.size()) >= 1 && sk.back() != v) {
      adj2[v].clear();
      adj2[sk.back()].push_back(v);
      adj2[v].push_back(sk.back());
      sk.pop_back();
      sk.push_back(v);
      vec2.push_back(v);
    }
    sk.push_back(u);
    adj2[u].clear();
    vec2.push_back(u);
  }
  for (int i = (0); i < ((int)(((int)sk.size()) - 1)); i++) {
    adj2[sk[i]].push_back(sk[i + 1]);
    adj2[sk[i + 1]].push_back(sk[i]);
  }
}
struct cmp {
  bool operator()(const pair<pair<int, int>, int>& i,
                  const pair<pair<int, int>, int>& j) const {
    return (((i.first.first) + (s[i.first.second]) - 1) /
            (s[i.first.second])) ==
                   (((j.first.first) + (s[j.first.second]) - 1) /
                    (s[j.first.second]))
               ? i.first.second > j.first.second
               : (((i.first.first) + (s[i.first.second]) - 1) /
                  (s[i.first.second])) >
                     (((j.first.first) + (s[j.first.second]) - 1) /
                      (s[j.first.second]));
  }
};
priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int>>,
               cmp>
    pq;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = (0); i < ((int)(n - 1)); i++) {
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  dfs(0, -1);
  cin >> q;
  while (q--) {
    cin >> k >> m;
    vec1.resize(k), vec2.resize(m);
    for (int i = (0); i < ((int)(((int)vec1.size()))); i++) {
      cin >> vec1[i] >> s[i];
      vec1[i]--;
    }
    for (auto& i : vec2) cin >> i;
    for (auto& i : vec2) i--;
    vec3.clear();
    for (auto& i : vec1) vec3.push_back(i);
    for (auto& i : vec2) vec3.push_back(i);
    build(vec3, vec);
    for (auto& i : vec) dis[i] = {1010000000, 0}, vis[i] = false;
    for (int i = (0); i < ((int)(((int)vec1.size()))); i++)
      dis[vec1[i]] = {0, i};
    for (int i = (0); i < ((int)(((int)vec1.size()))); i++)
      pq.push(make_pair(dis[vec1[i]], vec1[i]));
    while (!pq.empty()) {
      u = pq.top().second;
      pair<int, int> p = pq.top().first;
      pq.pop();
      if (vis[u]) continue;
      vis[u] = true;
      dis[u] = p;
      for (auto v : adj2[u])
        pq.push({{p.first + abs(dep[u] - dep[v]), p.second}, v});
    }
    for (auto& i : vec2) cout << (dis[i].second + 1) << ' ';
    cout << "\n";
  }
  return 0;
}
