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;
inline int read() {
  int k = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') {
    k = k * 10 + ch - 48;
    ch = getchar();
  }
  return k;
}
const int maxn = 2e5 + 5;
const int inf = 1e9;
int n, m, Q, num1, num2;
int h[maxn], H[maxn], Cnt, cnt;
struct d {
  int to, next;
} a[maxn * 2], A[maxn * 2];
inline void add(int x, int y) {
  a[++cnt] = (d){y, h[x]};
  h[x] = cnt;
}
int fa[maxn], dept[maxn], size[maxn], son[maxn], top[maxn], dfn[maxn], Sign;
void dfs1(int x, int father) {
  fa[x] = father;
  dept[x] = dept[fa[x]] + 1;
  size[x] = 1;
  for (int i = h[x]; i; i = a[i].next) {
    if (a[i].to == fa[x]) continue;
    dfs1(a[i].to, x);
    size[x] += size[a[i].to];
    if (size[a[i].to] > size[son[x]]) son[x] = a[i].to;
  }
}
void dfs2(int x, int Top) {
  top[x] = Top;
  dfn[x] = ++Sign;
  if (!son[x]) return;
  dfs2(son[x], Top);
  for (int i = h[x]; i; i = a[i].next) {
    if (a[i].to == fa[x] || a[i].to == son[x]) continue;
    dfs2(a[i].to, a[i].to);
  }
}
int LCA(int x, int y) {
  while (top[x] != top[y]) {
    if (dept[top[x]] < dept[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  if (dept[x] < dept[y]) swap(x, y);
  return y;
}
bool cmp(int x, int y) { return dfn[x] < dfn[y]; }
void Add(int x, int y) {
  A[++Cnt] = (d){y, H[x]};
  H[x] = Cnt;
}
int num, s[maxn];
void insert(int x) {
  if (x == 1) {
    return;
  }
  if (num == 1) {
    s[++num] = x;
    return;
  }
  int lca = LCA(s[num], x);
  while (num > 1 && dfn[s[num - 1]] >= dfn[lca]) {
    Add(s[num - 1], s[num]);
    --num;
  }
  if (lca != s[num]) {
    Add(lca, s[num]);
    s[num] = lca;
  }
  s[++num] = x;
  return;
}
int p[maxn * 2], q[maxn];
void build() {
  num = 0;
  s[++num] = 1;
  sort(p + 1, p + 1 + p[0], cmp);
  p[0] = unique(p + 1, p + 1 + p[0]) - p - 1;
  for (int i = 1; i <= p[0]; ++i) insert(p[i]);
  while (num > 1) Add(s[num - 1], s[num]), --num;
}
struct point {
  int x, y;
  bool operator<(const point& A) const { return x == A.x ? y < A.y : x < A.x; }
} c[maxn], col[maxn];
const point Inf = (point){inf, inf};
int lj[maxn], bel[maxn];
point Get(int x, int y) {
  int lca = LCA(x, c[y].x), dis = dept[x] + dept[c[y].x] - 2 * dept[lca];
  return (point){(dis - 1) / c[y].y + 1, y};
}
void dfs3(int x, int father) {
  lj[++lj[0]] = x;
  if (!bel[x]) col[x] = Inf;
  for (int i = H[x]; i; i = A[i].next) {
    if (A[i].to == father) continue;
    dfs3(A[i].to, x);
    int k = bel[A[i].to];
    if (!k) continue;
    point now = Get(x, k);
    if (now < col[x]) col[x] = now, bel[x] = bel[A[i].to];
  }
}
void dfs4(int x, int father) {
  if (father && x != c[bel[x]].x) {
    point k = Get(x, bel[father]);
    if (k < col[x]) col[x] = k, bel[x] = bel[father];
  }
  for (int i = H[x]; i; i = A[i].next) {
    if (A[i].to == father) continue;
    dfs4(A[i].to, x);
  }
}
void Solve() {
  build();
  dfs3(1, 0);
  dfs4(1, 0);
}
void Clear() {
  for (int i = 1; i <= lj[0]; ++i) {
    bel[lj[i]] = 0;
    H[lj[i]] = 0;
  }
  Cnt = 0;
  p[0] = 0;
  lj[0] = 0;
}
int main() {
  n = read();
  int x, y;
  for (int i = 1; i < n; ++i) {
    x = read();
    y = read();
    add(x, y);
    add(y, x);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  Q = read();
  for (int i = 1; i <= Q; ++i) {
    num1 = read();
    num2 = read();
    for (int i = 1; i <= num1; ++i) {
      c[i] = (point){read(), read()};
      bel[c[i].x] = i;
      p[++p[0]] = c[i].x;
      col[c[i].x] = (point){0, i};
    }
    for (int i = 1; i <= num2; ++i) {
      q[i] = read();
      p[++p[0]] = q[i];
    }
    Solve();
    for (int i = 1; i <= num2; ++i) cout << col[q[i]].y << ' ';
    cout << '\n';
    Clear();
  }
  return 0;
}
