#include <bits/stdc++.h>
using namespace std;
void dbg(char* fmt, ...) {}
void sum(std::pair<long long, long long>& cur,
         std::pair<long long, long long> other) {
  cur.first += other.first;
  cur.second += other.second;
}
struct RangeTree {
  vector<std::pair<long long, long long> > prefsum;
  RangeTree(int n) {
    prefsum = vector<std::pair<long long, long long> >(
        n + 1, std::pair<long long, long long>(0, 0));
  }
  void add(int l, int r, int v) {
    dbg("add %d %d %d\n", l, r, v);
    sum(prefsum[l], std::pair<long long, long long>(v, 1));
    sum(prefsum[r + 1], std::pair<long long, long long>(-v, -1));
  }
  vector<std::pair<long long, long long> > getValues() {
    vector<std::pair<long long, long long> > res(int(prefsum.size()) - 1);
    std::pair<long long, long long> cur(0, 0);
    for (int i = 0; i < int(prefsum.size()) - 1; ++i) {
      sum(cur, prefsum[i]);
      res[i] = cur;
    }
    return res;
  }
};
const int N = 200000;
int __left[N], __right[N];
int par[N], key[N];
int targ[N];
int _min[N], _max[N];
void calc(int root) {
  if (__left[root] == -1)
    _min[root] = _max[root] = key[root];
  else {
    calc(__left[root]);
    calc(__right[root]);
    _min[root] = _min[__left[root]];
    _max[root] = _max[__right[root]];
  }
}
vector<std::pair<long long, long long> > keys;
void solve(RangeTree& tree, int root, int minV, int maxV) {
  if (__left[root] == -1) return;
  tree.add(key[root] + 1, maxV, keys[_max[__left[root]]].first);
  tree.add(minV, key[root] - 1, keys[_min[__right[root]]].first);
  solve(tree, __left[root], minV, key[root] - 1);
  solve(tree, __right[root], key[root] + 1, maxV);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &par[i], &key[i]);
    --par[i];
    keys.push_back(std::pair<long long, long long>(key[i], -1));
  }
  memset(__left, 0xFF, sizeof(__left));
  int root;
  for (int i = 0; i < n; ++i)
    if (par[i] == -2)
      root = i;
    else {
      if (key[par[i]] > key[i])
        __left[par[i]] = i;
      else
        __right[par[i]] = i;
    }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &targ[i]);
    keys.push_back(std::pair<long long, long long>(targ[i], i));
  }
  sort(keys.begin(), keys.end());
  for (int i = 0; i < n; ++i)
    key[i] = lower_bound(keys.begin(), keys.end(),
                         std::pair<long long, long long>(key[i], -1)) -
             keys.begin();
  calc(root);
  RangeTree tree((int)keys.size());
  solve(tree, root, 0, int(keys.size()) - 1);
  vector<std::pair<long long, long long> > res = tree.getValues();
  vector<double> ans(q);
  for (int i = 0; i < int(keys.size()); ++i)
    if (keys[i].second != -1) {
      std::pair<long long, long long> cur = res[i];
      dbg("%d - %d/%d\n", targ[keys[i].second], cur.first, cur.second);
      ans[keys[i].second] = double(cur.first) / cur.second;
    }
  for (int i = 0; i < q; ++i) printf("%.15lf\n", ans[i]);
  return 0;
}
