#include <bits/stdc++.h>
using namespace std;
const double E = 1e-8;
const int inf = (int)1e9;
const int maxE = 100010;
int root;
int l[maxE];
int r[maxE];
int vc = 0;
int key[maxE];
int a[maxE];
int dk[maxE];
long long da[maxE];
long long leftV[maxE];
long long rightV[maxE];
void add(int x0, int sdkfjb, int i) {
  key[i] = sdkfjb;
  if (x0 == -1)
    root = i;
  else if (key[x0] > sdkfjb)
    l[x0] = i;
  else
    r[x0] = i;
}
void dfs(int x) {
  if (l[x] == 0) {
    leftV[x] = key[x];
    rightV[x] = key[x];
  } else {
    dfs(l[x]);
    dfs(r[x]);
    leftV[x] = leftV[l[x]];
    rightV[x] = rightV[r[x]];
  }
}
void go(int x, int ll, int rr) {
  if (ll > rr) return;
  if (l[x] == 0) return;
  int h = (int)(upper_bound(a + ll, a + rr + 1, key[x]) - a);
  dk[ll]++;
  dk[rr + 1]--;
  da[ll] += leftV[r[x]];
  da[h] -= leftV[r[x]];
  da[h] += rightV[l[x]];
  da[rr + 1] -= rightV[l[x]];
  go(l[x], ll, h - 1);
  go(r[x], h, rr);
}
int p[maxE];
int p1[maxE];
int a1[maxE];
double res[maxE];
int x0[maxE];
int sdkfjb[maxE];
bool comp(int x, int y) { return a[x] < a[y]; }
int main() {
  int n, k;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &x0[i], sdkfjb + i);
  for (int i = 0; i < n; i++) key[i + 1] = sdkfjb[i];
  for (int i = 0; i < n; i++) {
    add(x0[i], sdkfjb[i], i + 1);
  }
  dfs(root);
  scanf("%d", &k);
  for (int i = 0; i < k; i++) scanf("%d", a + i);
  for (int i = 0; i < k; i++) a1[i] = a[i];
  for (int i = 0; i < k; i++) p[i] = i;
  sort(p, p + k, comp);
  for (int i = 0; i < k; i++) a[i] = a1[p[i]];
  for (int i = 0; i < k; i++) p1[p[i]] = i;
  go(root, 0, k - 1);
  for (int i = 0; i < k; i++)
    cerr << i << " " << a[i] << " " << dk[i] << " " << da[i] << endl;
  int cc = 0;
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    cc += dk[i];
    sum += da[i];
    res[i] = sum * 1.0 / cc;
  }
  for (int i = 0; i < k; i++) printf("%.15lf\n", res[p1[i]]);
  return 0;
}
