#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
struct vertex {
  int val, l, r, lval, rval;
} arr[100005];
int p[100005];
map<int, double> M;
pair<long long, long long> DFS1(int pos) {
  if (arr[pos].l == -2) {
    return make_pair((long long)arr[pos].val, (long long)arr[pos].val);
  }
  pair<long long, long long> ll = DFS1(arr[pos].l);
  pair<long long, long long> rr = DFS1(arr[pos].r);
  arr[pos].lval = ll.second;
  arr[pos].rval = rr.first;
  return make_pair(ll.first, rr.second);
}
void DFS2(int pos, long long sum = 0, int q = 0, int p = -2,
          int mn = -1000000005) {
  if (arr[pos].l == -2) {
    M[-mn] = (double)sum / q;
    return;
  }
  DFS2(arr[pos].l, sum + arr[pos].rval, q + 1, pos, mn);
  DFS2(arr[pos].r, sum + arr[pos].lval, q + 1, pos, arr[pos].val);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i] >> arr[i].val;
    arr[i].l = -2;
    arr[i].r = -2;
    p[i]--;
  }
  int root = -1;
  for (int i = 0; i < n; i++) {
    if (p[i] != -2) {
      if (arr[p[i]].val > arr[i].val) {
        arr[p[i]].l = i;
      } else {
        arr[p[i]].r = i;
      }
    } else {
      root = i;
    }
  }
  DFS1(root);
  DFS2(root);
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int v;
    cin >> v;
    map<int, double>::iterator it = M.lower_bound(-v);
    if (it == M.end()) {
      --it;
    }
    cout << fixed << setprecision(10) << it->second << endl;
  }
  return 0;
}
