#include <bits/stdc++.h>
using namespace std;
int child[100001][2];
int val[100001], n, k;
int par[100001], a[100001], b[100001];
int mor[100001], les[100001];
map<int, int> mp;
double ans[100001];
void solve(int x, int y, int node, double pr, int dep) {
  if (child[node][0] == -1) {
    for (int i = x; i <= y; i++) ans[mp[a[i]]] = pr / dep;
    return;
  }
  int k = lower_bound(a + x, a + y + 1, val[node]) - a;
  if (k > x && k <= y) {
    solve(x, k - 1, child[node][0], (pr + mor[node]), dep + 1);
    solve(k, y, child[node][1], (pr + les[node]), dep + 1);
  } else if (k == x)
    solve(k, y, child[node][1], (pr + les[node]), dep + 1);
  else
    solve(x, k - 1, child[node][0], (pr + mor[node]), dep + 1);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &par[i], &val[i]);
    par[i]--;
  }
  int root = 0;
  memset(child, -1, sizeof child);
  for (int i = 0; i < n; i++) {
    if (par[i] == -2)
      root = i;
    else {
      if (val[i] < val[par[i]])
        child[par[i]][0] = i;
      else
        child[par[i]][1] = i;
    }
    b[i] = val[i];
    mp[b[i]] = i;
  }
  sort(b, b + n);
  les[mp[b[0]]] = 0;
  for (int i = 1; i < n; i++) les[mp[b[i]]] = b[i - 1];
  for (int i = 0; i < n - 1; i++) mor[mp[b[i]]] = b[i + 1];
  cin >> k;
  mp.clear();
  for (int i = 0; i < k; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = i;
  }
  sort(a, a + k);
  solve(0, k - 1, root, 0., 0);
  cout.precision(9);
  cout.flags(ios::fixed);
  double x[100001];
  for (int i = 0; i < k; i++) cout << ans[i] << endl;
  return 0;
}
