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;
long long mod = (1000000007LL);
inline long long poww(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
inline pair<int, int> operator+(pair<int, int> A, pair<int, int> B) {
  return pair<int, int>(A.first + B.first, A.second + B.second);
}
inline pair<int, int> operator-(pair<int, int> A, pair<int, int> B) {
  return pair<int, int>(A.first - B.first, A.second - B.second);
}
inline long long mult(long long a, long long b) { return (a * b) % mod; }
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int n, m, q, k;
int mark[300050], block[300050];
struct edge {
  int x, y, z;
};
int in[300050], fim[300050], anc[300050][20], deep[300050];
vector<int> grafo[300050];
void dfs(int x, int p) {
  anc[x][0] = p;
  in[x] = ++k;
  deep[x] = deep[p] + 1;
  for (auto v : grafo[x]) {
    if (v == p) continue;
    dfs(v, x);
  }
  fim[x] = k;
}
void build() {
  memset(anc, -1, sizeof anc);
  dfs(1, 1);
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++) anc[i][j] = anc[anc[i][j - 1]][j - 1];
}
int lca(int u, int v) {
  if (deep[v] > deep[u]) swap(u, v);
  for (int i = 19; i >= 0; i--)
    if (deep[u] - (1 << i) >= deep[v]) u = anc[u][i];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (anc[u][i] != -1 & anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  return anc[u][0];
}
int dist(int a, int b) { return deep[a] + deep[b] - 2 * deep[lca(a, b)]; }
bool check(int a, int b) {
  if (abs(deep[a] - deep[b]) == dist(a, b)) return 1;
  return 0;
}
pair<vector<edge>, int> build_virtual_tree(vector<int> K) {
  auto first = [&](int a, int b) { return in[a] < in[b]; };
  vector<edge> e;
  sort(begin(K), end(K), first);
  int m = (int)(K).size();
  for (int i = 1; i < (m); ++i) {
    K.push_back(lca(K[i], K[i - 1]));
  }
  sort(begin(K), end(K), first);
  K.erase(unique(begin(K), end(K)), K.end());
  for (int i = 0; i < ((int)(K).size() - 1); ++i) {
    int z = lca(K[i], K[i + 1]);
    e.push_back({K[i + 1], z, dist(z, K[i + 1])});
  }
  return {e, K[0]};
}
int id[300050], cnt = 0, rev[300050], vis[300050], ans[300050];
void compress(vector<int> &good, vector<edge> &aux,
              vector<vector<pair<int, int> > > &tree) {
  cnt = 0;
  set<int> caras, nxt;
  for (auto w : good) caras.insert(w);
  for (auto w : aux) {
    if (!caras.count(w.x)) {
      caras.insert(w.x);
      good.push_back(w.x);
    }
    if (!caras.count(w.y)) {
      caras.insert(w.y);
      good.push_back(w.y);
    }
  }
  for (auto w : good) {
    id[w] = ++cnt;
    rev[cnt] = w;
  }
  tree.resize(cnt + 1);
  for (auto e : aux) {
    int a = id[e.x], b = id[e.y], c = e.z;
    if (!a or !b) cout << "lixo\n";
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1, a, b; i < n; i++) {
    cin >> a >> b;
    grafo[a].push_back(b);
    grafo[b].push_back(a);
  }
  build();
  cin >> q;
  while (q--) {
    int ki, mi;
    cin >> ki >> mi;
    vector<int> good;
    vector<pair<int, int> > virus(ki);
    vector<int> city(mi);
    set<int> col;
    for (int i = 0; i < ki; i++) {
      cin >> virus[i].first >> virus[i].second;
      if (!col.count(virus[i].first)) good.push_back(virus[i].first);
      block[virus[i].first] = virus[i].second;
      col.insert(virus[i].first);
    }
    for (int i = 0; i < mi; i++) {
      cin >> city[i];
      if (!col.count(city[i])) good.push_back(city[i]);
      mark[city[i]] = 1;
      col.insert(city[i]);
    }
    auto T = build_virtual_tree(good);
    vector<vector<pair<int, int> > > tree;
    compress(good, T.first, tree);
    priority_queue<pair<pair<int, int>, pair<int, int> >,
                   vector<pair<pair<int, int>, pair<int, int> > >,
                   greater<pair<pair<int, int>, pair<int, int> > > >
        pq;
    for (int i = 0; i < (int)(virus).size(); i++) {
      pq.push({{0, id[virus[i].first]}, {0, id[virus[i].first]}});
    }
    while (!pq.empty()) {
      int tempo = pq.top().first.first, virus = pq.top().first.second,
          dist = pq.top().second.first, x = pq.top().second.second;
      pq.pop();
      if (vis[x]) continue;
      ans[x] = virus;
      vis[x] = 1;
      for (auto v : tree[x]) {
        int dist2 = dist + v.second;
        int tempo2 = (dist2 / block[rev[virus]] +
                      (dist2 % block[rev[virus]] != 0 ? 1 : 0));
        pq.push(
            {{((dist2 + block[rev[virus]] - 1) / (block[rev[virus]])), virus},
             {dist2, v.first}});
      }
    }
    for (int i = 0; i < (int)(city).size(); i++) {
      cout << ans[id[city[i]]] << " ";
    }
    cout << "\n";
    int t = 1;
    for (auto w : good) {
      block[w] = mark[w] = ans[w] = vis[w] = id[w] = rev[w] = 0;
      block[t] = mark[t] = ans[t] = vis[t] = id[t] = rev[t] = 0;
      t++;
    }
    city.clear();
    virus.clear();
    T.first.clear();
    col.clear();
    good.clear();
  }
}