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;
struct lca_tree {
  vector<vector<pair<int, long long>>> adj;
  vector<int> parent[20], depth, st;
  vector<long long> dist;
  int lg, n, built = 0, root, tt;
  lca_tree(int root_, int sz) {
    n = sz, root = root_;
    tt = 0;
    for (lg = 1; (1 << lg) <= 200010; lg++)
      ;
    lg--;
    assert(lg < 20);
    for (int i = 0; i <= lg; i++) parent[i].resize(n + 1);
    depth.resize(n + 1);
    dist.resize(n + 1);
    adj.resize(n + 1);
    st.resize(n + 1);
  }
  void dfs(int u, int p = -1) {
    st[u] = ++tt;
    for (auto e : adj[u]) {
      int v = e.first;
      if (v != p) {
        dist[v] = e.second + dist[u];
        depth[v] = 1 + depth[u];
        parent[0][v] = u;
        dfs(v, u);
      }
    }
  }
  void build(int node) {
    dist[node] = depth[node] = 0;
    dfs(node);
    parent[0][node] = node;
    for (int j = 1; j <= lg; j++)
      for (int i = 0; i <= n; i++)
        parent[j][i] = parent[j - 1][parent[j - 1][i]];
    built = 1;
  }
  int get_lca(int x, int y) {
    if (!built) build(root);
    if (depth[x] < depth[y]) swap(x, y);
    for (int i = lg; i >= 0; i--)
      if (depth[x] - depth[y] >= (1 << i)) x = parent[i][x];
    if (x == y) return x;
    for (int i = lg; i >= 0; i--)
      if (parent[i][x] != parent[i][y]) {
        x = parent[i][x];
        y = parent[i][y];
      }
    return parent[0][x];
  }
  long long distance(int x, int y) {
    if (!built) build(root);
    return dist[x] + dist[y] - 2LL * dist[get_lca(x, y)];
  }
};
struct D {
  int d, v, rem;
  bool operator<(const D& o) const {
    return tie(d, v, rem) < tie(o.d, o.v, o.rem);
  }
};
int ans[200010], id[200010];
int main() {
  int n, q;
  scanf("%d", &n);
  lca_tree t(1, n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    t.adj[u].emplace_back(v, 1);
    t.adj[v].emplace_back(u, 1);
  }
  t.build(1);
  scanf("%d", &q);
  while (q--) {
    int k, m;
    vector<int> c, add;
    vector<pair<int, int>> viruses;
    scanf("%d %d", &k, &m);
    for (int i = 0; i < k; i++) {
      int v, s;
      scanf("%d %d", &v, &s);
      viruses.emplace_back(v, s);
      c.push_back(v);
    }
    for (int i = 0; i < m; i++) {
      scanf("%d", &ans[i]);
      c.push_back(ans[i]);
    }
    sort(c.begin(), c.end(), [&](int u, int v) { return t.st[u] < t.st[v]; });
    for (int i = 0; i + 1 < (int)c.size(); i++) {
      int u = c[i], v = c[i + 1], lca = t.get_lca(u, v);
      if (lca != u && lca != v) add.push_back(lca);
    }
    c.insert(c.end(), add.begin(), add.end());
    sort(c.begin(), c.end(), [&](int u, int v) { return t.st[u] < t.st[v]; });
    vector<int> tmp;
    for (int i = 0; i < (int)c.size(); i++) {
      if (!i || c[i] != c[i - 1]) tmp.push_back(c[i]);
    }
    c = tmp;
    lca_tree comp(0, c.size());
    stack<int> path;
    for (int i = 0; i < (int)c.size(); i++) {
      while (!path.empty() && t.get_lca(c[path.top()], c[i]) != c[path.top()]) {
        path.pop();
      }
      if (!path.empty()) {
        int pt = path.top();
        int d = t.distance(c[i], c[pt]);
        comp.adj[i].emplace_back(pt, d);
        comp.adj[pt].emplace_back(i, d);
      }
      path.push(i);
      id[c[i]] = i;
    }
    vector<D> dist(c.size(), {INT_MAX, 0, 0});
    set<pair<D, int>> fila;
    for (int i = 0; i < k; i++) {
      int cr = id[viruses[i].first];
      dist[cr] = {0, i, 0};
      fila.insert({dist[cr], cr});
    }
    while (!fila.empty()) {
      auto tt = *(fila.begin());
      fila.erase(tt);
      D d = tt.first;
      int u = tt.second;
      if (dist[u] < d) continue;
      for (auto ed : comp.adj[u]) {
        int v = ed.first;
        long long cost = ed.second;
        int nrem = d.rem + cost;
        D nno({(nrem + viruses[d.v].second - 1) / viruses[d.v].second, d.v,
               nrem});
        if (nno < dist[v]) {
          dist[v] = nno;
          fila.insert({dist[v], v});
        }
      }
    }
    for (int i = 0; i < m; i++) {
      printf("%d ", dist[id[ans[i]]].v + 1);
    }
    puts("");
  }
  return 0;
}
