#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int in[200005], out[200005], number[200005];
int t;
int p[20][200005];
int dis[200005];
void dfs(int first, int f) {
  in[first] = ++t;
  number[t] = first;
  p[0][first] = f;
  dis[first] = dis[f] + 1;
  for (auto it : v[first]) {
    if (it != f) {
      dfs(it, first);
    }
  }
  out[first] = t;
}
void build(int n) {
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      p[i][j] = p[i - 1][p[i - 1][j]];
    }
  }
}
int lca(int first, int second) {
  if (dis[first] > dis[second]) swap(first, second);
  int d = dis[second] - dis[first];
  for (int i = 0; i < 20; i++) {
    if (d & (1 << i)) {
      second = p[i][second];
    }
  }
  if (first == second) return first;
  for (int i = 19; i >= 0; i--) {
    if (p[i][second] != p[i][first]) {
      first = p[i][first];
      second = p[i][second];
    }
  }
  return p[0][first];
}
int getdis(int first, int second) {
  int lcaa = lca(first, second);
  return dis[first] + dis[second] - dis[lcaa] * 2;
}
bool cmp(const int &a, const int &b) { return in[a] < in[b]; }
vector<int> tmpv[200005];
int vis[200005];
int bln[200005];
int num[200005];
vector<int> buildtree(vector<int> &vertex) {
  vector<int> tmp;
  for (auto it : vertex) {
    tmp.push_back(it);
  }
  sort(tmp.begin(), tmp.end(), cmp);
  for (int i = 0; i < vertex.size() - 1; i++) {
    tmp.push_back(lca(tmp[i], tmp[i + 1]));
  }
  sort(tmp.begin(), tmp.end(), cmp);
  tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());
  for (auto it : tmp) tmpv[it].clear(), vis[it] = 0;
  vector<int> stk;
  stk.push_back(tmp[0]);
  for (int i = 1; i < tmp.size(); i++) {
    while (in[tmp[i]] > out[stk.back()]) stk.pop_back();
    tmpv[stk.back()].push_back(tmp[i]);
    tmpv[tmp[i]].push_back(stk.back());
    stk.push_back(tmp[i]);
  }
  return tmp;
}
int s[200005];
int heigh[200005];
void solve(vector<int> vertex) {
  auto vertex2 = buildtree(vertex);
  for (auto it : vertex) {
    vis[it] = 1;
    bln[it] = it;
    heigh[it] = 1e6;
  }
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      pq;
  for (auto it : vertex) {
    for (auto it2 : tmpv[it]) {
      if (!vis[it2]) {
        pq.push(make_pair((abs(dis[it] - dis[it2]) + s[it] - 1) / s[it],
                          make_pair(num[it], it2)));
      }
    }
  }
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    p.second.first = vertex[p.second.first - 1];
    if (!vis[p.second.second]) {
      vis[p.second.second] = 1;
      bln[p.second.second] = p.second.first;
    } else {
      continue;
    }
    for (auto it : tmpv[p.second.second]) {
      if (!vis[it]) {
        pq.push(make_pair((getdis(it, p.second.first) + s[p.second.first] - 1) /
                              s[p.second.first],
                          make_pair(num[p.second.first], it)));
      }
    }
  }
  for (auto it : vertex2) {
    for (auto it2 : tmpv[it]) {
      if (bln[it] != bln[it2] && dis[it] > dis[it2]) {
        int d = getdis(bln[it], bln[it2]) - 1;
        int a = bln[it], b = bln[it2];
        heigh[a] = d / (s[a] + s[b]) * s[a];
        if (num[a] > num[b]) {
          heigh[a] += max(0, d % (s[a] + s[b]) - s[b]);
        } else {
          heigh[a] += min(d % (s[a] + s[b]), s[a]);
        }
      }
    }
  }
}
int go(int first, int h) {
  for (int i = 0; i < 20; i++) {
    if (h & (1 << i)) {
      first = p[i][first];
    }
  }
  if (first == 0) return 1;
  return first;
}
struct node {
  node *l, *r;
  int a, b;
  int tag;
  node(int _a, int _b) : l(NULL), r(NULL), a(_a), b(_b), tag(0) {}
} * root;
void build(node *n) {
  if (n->a == n->b) return;
  int mid = (n->a + n->b) / 2;
  n->l = new node(n->a, mid);
  n->r = new node(mid + 1, n->b);
  build(n->l);
  build(n->r);
}
void push(node *n) {
  if (n->tag) {
    n->l->tag = n->tag;
    n->r->tag = n->tag;
    n->tag = 0;
  }
}
void add(node *n, int l, int r, int k) {
  if (n->a >= l && n->b <= r) {
    n->tag = k;
    return;
  }
  if (n->b < l || n->a > r) {
    return;
  }
  push(n);
  add(n->l, l, r, k);
  add(n->r, l, r, k);
}
int query(node *n, int first) {
  if (n->a == n->b) {
    return n->tag;
  }
  int mid = (n->a + n->b) / 2;
  push(n);
  if (first <= mid) {
    return query(n->l, first);
  } else {
    return query(n->r, first);
  }
}
int ans[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    v[first].push_back(second);
    v[second].push_back(first);
  }
  dfs(1, 0);
  build(n);
  root = new node(1, n);
  build(root);
  int q;
  scanf("%d", &q);
  while (q--) {
    int k, m;
    scanf("%d %d", &k, &m);
    vector<int> vertex;
    for (int i = 0; i < k; i++) {
      int first;
      scanf("%d", &first);
      scanf("%d", &s[first]);
      num[first] = i + 1;
      vertex.push_back(first);
    }
    solve(vertex);
    vector<pair<pair<int, int>, int> > vertex2;
    int now = 1;
    for (auto it : vertex) {
      int first = go(it, heigh[it]);
      vertex2.push_back(make_pair(make_pair(in[first], out[first]), now));
      now++;
    }
    sort(vertex2.begin(), vertex2.end());
    for (auto it : vertex2) {
      add(root, it.first.first, it.first.second, it.second);
    }
    while (m--) {
      int first;
      scanf("%d", &first);
      printf("%d ", query(root, in[first]));
    }
    printf("\n");
  }
}
