#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n, m, k, t, cnt, top, tot;
int in[800010], out[800010], tp[800010], f[800010], son[800010], dep[800010],
    siz[800010];
int q[800010], st[800010], fa[800010], col[800010], bel[800010], s[800010],
    sp[800010];
struct edge {
  int to, nxt;
} e[800010];
int head[800010], edge_cnt;
void add(int from, int to) {
  e[++edge_cnt] = {to, head[from]}, head[from] = edge_cnt;
}
bool cmp(const int &a, const int &b) { return in[a] < in[b]; }
void dfs_son(int x, int fath) {
  siz[x] = 1, f[x] = fath, dep[x] = dep[fath] + 1;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (y == fath) continue;
    dfs_son(y, x), siz[x] += siz[y];
    if (siz[son[x]] < siz[y]) son[x] = y;
  }
}
void dfs_chain(int x, int t) {
  in[x] = ++cnt, tp[x] = t;
  if (son[x]) dfs_chain(son[x], t);
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (in[y]) continue;
    dfs_chain(y, y);
  }
  out[x] = cnt;
}
int lca(int x, int y) {
  while (tp[x] != tp[y]) {
    if (dep[tp[x]] < dep[tp[y]]) swap(x, y);
    x = f[tp[x]];
  }
  if (in[x] > in[y]) swap(x, y);
  return x;
}
int dis(int x, int y) { return dep[x] + dep[y] - dep[lca(x, y)] * 2; }
int calc(int x, int y) { return (dis(x, y) + sp[col[x]] - 1) / sp[col[x]]; }
void build() {
  sort(s + 1, s + tot + 1, cmp);
  for (int i = tot - 1; i; --i) s[++tot] = lca(s[i], s[i + 1]);
  sort(s + 1, s + tot + 1, cmp), tot = unique(s + 1, s + tot + 1) - s - 1,
                                 top = 0;
  for (int i = 1; i <= tot; ++i) {
    while (top && out[st[top]] < in[s[i]]) top--;
    if (top) fa[s[i]] = st[top];
    st[++top] = s[i];
  }
}
int get(int x, int a, int b) {
  if (!x) return 0;
  if (!a || !b) return a + b;
  int da = calc(a, x), db = calc(b, x);
  if (da == db) return col[a] < col[b] ? a : b;
  return da < db ? a : b;
}
void clear() {
  for (int i = 1; i <= tot; ++i) fa[s[i]] = bel[s[i]] = 0;
  tot = 0;
}
int main() {
  read(n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    read(x), read(y);
    add(x, y), add(y, x);
  }
  dfs_son(1, 0), dfs_chain(1, 1);
  read(m);
  while (m--) {
    read(k), read(t);
    for (int i = 1; i <= k; ++i) {
      int x;
      read(x), read(sp[i]);
      col[x] = i, bel[x] = x, s[++tot] = x;
    }
    for (int i = 1; i <= t; ++i) {
      int x;
      read(x), s[++tot] = x, q[i] = x;
    }
    build();
    for (int i = tot; i; --i)
      bel[fa[s[i]]] = get(fa[s[i]], bel[fa[s[i]]], bel[s[i]]);
    for (int i = 1; i <= tot; ++i)
      bel[s[i]] = get(s[i], bel[fa[s[i]]], bel[s[i]]);
    for (int i = 1; i <= t; ++i) printf("%d%c", col[bel[q[i]]], " \n"[i == t]);
    clear();
  }
  return 0;
}
