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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 200005, K = 20;
int a[N], b[N], st[N], dp[N][K], in[N], sp[N], SP[N], out[N], ti, dep[N], an[N],
    q[N << 2];
vector<int> v[N], e[N];
inline bool zx(int a, int b) { return in[a] <= in[b] && out[a] >= out[b]; }
void dfs(int p, int fa) {
  dp[p][0] = fa;
  in[p] = ++ti;
  dep[p] = dep[fa] + 1;
  for (auto i : v[p])
    if (i != fa) {
      dfs(i, p);
    }
  out[p] = ti;
}
int lca(int x, int y) {
  if (zx(x, y)) return x;
  for (int i = (int)(K - 1); i >= (int)(0); i--)
    if (dp[x][i] && !zx(dp[x][i], y)) x = dp[x][i];
  return dp[x][0];
}
int dis(int x, int y) {
  int t = lca(x, y);
  return dep[x] + dep[y] - dep[t] * 2;
}
int chu(int x, int y) { return (x + y - 1) / y; }
int cmp(int x, int y, int t) {
  if (!x || !y) return x | y;
  int X = chu(dis(x, t), sp[x]), Y = chu(dis(y, t), sp[y]);
  if (X != Y)
    return X < Y ? x : y;
  else
    return SP[x] < SP[y] ? x : y;
}
void d1(int p) {
  for (auto i : e[p]) {
    d1(i);
    an[p] = cmp(an[i], an[p], p);
  }
}
void d2(int p) {
  for (auto i : e[p]) {
    an[i] = cmp(an[p], an[i], i);
    d2(i);
  }
}
bool cm(int a, int b) { return in[a] < in[b]; }
int main() {
  int n = read();
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int s = read(), t = read();
    v[s].push_back(t);
    v[t].push_back(s);
  }
  dfs(1, 0);
  for (int i = (int)(1); i <= (int)(K - 1); i++)
    for (int j = (int)(1); j <= (int)(n); j++)
      dp[j][i] = dp[dp[j][i - 1]][i - 1];
  int Q = read();
  while (Q--) {
    int k = read(), m = read(), tot = 1;
    q[1] = 1;
    for (int i = (int)(1); i <= (int)(k); i++) {
      a[i] = read();
      sp[a[i]] = read();
      SP[a[i]] = i;
      an[a[i]] = a[i];
      q[++tot] = a[i];
    }
    for (int i = (int)(1); i <= (int)(m); i++) {
      b[i] = read();
      q[++tot] = b[i];
    }
    sort(q + 1, q + tot + 1, cm);
    for (int i = (int)(tot - 1); i >= (int)(1); i--)
      q[++tot] = lca(q[i], q[i + 1]);
    sort(q + 1, q + tot + 1, cm);
    tot = unique(q + 1, q + tot + 1) - q - 1;
    int top = 1;
    st[1] = 1;
    for (int i = (int)(2); i <= (int)(tot); i++) {
      while (!zx(st[top], q[i])) top--;
      e[st[top]].push_back(q[i]);
      st[++top] = q[i];
    }
    d1(1);
    d2(1);
    for (int i = (int)(1); i <= (int)(m); i++) wri(SP[an[b[i]]]);
    puts("");
    for (int i = (int)(1); i <= (int)(tot); i++) {
      an[q[i]] = 0;
      e[q[i]].clear();
    }
  }
}