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;
using ll = long long;
const ll INF = 4 * (ll)1e18;
class HLD {
 private:
  vector<int> par, siz, cmp, ind, dep;
  int dfs1(int i, vector<vector<int>>& g) {
    for (auto& t : g[i]) {
      if (t == par[i]) continue;
      par[t] = i;
      dep[t] = dep[i] + 1;
      siz[i] += dfs1(t, g);
      if (siz[t] > siz[g[i][0]] || g[i][0] == par[i]) swap(t, g[i][0]);
    }
    return siz[i];
  }
  void dfs2(int i, int& x, const vector<vector<int>>& g) {
    ind[i] = x;
    ++x;
    for (auto t : g[i]) {
      if (t == par[i]) continue;
      cmp[t] = (x == ind[i] + 1 ? cmp[i] : t);
      dfs2(t, x, g);
    }
  }

 public:
  HLD(vector<vector<int>> g, int r = 0)
      : par(g.size(), -1),
        siz(g.size(), 1),
        cmp(g.size(), r),
        ind(g.size()),
        dep(g.size(), 0) {
    dfs1(r, g);
    int x = 0;
    dfs2(r, x, g);
  }
  int lca(int a, int b) const {
    for (;; b = par[cmp[b]]) {
      if (ind[b] < ind[a]) swap(a, b);
      if (ind[cmp[b]] <= ind[a]) return a;
    }
  }
  pair<int, int> subtree(int i) const { return {ind[i], ind[i] + siz[i] - 1}; }
  int dist(int a, int b) const {
    if (ind[a] > ind[b]) swap(a, b);
    if (ind[a] + siz[a] > ind[b])
      return dep[b] - dep[a];
    else
      return dep[a] + dep[b] - 2 * dep[lca(a, b)];
  }
  vector<vector<pair<int, int>>> inducedTree(vector<int>& v) const {
    int m = v.size();
    vector<pair<int, int>> ord(m);
    for (int j = 0; j < m; ++j) ord[j] = {ind[v[j]], j};
    sort(ord.begin(), ord.end());
    for (int j = 0; j + 1 < m; ++j) {
      int x = lca(v[ord[j].second], v[ord[j + 1].second]);
      ord.emplace_back(ind[x], -(x + 1));
    }
    sort(ord.begin(), ord.end());
    vector<int> act;
    for (int j = (int)ord.size() - 1; j >= 0; --j) {
      if (j + 1 < ord.size() && ord[j + 1].first == ord[j].first) continue;
      if (ord[j].second < 0) {
        if (j == 0) continue;
        v.push_back(-ord[j].second - 1);
        ord[j].second = (int)v.size() - 1;
      }
      act.push_back(ord[j].second);
    }
    reverse(act.begin(), act.end());
    vector<int> sta;
    vector<vector<pair<int, int>>> g(act.size());
    for (auto j : act) {
      while (sta.size() > 1 && subtree(v[sta.back()]).second < ind[v[j]])
        sta.pop_back();
      if (!sta.empty()) {
        int i = sta.back();
        int d = dist(v[i], v[j]);
        g[i].emplace_back(j, d);
        g[j].emplace_back(i, d);
      }
      sta.push_back(j);
    }
    return g;
  }
};
int bins(const vector<int>& vec, int v) {
  int low = 0;
  int high = (int)vec.size() - 1;
  while (low != high) {
    int mid = (low + high) >> 1;
    if (vec[mid] < v)
      low = mid + 1;
    else
      high = mid;
  }
  return low;
}
void solve(const vector<pair<int, int>>& virus, const vector<int>& city,
           const vector<vector<pair<int, int>>>& g) {
  int n = g.size();
  vector<pair<pair<ll, int>, int>> sic(n, {{INF, -1}, 0});
  priority_queue<pair<pair<ll, int>, int>> que;
  for (int i = 0; i < virus.size(); ++i) {
    que.push({{0, -i}, virus[i].first});
    sic[virus[i].first] = {{0, i}, 0};
  }
  while (!que.empty()) {
    auto tmp = que.top();
    que.pop();
    int i = tmp.second;
    ll di = sic[i].first.first;
    int vi = sic[i].first.second;
    int sta = -sic[i].second;
    if (di != -tmp.first.first || vi != -tmp.first.second) continue;
    for (auto pr : g[i]) {
      int t = pr.first;
      int t_vi = vi;
      int t_sta = sta - pr.second;
      int rest =
          max(0, ((-t_sta) + (virus[vi].second - 1)) / (virus[vi].second));
      ll t_di = di + rest;
      t_sta += rest * virus[vi].second;
      pair<pair<ll, int>, int> off = {{t_di, t_vi}, -t_sta};
      if (off < sic[t]) {
        sic[t] = off;
        que.push({{-t_di, -t_vi}, t});
      }
    }
  }
  for (auto i : city) cout << sic[i].first.second + 1 << ' ';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  HLD hld(g);
  int q;
  cin >> q;
  for (; q; --q) {
    int k, m;
    cin >> k >> m;
    vector<int> imp(k + m);
    vector<pair<int, int>> virus(k);
    vector<int> city(m);
    for (int i = 0; i < k; ++i) {
      cin >> virus[i].first >> virus[i].second;
      --virus[i].first;
      imp[i] = virus[i].first;
    }
    for (int i = 0; i < m; ++i) {
      cin >> city[i];
      --city[i];
      imp[i + k] = city[i];
    }
    sort(imp.begin(), imp.end());
    imp.erase(unique(imp.begin(), imp.end()), imp.end());
    for (auto& pr : virus) pr.first = bins(imp, pr.first);
    for (auto& i : city) i = bins(imp, i);
    auto ind_g = hld.inducedTree(imp);
    solve(virus, city, ind_g);
  }
}
