#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e9;
int read() {
  int x = 0, F = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') F = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
  return x * F;
}
const int ot = 20;
namespace Tree {
int fa[N][ot + 1], mi[N][18];
int dep[N], tot, dfn[N];
vector<pair<int, int> > G[N];
void init(int x, int f) {
  dfn[x] = ++tot;
  dep[x] = dep[f] + 1;
  for (int i = 1; i <= ot; i++)
    fa[x][i] = fa[fa[x][i - 1]][i - 1],
    mi[x][i] = min(mi[x][i - 1], mi[fa[x][i - 1]][i - 1]);
  for (pair<int, int> now : G[x]) {
    int to = now.first;
    if (to == f) continue;
    mi[to][0] = now.second;
    fa[to][0] = x;
    init(to, x);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = ot; i >= 0; i--) {
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
    if (u == v) return u;
  }
  for (int i = ot; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
int dis(int u, int v) {
  int lc = lca(u, v);
  return dep[u] + dep[v] - 2 * dep[lc];
}
};  // namespace Tree
using namespace Tree;
struct dat {
  int u, t, c, d;
};
inline bool operator<(dat x, dat y) {
  return x.t == y.t ? x.c > y.c : x.t > y.t;
}
priority_queue<dat> q;
int col[N];
namespace XTree {
int stk[N];
int b[N];
int tp, cnt, used[N];
vector<pair<int, int> > g[N];
int usd[N];
bool cmp(int x, int y) { return Tree::dfn[x] < Tree::dfn[y]; }
void addEdge(int u, int v) {
  int d = Tree::dis(u, v);
  g[u].push_back(make_pair(v, d));
  g[v].push_back(make_pair(u, d));
}
void build(int k) {
  sort(b + 1, b + 1 + k, cmp);
  k = unique(b + 1, b + 1 + k) - b - 1;
  cnt = 0;
  for (int i = 1; i <= k; ++i) {
    int u = b[i];
    usd[++cnt] = u;
    if (!tp) {
      stk[++tp] = u;
      continue;
    }
    int lca = Tree::lca(u, stk[tp]);
    while (tp && dep[stk[tp - 1]] >= dep[lca])
      addEdge(stk[tp - 1], stk[tp]), --tp;
    if (stk[tp] != lca) addEdge(lca, stk[tp]), stk[tp] = lca, usd[++cnt] = lca;
    stk[++tp] = u;
  }
  while (--tp) addEdge(stk[tp], stk[tp + 1]);
}
void clear() {
  for (int i = 1; i <= cnt; ++i) col[usd[i]] = 0, g[usd[i]].clear();
}
}  // namespace XTree
int s[N], vt[N], ut[N];
void solve() {
  while (!q.empty()) {
    dat p = q.top();
    q.pop();
    if (col[p.u]) continue;
    col[p.u] = p.c;
    for (auto e : XTree::g[p.u])
      if (!col[e.first])
        q.push((dat){e.first, (p.d + e.second - 1) / vt[p.c] + 1, p.c,
                     p.d + e.second});
  }
}
int main() {
  int n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    G[u].push_back(make_pair(v, 1));
    G[v].push_back(make_pair(u, 1));
  }
  init(1, 0);
  int Q = read();
  while (Q--) {
    int k = read(), m = read();
    int cnt = 0;
    for (int i = 1; i <= k; i++) {
      s[i] = read();
      vt[i] = read();
      XTree::b[++cnt] = s[i];
      q.push((dat){s[i], 0, i, 0});
    }
    for (int i = 1; i <= m; i++) {
      ut[i] = read();
      XTree::b[++cnt] = ut[i];
    }
    XTree::build(cnt);
    solve();
    for (int i = 1; i <= m; i++) {
      printf("%d ", col[ut[i]]);
    }
    puts("");
    XTree::clear();
  }
}
