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 void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, i, j, dfn[200005], ti, fa[200005][19], stk[200005], tp, dep[200005],
    a[200005], b[200005], c[400005], trs[200005], col[200005], s[200005];
vector<int> e[200005], all, ee[200005];
int la, lb, len;
int fx, fy, cas = 0;
bool cmp(int x, int y) { return dfn[x] < dfn[y]; }
void dfs1(int x, int p) {
  dfn[x] = ++ti;
  fa[x][0] = p;
  for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++) {
    if (*it == p) continue;
    dep[*it] = dep[x] + 1;
    dfs1(*it, x);
  }
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int t = dep[x] - dep[y], i;
  for ((i) = (18); (i) >= (0); (i)--) {
    if ((t >> i) & 1) {
      x = fa[x][i];
    }
  }
  if (x == y) return x;
  for ((i) = (18); (i) >= (0); (i)--) {
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  }
  return fa[x][0];
}
void add(int x, int y) {
  all.push_back(x);
  all.push_back(y);
  ee[x].push_back(y);
  ee[y].push_back(x);
}
void ins(int x) {
  if (tp <= 1) {
    stk[++tp] = x;
    return;
  }
  int z = lca(x, stk[tp]);
  if (z == stk[tp]) {
    stk[++tp] = x;
    return;
  }
  while (tp > 1 && dfn[stk[tp - 1]] >= dfn[z]) {
    add(stk[tp - 1], stk[tp]);
    tp--;
  }
  if (z != stk[tp]) add(z, stk[tp]);
  stk[tp] = z;
  stk[++tp] = x;
}
struct node {
  int dis, rem, col;
} dis[200005];
bool operator<(node x, node y) {
  if (x.dis != y.dis) return x.dis > y.dis;
  if (x.col != y.col) return x.col > y.col;
  return x.rem > y.rem;
}
void solve() {
  int i, j;
  priority_queue<pair<node, int> > qx;
  for (((i)) = (1); ((i)) <= ((la)); ((i))++) {
    qx.push(make_pair(dis[a[i]], a[i]));
  }
  while (!qx.empty()) {
    int x = qx.top().second;
    qx.pop();
    if (trs[x]) continue;
    trs[x] = 1;
    for (__typeof((ee[x]).begin()) it = (ee[x]).begin(); it != (ee[x]).end();
         it++) {
      node nxt = dis[x];
      nxt.rem -= abs(dep[x] - dep[*it]);
      int tmp = ((-nxt.rem) + s[col[x]] - 1) / s[col[x]];
      nxt.dis += tmp;
      nxt.rem += tmp * s[col[x]];
      if (!col[*it] || dis[*it] < nxt) {
        if (n == 10 && fx == 2 && fy == 3) {
          if (!binary_search(all.begin(), all.end(), *it)) exit(cas);
        }
        dis[*it] = nxt;
        col[*it] = col[x];
        qx.push(make_pair(dis[*it], *it));
      }
    }
  }
  for (((i)) = (1); ((i)) <= ((lb)); ((i))++) {
    printf("%d%c", col[b[i]], (i == lb ? '\n' : ' '));
  }
}
int main() {
  read(n);
  for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) {
    int x, y;
    read(x);
    read(y);
    if (i == 1) {
      fx = x;
      fy = y;
    }
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs1(1, 0);
  for (((j)) = (1); ((j)) <= ((18)); ((j))++) {
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
    }
  }
  read(m);
  while (m--) {
    read(la);
    read(lb);
    len = la + lb;
    ++cas;
    for (((i)) = (1); ((i)) <= ((la)); ((i))++) {
      int t;
      read(a[i]);
      read(t);
      s[i] = t;
      dis[a[i]] = (node){0, 0, i};
      col[a[i]] = i;
      c[i] = a[i];
    }
    for (((i)) = (1); ((i)) <= ((lb)); ((i))++) {
      read(b[i]);
      c[i + la] = b[i];
    }
    sort(c + 1, c + len + 1, cmp);
    stk[tp = 1] = 1;
    for (((i)) = (1); ((i)) <= ((len)); ((i))++) {
      all.push_back(c[i]);
      if (c[i] != 1 && c[i] != c[i - 1]) {
        ins(c[i]);
      }
    }
    while (tp > 1) {
      add(stk[tp], stk[tp - 1]);
      tp--;
    }
    sort(all.begin(), all.end());
    solve();
    for (__typeof((all).begin()) it = (all).begin(); it != (all).end(); it++) {
      ee[*it].clear();
      col[*it] = trs[*it] = 0;
      dis[*it] = dis[0];
    }
    all.clear();
  }
  return 0;
}
