#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int maxn = 100100;
int root = 0;
int n, k;
int asdaflkadgjigda[maxn], adfadflasdaflkadgjigda[maxn], key[maxn], par[maxn];
long double minv[maxn], maxv[maxn];
long double ans[maxn];
bool leaf[maxn];
pair<int, int> p[maxn];
int a[maxn];
void dfs(int u) {
  if (leaf[u]) {
    minv[u] = maxv[u] = key[u];
  } else {
    dfs(asdaflkadgjigda[u]);
    dfs(adfadflasdaflkadgjigda[u]);
    minv[u] = minv[asdaflkadgjigda[u]];
    maxv[u] = maxv[adfadflasdaflkadgjigda[u]];
  }
}
void dfs_ans(int u, int l, int r, long double add, int cnt) {
  if (leaf[u]) {
    for (int i = (l); i < (r); i++) {
      ans[p[i].second] = add / (long double)cnt;
    }
  } else {
    int mid = int(lower_bound(a + l, a + r, key[u]) - a);
    dfs_ans(asdaflkadgjigda[u], l, mid, add + minv[adfadflasdaflkadgjigda[u]],
            cnt + 1);
    dfs_ans(adfadflasdaflkadgjigda[u], mid, r, add + maxv[asdaflkadgjigda[u]],
            cnt + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    leaf[i] = true;
  }
  for (int i = (0); i < (n); i++) {
    scanf("%d%d", par + i, key + i);
    if (par[i] == -1)
      root = i;
    else {
      par[i]--;
      leaf[par[i]] = false;
    }
  }
  for (int i = (0); i < (n); i++) {
    if (root != i) {
      if (key[i] < key[par[i]]) {
        asdaflkadgjigda[par[i]] = i;
      } else {
        adfadflasdaflkadgjigda[par[i]] = i;
      }
    }
  }
  dfs(root);
  scanf("%d", &k);
  for (int i = (0); i < (k); i++) {
    scanf("%d", &p[i].first);
    p[i].second = i;
  }
  sort(p, p + k);
  for (int i = (0); i < (k); i++) {
    a[i] = p[i].first;
  }
  dfs_ans(root, 0, k, 0, 0);
  for (int i = (0); i < (k); i++) {
    printf("%.20lf\n", (double)ans[i]);
  }
  return 0;
}
