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;
vector<int> v[200005];
int in[200005], out[200005], number[200005];
int t;
int p[20][200005];
int dis[200005];
void dfs(int first, int f) {
  in[first] = ++t;
  number[t] = first;
  p[0][first] = f;
  dis[first] = dis[f] + 1;
  for (auto it : v[first]) {
    if (it != f) {
      dfs(it, first);
    }
  }
  out[first] = t;
}
void build(int n) {
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      p[i][j] = p[i - 1][p[i - 1][j]];
    }
  }
}
int lca(int first, int second) {
  if (dis[first] > dis[second]) swap(first, second);
  int d = dis[second] - dis[first];
  for (int i = 0; i < 20; i++) {
    if (d & (1 << i)) {
      second = p[i][second];
    }
  }
  if (first == second) return first;
  for (int i = 19; i >= 0; i--) {
    if (p[i][second] != p[i][first]) {
      first = p[i][first];
      second = p[i][second];
    }
  }
  return p[0][first];
}
int getdis(int first, int second) {
  int lcaa = lca(first, second);
  return dis[first] + dis[second] - dis[lcaa] * 2;
}
bool cmp(const int &a, const int &b) { return in[a] < in[b]; }
vector<int> tmpv[200005];
int vis[200005];
int bln[200005];
int num[200005];
vector<int> buildtree(vector<int> &vertex) {
  vector<int> tmp;
  for (auto it : vertex) {
    tmp.push_back(it);
  }
  sort(tmp.begin(), tmp.end(), cmp);
  for (int i = 0; i < vertex.size() - 1; i++) {
    tmp.push_back(lca(tmp[i], tmp[i + 1]));
  }
  sort(tmp.begin(), tmp.end(), cmp);
  tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());
  for (auto it : tmp) tmpv[it].clear(), vis[it] = 0;
  vector<int> stk;
  stk.push_back(tmp[0]);
  for (int i = 1; i < tmp.size(); i++) {
    while (in[tmp[i]] > out[stk.back()]) stk.pop_back();
    tmpv[stk.back()].push_back(tmp[i]);
    tmpv[tmp[i]].push_back(stk.back());
    stk.push_back(tmp[i]);
  }
  return tmp;
}
int s[200005];
int heigh[200005];
void solve(vector<int> vertex) {
  auto vertex2 = buildtree(vertex);
  for (auto it : vertex) {
    vis[it] = 1;
    bln[it] = it;
    heigh[it] = 1e6;
  }
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      pq;
  for (auto it : vertex) {
    for (auto it2 : tmpv[it]) {
      if (!vis[it2]) {
        pq.push(make_pair((abs(dis[it] - dis[it2]) + s[it] - 1) / s[it],
                          make_pair(num[it], it2)));
      }
    }
  }
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    p.second.first = vertex[p.second.first - 1];
    if (!vis[p.second.second]) {
      vis[p.second.second] = 1;
      bln[p.second.second] = p.second.first;
    } else {
      continue;
    }
    for (auto it : tmpv[p.second.second]) {
      if (!vis[it]) {
        pq.push(make_pair((getdis(it, p.second.first) + s[p.second.first] - 1) /
                              s[p.second.first],
                          make_pair(num[p.second.first], it)));
      }
    }
  }
  for (auto it : vertex2) {
    for (auto it2 : tmpv[it]) {
      if (bln[it] != bln[it2] && dis[it] > dis[it2]) {
        int d = getdis(bln[it], bln[it2]) - 1;
        int a = bln[it], b = bln[it2];
        heigh[a] = d / (s[a] + s[b]) * s[a];
        if (num[a] > num[b]) {
          heigh[a] += max(0, d % (s[a] + s[b]) - s[b]);
        } else {
          heigh[a] += min(d % (s[a] + s[b]), s[a]);
        }
      }
    }
  }
}
int go(int first, int h) {
  for (int i = 0; i < 20; i++) {
    if (h & (1 << i)) {
      first = p[i][first];
    }
  }
  if (first == 0) return 1;
  return first;
}
struct node {
  node *l, *r;
  int a, b;
  int tag;
  node(int _a, int _b) : l(NULL), r(NULL), a(_a), b(_b), tag(0) {}
} * root;
void build(node *n) {
  if (n->a == n->b) return;
  int mid = (n->a + n->b) / 2;
  n->l = new node(n->a, mid);
  n->r = new node(mid + 1, n->b);
  build(n->l);
  build(n->r);
}
void push(node *n) {
  if (n->tag) {
    n->l->tag = n->tag;
    n->r->tag = n->tag;
    n->tag = 0;
  }
}
void add(node *n, int l, int r, int k) {
  if (n->a >= l && n->b <= r) {
    n->tag = k;
    return;
  }
  if (n->b < l || n->a > r) {
    return;
  }
  push(n);
  add(n->l, l, r, k);
  add(n->r, l, r, k);
}
int query(node *n, int first) {
  if (n->a == n->b) {
    return n->tag;
  }
  int mid = (n->a + n->b) / 2;
  push(n);
  if (first <= mid) {
    return query(n->l, first);
  } else {
    return query(n->r, first);
  }
}
int ans[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    v[first].push_back(second);
    v[second].push_back(first);
  }
  dfs(1, 0);
  build(n);
  root = new node(1, n);
  build(root);
  int q;
  scanf("%d", &q);
  while (q--) {
    int k, m;
    scanf("%d %d", &k, &m);
    vector<int> vertex;
    for (int i = 0; i < k; i++) {
      int first;
      scanf("%d", &first);
      scanf("%d", &s[first]);
      num[first] = i + 1;
      vertex.push_back(first);
    }
    solve(vertex);
    vector<pair<pair<int, int>, int> > vertex2;
    int now = 1;
    for (auto it : vertex) {
      int first = go(it, heigh[it]);
      vertex2.push_back(make_pair(make_pair(in[first], out[first]), now));
      now++;
    }
    sort(vertex2.begin(), vertex2.end());
    for (auto it : vertex2) {
      add(root, it.first.first, it.first.second, it.second);
    }
    while (m--) {
      int first;
      scanf("%d", &first);
      printf("%d ", query(root, in[first]));
    }
    printf("\n");
  }
}