#include <bits/stdc++.h>
using namespace std;
const int IMP = (-1);
struct TreeNode {
  int v;
  int p;
  int l, r;
  int lr, rl;
  int ml, mr;
  int tl, tr;
  long long int vs;
  int vc;
};
TreeNode tn[100008];
void recurse_one(int v, int tl, int tr);
void recurse_two(int v, long long int vs, int vc);
int main() {
  double A;
  int i, r = (-1), V, Q, v;
  scanf("%d", &V);
  for (i = 0; i < V; i++) {
    scanf("%d %d", &tn[i].p, &tn[i].v);
    tn[i].p--;
    if (tn[i].p < 0) r = i;
    tn[i].l = IMP;
    tn[i].r = IMP;
  }
  for (i = 0; i < V; i++)
    if (tn[i].p >= 0) {
      if (tn[i].v < tn[tn[i].p].v) tn[tn[i].p].l = i;
      if (tn[i].v > tn[tn[i].p].v) tn[tn[i].p].r = i;
    }
  vector<pair<int, int> > vr;
  for (i = 0; i < V; i++)
    if (tn[i].l < 0) vr.push_back(pair<int, int>(tn[i].v, i));
  sort(vr.begin(), vr.end());
  recurse_one(r, IMP, IMP);
  recurse_two(r, 0, 0);
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d", &v);
    vector<pair<int, int> >::iterator it =
        lower_bound(vr.begin(), vr.end(), pair<int, int>(v, -1));
    if (it == vr.end()) {
      const TreeNode &lf = tn[vr.back().second];
      A = lf.vs / (double)lf.vc;
    } else if (it == vr.begin()) {
      const TreeNode &lf = tn[vr[0].second];
      A = lf.vs / (double)lf.vc;
    } else {
      int x = it - vr.begin();
      const TreeNode &l1 = tn[vr[x - 1].second];
      const TreeNode &l2 = tn[vr[x - 0].second];
      assert(l1.tl == l2.tr);
      if (v < tn[l1.tl].v)
        A = l1.vs / (double)l1.vc;
      else
        A = l2.vs / (double)l2.vc;
    }
    printf("%.12lf\n", A);
  }
  return 0;
}
void recurse_one(int v, int tl, int tr) {
  TreeNode &nd = tn[v];
  if (nd.l < 0) {
    assert(nd.r < 0);
    nd.lr = nd.rl = IMP;
    nd.ml = nd.mr = nd.v;
    nd.tl = tl;
    nd.tr = tr;
  } else {
    recurse_one(nd.l, v, tr);
    recurse_one(nd.r, tl, v);
    nd.lr = tn[nd.l].mr;
    nd.rl = tn[nd.r].ml;
    nd.ml = tn[nd.l].ml;
    nd.mr = tn[nd.r].mr;
  }
}
void recurse_two(int v, long long int vs, int vc) {
  TreeNode &nd = tn[v];
  if (nd.l < 0) {
    assert(nd.r < 0);
    nd.vs = vs;
    nd.vc = vc;
  } else {
    recurse_two(nd.l, vs + nd.rl, vc + 1);
    recurse_two(nd.r, vs + nd.lr, vc + 1);
  }
}
