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>
#pragma comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
const int maxn = (int)2e5 + 10, maxlog = 20;
struct Tree {
  vector<vector<int> > ed;
  int n;
  vector<int> h;
  vector<int> par[maxlog];
  vector<int> tin;
  int tt;
  vector<int> proj[2];
  vector<int> used;
  int last;
  int posit;
  void dfs(int v, int p, int hh) {
    tt++;
    tin[v] = tt;
    h[v] = hh;
    par[0][v] = p;
    for (int i = 1; i < maxlog; i++) {
      par[i][v] = par[i - 1][par[i - 1][v]];
    }
    for (int u : ed[v]) {
      if (u != p) {
        dfs(u, v, hh + 1);
      }
    }
  }
  int lca(int x, int y) {
    if (h[x] < h[y]) {
      swap(x, y);
    }
    for (int i = maxlog - 1; i >= 0; i--) {
      if (h[x] - (1 << i) >= h[y]) {
        x = par[i][x];
      }
    }
    if (x == y) {
      return x;
    }
    for (int i = maxlog - 1; i >= 0; i--) {
      if (par[i][x] != par[i][y]) {
        x = par[i][x];
        y = par[i][y];
      }
    }
    return par[0][x];
  }
  Tree() {}
  Tree(int n, vector<pair<int, int> > e) : n(n) {
    used.resize(n);
    last = 0;
    tt = -1;
    ed.resize(n);
    h.resize(n);
    tin.resize(n);
    proj[0].resize(n);
    proj[1].resize(n);
    for (int i = 0; i < maxlog; i++) {
      par[i].resize(n);
    }
    for (auto [v, u] : e) {
      ed[v].push_back(u);
      ed[u].push_back(v);
    }
    dfs(0, 0, 0);
  }
  vector<vector<pair<int, int> > > e;
  int get_num(int v) {
    if (used[v] == last) {
      return proj[0][v];
    }
    e.push_back(vector<pair<int, int> >());
    used[v] = last;
    proj[0][v] = posit;
    proj[1][posit++] = v;
    return proj[0][v];
  }
  vector<vector<pair<int, int> > > build(vector<int> vert) {
    e.clear();
    posit = 0;
    last++;
    sort((vert).begin(), (vert).end(),
         [&](int a, int b) { return tin[a] < tin[b]; });
    vector<int> st;
    for (int v : vert) {
      if (st.empty()) {
        st.push_back(v);
        continue;
      }
      int l = lca(st.back(), v);
      int pv = get_num(v);
      int pl = get_num(l);
      int lst = -1;
      int plst = -1;
      while (!st.empty() && h[l] <= h[st.back()]) {
        int u = st.back();
        st.pop_back();
        int pu = get_num(u);
        if (lst != -1) {
          e[pu].push_back(make_pair(plst, h[lst] - h[u]));
          e[plst].push_back(make_pair(pu, h[lst] - h[u]));
        }
        lst = u;
        plst = pu;
      }
      if (lst != -1 && lst != l) {
        e[pl].push_back(make_pair(plst, h[lst] - h[l]));
        e[plst].push_back(make_pair(pl, h[lst] - h[l]));
      }
      st.push_back(l);
      if (v != l) {
        st.push_back(v);
      }
    }
    int lst = -1;
    int plst = -1;
    while (!st.empty()) {
      int u = st.back();
      st.pop_back();
      int pu = get_num(u);
      if (lst != -1) {
        e[pu].push_back(make_pair(plst, h[lst] - h[u]));
        e[plst].push_back(make_pair(pu, h[lst] - h[u]));
      }
      lst = u;
      plst = pu;
    }
    return e;
  }
};
vector<int> ed[maxn];
vector<vector<pair<int, int> > > e;
struct vt {
  int len;
  int s;
  int num;
  vt() {}
  vt(int len, int s, int num) : len(len), s(s), num(num) {}
};
bool operator<(vt a, vt b) {
  int na = (a.len + a.s - 1) / a.s;
  int nb = (b.len + b.s - 1) / b.s;
  if (na != nb) {
    return na < nb;
  }
  return a.num < b.num;
}
int wh[maxn];
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > ee;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    ed[x].push_back(y);
    ed[y].push_back(x);
    ee.push_back(make_pair(x, y));
  }
  Tree t = Tree(n, ee);
  int q;
  cin >> q;
  while (q--) {
    int k, m;
    scanf("%d %d", &k, &m);
    vector<pair<int, int> > a;
    vector<int> b;
    vector<int> vert;
    for (int i = 0; i < k; i++) {
      int x, c;
      scanf("%d %d", &x, &c);
      x--;
      a.push_back(make_pair(x, c));
      vert.push_back(x);
    }
    for (int i = 0; i < m; i++) {
      int x;
      scanf("%d", &x);
      x--;
      b.push_back(x);
      vert.push_back(x);
    }
    sort((vert).begin(), (vert).end());
    vert.resize(unique((vert).begin(), (vert).end()) - vert.begin());
    e = t.build(vert);
    for (int i = 0; i < (int)e.size(); i++) {
      wh[i] = -1;
    }
    set<pair<vt, int> > s;
    for (int i = 0; i < (int)a.size(); i++) {
      int v = t.proj[0][a[i].first];
      int sp = a[i].second;
      s.insert(make_pair(vt(0, sp, i), v));
    }
    while (!s.empty()) {
      vt cur = s.begin()->first;
      int v = s.begin()->second;
      s.erase(s.begin());
      if (wh[v] != -1) {
        continue;
      }
      wh[v] = cur.num;
      for (auto [u, d] : e[v]) {
        cur.len += d;
        s.insert(make_pair(cur, u));
        cur.len -= d;
      }
    }
    for (int v : b) {
      printf("%d ", wh[t.proj[0][v]] + 1);
    }
    printf("\n");
  }
}
