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>
namespace IO {
char gc() { return getchar(); }
template <typename Tp>
bool get1(Tp &x) {
  bool neg = 0;
  char c = gc();
  while (c != EOF && (c < '0' || c > '9') && c != '-') c = gc();
  if (c == '-') c = gc(), neg = 1;
  if (c == EOF) return false;
  x = 0;
  for (; c >= '0' && c <= '9'; c = gc()) x = x * 10 + c - '0';
  if (neg) x = -x;
  return true;
}
template <typename Tp>
void printendl(Tp x) {
  if (x < 0) putchar('-'), x = -x;
  static short a[40], sz;
  sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
  puts("");
}
}  // namespace IO
using IO::get1;
using IO::printendl;
const int inf = 0x3f3f3f3f;
const long long Linf = 1ll << 61;
namespace Tree {
constexpr int maxn = 200111;
std::vector<int> g[maxn], l[maxn];
void addedge(int u, int v, int w = 1) {
  g[u].push_back(v);
  l[u].push_back(w);
  g[v].push_back(u);
  l[v].push_back(w);
}
int dist[maxn];
int dfn[maxn], edfn[maxn], dep[maxn], timer, fa[20][maxn], seq[maxn];
void dfs(int x, int f = 0) {
  fa[0][x] = f;
  for (int i = 1; i < 20; i++) fa[i][x] = fa[i - 1][fa[i - 1][x]];
  dfn[x] = ++timer;
  seq[timer] = x;
  for (int i = 0; i < (int)g[x].size(); i++)
    if (g[x][i] != f) {
      dep[g[x][i]] = dep[x] + 1;
      dist[g[x][i]] = dist[x] + l[x][i];
      dfs(g[x][i], x);
    }
  edfn[x] = timer;
}
void prework(int n) {
  memset(dfn, 0, sizeof(int) * (n + 10));
  timer = 0;
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i);
}
int getlca(int u, int v) {
  if (dep[u] < dep[v]) std::swap(u, v);
  for (int i = 19; i >= 0; i--)
    if ((dep[u] - dep[v]) >> i) u = fa[i][u];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (fa[i][u] != fa[i][v]) u = fa[i][u], v = fa[i][v];
  return fa[0][u];
}
int getdist(int u, int v) {
  if (dfn[u] > dfn[v]) std::swap(u, v);
  if (edfn[u] >= dfn[v])
    return dist[v] - dist[u];
  else
    return dist[u] + dist[v] - 2 * dist[getlca(u, v)];
}
std::vector<std::pair<std::pair<int, int>, int>> extract(std::vector<int> &vs) {
  std::sort(vs.begin(), vs.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
  vs.erase(std::unique(vs.begin(), vs.end()), vs.end());
  for (int i = vs.size() - 1; i >= 1; i--) {
    int lca = getlca(vs[i], vs[i - 1]);
    if (lca) vs.push_back(getlca(vs[i], vs[i - 1]));
  }
  std::sort(vs.begin(), vs.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
  vs.erase(std::unique(vs.begin(), vs.end()), vs.end());
  static int stk[maxn], top;
  top = 0;
  std::vector<std::pair<std::pair<int, int>, int>> ret;
  for (auto x : vs) {
    while (top && edfn[stk[top]] < dfn[x]) top--;
    if (top)
      ret.emplace_back(std::make_pair(x, stk[top]), dist[x] - dist[stk[top]]);
    stk[++top] = x;
  }
  assert(vs.size() == ret.size() + 1);
  return ret;
}
}  // namespace Tree
const int maxn = 200111;
std::vector<int> g[maxn];
int n, q, k, m, virus[maxn], speed[maxn], qs[maxn];
int infected[maxn], rounds[maxn];
void update(int u, int id) {
  int dist = Tree::getdist(u, virus[id]);
  dist = (dist + speed[id] - 1) / speed[id];
  if (std::make_pair(dist, id) <= std::make_pair(rounds[u], infected[u])) {
    infected[u] = id;
    rounds[u] = dist;
  }
}
void dfs(int x, int f = 0) {
  for (int i = 0; i < (int)g[x].size(); i++)
    if (g[x][i] != f) {
      dfs(g[x][i], x);
      if (infected[g[x][i]] != inf) update(x, infected[g[x][i]]);
    }
}
void dfs2(int x, int f = 0) {
  for (int i = 0; i < (int)g[x].size(); i++)
    if (g[x][i] != f) {
      update(g[x][i], infected[x]);
      dfs2(g[x][i], x);
    }
}
void solve() {
  get1(k) && get1(m);
  std::vector<int> V;
  for (int i = 1; i <= k; i++) {
    get1(virus[i]) && get1(speed[i]);
    V.push_back(virus[i]);
  }
  for (int i = 1; i <= m; i++) {
    get1(qs[i]);
    V.push_back(qs[i]);
  }
  auto E = Tree::extract(V);
  for (auto v : V) {
    g[v].clear();
    infected[v] = rounds[v] = inf;
  }
  for (auto e : E) {
    g[e.first.first].push_back(e.first.second);
    g[e.first.second].push_back(e.first.first);
  }
  for (int i = 1; i <= k; i++) update(virus[i], i);
  int rt = V.front();
  dfs(rt);
  dfs2(rt);
  for (int i = 1; i <= m; i++)
    printf("%d%c", infected[qs[i]], i == m ? '\n' : ' ');
}
int main() {
  get1(n);
  for (int i = 1, u, v; i < n; i++) {
    get1(u) && get1(v);
    Tree::addedge(u, v);
  }
  Tree::prework(n);
  get1(q);
  while (q--) solve();
  return 0;
}
