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;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int dir[8][2] = {-1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -1, 1, 1 - 1, 1, 1};
template <typename S, typename T>
inline bool Min(S &a, const T &b) {
  return a > b ? a = b, true : false;
}
template <typename S, typename T>
inline bool Max(S &a, const T &b) {
  return a < b ? a = b, true : false;
}
template <typename S, typename T>
inline void Adm(S &a, const T &b) {
  a = (a + b) % MOD;
  if (a < 0) a += MOD;
}
template <typename S, typename T>
inline void Mum(S &a, const T &b) {
  a = 1LL * a * b % MOD;
}
template <typename T>
inline bool IsPri(T x) {
  if (x < 2) return false;
  for (T i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
template <typename T>
inline T Gcd(T a, T b) {
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <typename T>
inline int BitCnt(T x) {
  int cnt = 0;
  while (x) ++cnt, x &= x - 1;
  return cnt;
}
template <typename T>
inline T MDis(T x1, T y1, T x2, T y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
template <typename T>
inline T MDis(T x1, T y1, T z1, T x2, T y2, T z2) {
  return abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2);
}
inline double EDis(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
inline double EDis(double x1, double y1, double z1, double x2, double y2,
                   double z2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
              (z1 - z2) * (z1 - z2));
}
inline long long Pow(long long a, long long n) {
  long long t = 1;
  a %= MOD;
  while (n > 0) {
    if (n & 1) t = t * a % MOD;
    a = a * a % MOD, n >>= 1;
  }
  return t % MOD;
}
inline int read() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  register int x = false;
  register char ch =
      p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
          ? EOF
          : *p1++;
  ;
  register bool sgn = false;
  while (ch != '-' && (ch < '0' || ch > '9'))
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  if (ch == '-')
    sgn = true,
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48),
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  return sgn ? -x : x;
}
const int N = 4e5 + 100;
vector<int> g[N];
int fz[N][20], dep[N], dfn[N], idx;
void DFS(int x, int f) {
  fz[x][0] = f, dep[x] = dep[f] + 1, dfn[x] = ++idx;
  for (int i = 1; i < 20; ++i) fz[x][i] = fz[fz[x][i - 1]][i - 1];
  for (int y : g[x])
    if (y != f) DFS(y, x);
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; dep[x] != dep[y]; --i)
    if (dep[fz[x][i]] >= dep[y]) x = fz[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; --i)
    if (fz[x][i] != fz[y][i]) x = fz[x][i], y = fz[y][i];
  return fz[x][0];
}
int a[N], v[N], vv[N], b[N], c[N], d[N], A, B, C, D;
int stk[N], top;
vector<int> e[N];
void Build() {
  sort(c + 1, c + C + 1, [](int x, int y) { return dfn[x] < dfn[y]; });
  C = unique(c + 1, c + C + 1) - c - 1;
  stk[top = 1] = d[D = 1] = 1;
  for (int i = 1; i <= C; ++i) {
    if (c[i] == 1) continue;
    int l = LCA(c[i], stk[top]);
    if (stk[top] == l)
      stk[++top] = c[i];
    else {
      while (top > 1 && dfn[stk[top - 1]] >= dfn[l]) {
        e[stk[top - 1]].push_back(stk[top]);
        e[stk[top]].push_back(stk[top - 1]);
        --top;
      }
      if (stk[top] != l) {
        e[l].push_back(stk[top]);
        e[stk[top]].push_back(l);
        stk[top] = l, ++D, d[D] = l;
      }
      stk[++top] = c[i];
    }
  }
  while (top > 1) {
    e[stk[top - 1]].push_back(stk[top]);
    e[stk[top]].push_back(stk[top - 1]);
    --top;
  }
}
long long calc(pair<long long, long long> p) {
  return (p.first + p.second - 1) / p.second;
}
struct node {
  int v, stv, sid;
  pair<long long, long long> w;
  bool operator<(const node &o) const {
    if (calc(w) != calc(o.w)) return calc(w) > calc(o.w);
    return sid > o.sid;
  }
};
pair<long long, long long> dis[N];
int vis[N];
void Dijkstra() {
  for (int i = 1; i <= C; ++i) dis[c[i]] = {INF, 1}, vis[c[i]] = 0;
  for (int i = 1; i <= D; ++i) dis[d[i]] = {INF, 1}, vis[d[i]] = 0;
  priority_queue<node> pq;
  for (int i = 1; i <= A; ++i)
    pq.push({a[i], a[i], i, {0, v[i]}}), dis[a[i]] = {0, v[i]};
  while (!pq.empty()) {
    int u = pq.top().v, stv = pq.top().stv, sid = pq.top().sid;
    pair<int, int> dd = pq.top().w;
    pq.pop();
    if (vis[u]) continue;
    dis[u] = dd;
    vis[u] = sid;
    for (int v : e[u]) {
      dd = {dis[u].first + abs(dep[u] - dep[v]), vv[stv]};
      if (calc(dis[v]) >= calc(dd)) pq.push({v, stv, sid, dd});
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v), g[v].push_back(u);
  }
  DFS(1, 0);
  int q;
  cin >> q;
  while (q--) {
    scanf("%d%d", &A, &B), C = A + B;
    for (int i = 1; i <= A; ++i)
      scanf("%d%d", &a[i], &v[i]), c[i] = a[i], vv[a[i]] = v[i];
    for (int i = 1; i <= B; ++i) scanf("%d", &b[i]), c[A + i] = b[i];
    Build();
    Dijkstra();
    for (int i = 1; i <= B; ++i) printf("%d%c", vis[b[i]], " \n"[i == B]);
    for (int i = 1; i <= C; ++i) e[c[i]].clear();
    for (int i = 1; i <= D; ++i) e[d[i]].clear();
  }
  return 0;
}