#include <bits/stdc++.h>
using namespace std;
int N, K, Root;
int Par[1000000], Key[1000000], Left[1000000], Right[1000000];
long double Ans[1000000];
vector<int> treeKeys;
vector<pair<long long, long long> > searchKeys;
map<int, int> Bef, Aft;
vector<int> Stack;
int pos, cnt;
long long total;
void findTree(int key) {
  while (Left[pos] != -1) {
    if (key < Key[pos]) {
      Stack.push_back(Key[pos]);
      cnt++;
      total += Aft[Key[pos]];
      pos = Left[pos];
    } else {
      cnt++;
      total += Bef[Key[pos]];
      pos = Right[pos];
    }
  }
}
int main() {
  int i, a;
  scanf("%d", &N);
  memset(Left, 255, sizeof(Left));
  memset(Right, 255, sizeof(Right));
  for (i = 0; i < (int)(N); i++) {
    scanf("%d%d", &Par[i], &Key[i]);
    if (Par[i] != -1) Par[i]--;
    treeKeys.push_back(Key[i]);
  }
  sort(treeKeys.begin(), treeKeys.end());
  for (i = 0; i < (int)(N); i++) {
    if (Par[i] == -1)
      Root = i;
    else if (Key[Par[i]] > Key[i])
      Left[Par[i]] = i;
    else
      Right[Par[i]] = i;
  }
  for (i = 0; i < (int)(((int)treeKeys.size())); i++) {
    if (i < N - 1) Aft[treeKeys[i]] = treeKeys[i + 1];
    if (i > 0) Bef[treeKeys[i]] = treeKeys[i - 1];
  }
  scanf("%d", &K);
  for (i = 0; i < (int)(K); i++) {
    scanf("%d", &a);
    searchKeys.push_back(make_pair(a, i));
  }
  sort(searchKeys.begin(), searchKeys.end());
  pos = Root;
  cnt = 0;
  total = 0;
  findTree(searchKeys[0].first);
  for (i = 0; i < (int)(((int)searchKeys.size())); i++) {
    Ans[searchKeys[i].second] = total / (long double)cnt;
    if (i == ((int)searchKeys.size()) - 1) break;
    int now = searchKeys[i + 1].first;
    while (((int)Stack.size()) && Stack.back() < now) {
      pos = Par[pos];
      if (Key[pos] == Stack.back()) {
        cnt--;
        total -= Aft[Key[pos]];
        Stack.pop_back();
        if (!((int)Stack.size()) || Stack.back() > now) break;
      } else {
        cnt--;
        total -= Bef[Key[pos]];
      }
    }
    findTree(now);
  }
  for (i = 0; i < (int)(K); i++) {
    printf("%0.13lf\n", (double)Ans[i]);
  }
  return 0;
}
