#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
int pa[110000];
int ch[110000][2];
int ke[110000];
int smri[110000];
int lale[110000];
int lak[110000];
int smk[110000];
int lea[110000], L;
int ind[110000];
int inp[110000];
int sor[110000];
long long BIT[110000];
int dep[110000];
void insert(int pos, long long val) {
  while (pos < 110000) {
    BIT[pos] += val;
    pos += pos & (-pos);
  }
}
long long query(int pos) {
  long long res = 0;
  while (pos) {
    res += BIT[pos];
    pos -= (pos & (-pos));
  }
  return res;
}
void rek(int n, int fr, int to, int cdep) {
  int k = ke[n];
  if (ch[n][0] == -1) {
    for (int i = (fr); i < (to + 1); i++) dep[i] = cdep;
  } else {
    int lo = fr, hi = to;
    while (lo - hi > 2) {
      int mid = lo + ((hi - lo) >> 1);
      if (sor[mid] < k) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    while (sor[lo] < k) ++lo;
    while (sor[lo] > k) --lo;
    int s1 = lo;
    int s2 = lo + 1;
    if (s1 >= fr) {
      insert(fr, smri[n]);
      insert(s1 + 1, -smri[n]);
      rek(ch[n][0], fr, s1, cdep + 1);
    }
    if (s2 <= to) {
      insert(s2, lale[n]);
      insert(to + 1, -lale[n]);
      rek(ch[n][1], s2, to, cdep + 1);
    }
  }
}
int main() {
  memset(ch, -1, sizeof(ch));
  int N;
  int ro = -1;
  scanf("%d", &N);
  for (int i = (0); i < (N); i++) {
    scanf("%d%d", pa + i, ke + i);
    --pa[i];
    if (pa[i] < 0) ro = i;
  }
  L = 0;
  for (int i = (0); i < (N); i++)
    if (pa[i] >= 0) {
      if (ke[i] > ke[pa[i]]) {
        ch[pa[i]][1] = i;
      } else {
        ch[pa[i]][0] = i;
      }
    }
  for (int i = (0); i < (N); i++) {
    if (ch[i][0] == -1) {
      lea[L++] = i;
    } else {
      ind[i] = 2;
    }
  }
  for (int i = (0); i < (N); i++) {
    int to = pa[lea[i]];
    if (--ind[to] == 0) {
      lea[L++] = to;
    }
  }
  for (int i = (0); i < (N); i++) lak[i] = smk[i] = smri[i] = lale[i] = ke[i];
  for (int ii = (0); ii < (N); ii++) {
    int i = lea[ii];
    if (ch[i][0] != -1) {
      lak[i] = lak[ch[i][1]];
      smk[i] = smk[ch[i][0]];
      smri[i] = smk[ch[i][1]];
      lale[i] = lak[ch[i][0]];
    }
  }
  int K;
  scanf("%d", &K);
  for (int i = (0); i < (K); i++) scanf("%d", inp + i);
  for (int i = (0); i < (K); i++) sor[i] = inp[i];
  sor[K] = -1000;
  sor[K + 2] = -2000;
  sor[K + 1] = 2000000000;
  sort(sor, sor + (3 + K));
  for (int i = (0); i < (110000); i++) BIT[i] = 0;
  rek(ro, 2, K + 1, 0);
  for (int i = (0); i < (K); i++) {
    int v = inp[i];
    int lo = 2, hi = K + 2;
    while (true) {
      int mid = lo + ((hi - lo) >> 1);
      if (sor[mid] == v) {
        lo = hi = mid;
        break;
      } else if (sor[mid] < v) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    printf("%.10lf\n", query(lo) / (double)dep[lo]);
  }
  return 0;
}
