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;
template <typename T>
vector<T>& operator--(vector<T>& v) {
  for (auto& i : v) --i;
  return v;
}
template <typename T>
vector<T>& operator++(vector<T>& v) {
  for (auto& i : v) ++i;
  return v;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& i : v) os << i << ' ';
  return os;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
template <typename T, typename U>
void umin(T& a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
void umax(T& a, U b) {
  if (a < b) a = b;
}
vector<int> lca_ind;
vector<vector<int>> lca_sparse;
vector<int> lca_p2;
vector<int> lca_depth;
void build_lca_sparse(vector<vector<int>>& g, int root = 0) {
  int n = g.size();
  vector<int> euler;
  lca_ind.resize(n);
  lca_depth.assign(n, -1);
  function<void(int, int)> dfs = [&](int v, int depth) {
    lca_ind[v] = euler.size();
    euler.push_back(v);
    lca_depth[v] = depth;
    for (auto k : g[v]) {
      if (lca_depth[k] == -1) {
        dfs(k, depth + 1);
        euler.push_back(v);
      }
    }
  };
  dfs(root, 0);
  int m = euler.size();
  int log = 1;
  while ((1 << log) < m) ++log;
  lca_sparse.resize(log);
  lca_sparse[0].resize(m);
  lca_p2.resize(m + 1);
  int pp2 = 0;
  for (int i = 1; i < lca_p2.size(); ++i) {
    if (1 << (pp2 + 1) <= i) ++pp2;
    lca_p2[i] = pp2;
  }
  lca_p2[0] = 0;
  for (int i = 0; i < m; ++i) lca_sparse[0][i] = euler[i];
  for (int i = 1; i < log; ++i) {
    lca_sparse[i].assign(m, 0);
    for (int j = 0; j < m - (1 << (i - 1)); ++j) {
      int v1 = lca_sparse[i - 1][j], v2 = lca_sparse[i - 1][j + (1 << (i - 1))];
      if (lca_depth[v1] < lca_depth[v2])
        lca_sparse[i][j] = v1;
      else
        lca_sparse[i][j] = v2;
    }
  }
}
int get_lca(int u, int v) {
  if (u == v) return u;
  u = lca_ind[u];
  v = lca_ind[v];
  if (u > v) swap(u, v);
  int v1 = lca_sparse[lca_p2[v - u + 1]][u],
      v2 = lca_sparse[lca_p2[v - u + 1]][v - (1 << lca_p2[v - u + 1]) + 1];
  if (lca_depth[v1] < lca_depth[v2])
    return v1;
  else
    return v2;
}
int dist(int u, int v) {
  return lca_depth[u] + lca_depth[v] - 2 * lca_depth[get_lca(u, v)];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  build_lca_sparse(g, 0);
  vector<int> order;
  vector<bool> u(n, false);
  vector<int> tin(n), tout(n);
  int timer = 0;
  function<void(int)> dfs = [&](int v) {
    tin[v] = timer++;
    u[v] = true;
    for (auto k : g[v]) {
      if (!u[k]) {
        dfs(k);
      }
    }
    tout[v] = timer++;
  };
  dfs(0);
  vector<int> inf(n, 0);
  vector<int> col(n);
  int tinf = 1;
  vector<vector<pair<int, int>>> g0(n);
  int q;
  cin >> q;
  while (q--) {
    int k, m;
    cin >> k >> m;
    vector<int> speed(k);
    vector<int> st(k);
    for (int i = 0; i < k; ++i) {
      cin >> st[i] >> speed[i];
      --st[i];
    }
    vector<int> ess(m);
    cin >> ess;
    --ess;
    vector<int> ver = ess;
    for (int i = 0; i < k; ++i) {
      ver.push_back(st[i]);
    }
    sort(ver.begin(), ver.end());
    ver.erase(unique(ver.begin(), ver.end()), ver.end());
    sort(ver.begin(), ver.end(), [&](int i, int j) { return tin[i] < tin[j]; });
    int x = ver.size();
    for (int i = 0; i < x - 1; ++i) {
      ver.push_back(get_lca(ver[i], ver[i + 1]));
    }
    ver.push_back(get_lca(ver[0], ver[x - 1]));
    sort(ver.begin(), ver.end());
    ver.erase(unique(ver.begin(), ver.end()), ver.end());
    vector<pair<int, int>> ev;
    for (auto v : ver) {
      ev.emplace_back(tin[v], v);
      ev.emplace_back(tout[v], v);
    }
    sort(ev.begin(), ev.end());
    vector<int> sta;
    for (auto [tm, v] : ev) {
      if (!sta.empty() && sta.back() == v) {
        sta.pop_back();
      } else {
        if (!sta.empty()) {
          int d = dist(v, sta.back());
          g0[sta.back()].emplace_back(v, d);
          g0[v].emplace_back(sta.back(), d);
        }
        sta.push_back(v);
      }
    }
    set<pair<pair<int, int>, pair<int, int>>> s;
    for (int i = 0; i < k; ++i) {
      inf[st[i]] = tinf;
      col[st[i]] = i;
      for (auto [u, w] : g0[st[i]]) {
        s.emplace(make_pair((w + speed[i] - 1) / speed[i], i), make_pair(u, w));
      }
    }
    while (!s.empty()) {
      42;
      ;
      auto [sth, vv] = *s.begin();
      auto v = vv.first;
      int ind = sth.second;
      s.erase(s.begin());
      if (inf[v] == tinf) continue;
      inf[v] = tinf;
      col[v] = ind;
      for (auto [u, w] : g0[v]) {
        if (inf[u] < tinf) {
          s.emplace(
              make_pair((vv.second + w + speed[ind] - 1) / speed[ind], ind),
              make_pair(u, vv.second + w));
        }
      }
    }
    for (int i = 0; i < m; ++i) {
      cout << col[ess[i]] + 1 << ' ';
    }
    cout << '\n';
    for (auto x : ver) {
      g0[x].clear();
    }
    ++tinf;
  }
  return 0;
}
