#include <bits/stdc++.h>
static const int maxn = 100012;
static const int maxk = 100012;
int N;
int P[maxn];
int V[maxn];
int K;
int Key[maxk];
void Read() {
  int i;
  scanf("%d", &N);
  for (i = 0; i < N; ++i) {
    scanf("%d%d", &P[i], &V[i]);
    if (P[i] != -1) --P[i];
  }
  scanf("%d", &K);
  for (i = 0; i < K; ++i) {
    scanf("%d", &Key[i]);
  }
}
int L[maxn], R[maxn];
int Index[maxn], Leaf[maxn];
int Stack[maxn];
int MinError[maxn], MaxError[maxn];
double Error[maxn];
int Depth[maxn];
int Min[maxn];
void Work() {
  int i, t;
  memset(L, -1, sizeof(L));
  memset(R, -1, sizeof(R));
  t = 0;
  for (i = 0; i < N; ++i) {
    if (P[i] == -1) {
      Stack[t++] = i;
      continue;
    }
    if (V[P[i]] < V[i])
      R[P[i]] = i;
    else
      L[P[i]] = i;
  }
  i = 0;
  int ln = 0;
  while (t > 0) {
    int c = Stack[--t];
    Index[i++] = c;
    if (R[c] != -1) {
      Stack[t++] = R[c];
      Stack[t++] = L[c];
    } else {
      Leaf[ln++] = c;
    }
  }
  for (i = N - 1; i >= 0; --i) {
    if (L[Index[i]] == -1) {
      MinError[Index[i]] = V[Index[i]];
      MaxError[Index[i]] = V[Index[i]];
    } else {
      MinError[Index[i]] = MinError[L[Index[i]]];
      MaxError[Index[i]] = MaxError[R[Index[i]]];
    }
  }
  Depth[Index[0]] = 0;
  Error[Index[0]] = 0;
  for (i = 1; i < N; ++i) {
    Depth[Index[i]] = Depth[P[Index[i]]] + 1;
    if (V[P[Index[i]]] < V[Index[i]])
      Error[Index[i]] = Error[P[Index[i]]] + MaxError[L[P[Index[i]]]];
    else
      Error[Index[i]] = Error[P[Index[i]]] + MinError[R[P[Index[i]]]];
  }
  Min[Index[0]] = 0;
  for (i = 0; i < N; ++i) {
    if (L[Index[i]] != -1) Min[L[Index[i]]] = Min[Index[i]];
    if (R[Index[i]] != -1) Min[R[Index[i]]] = V[Index[i]];
  }
  for (i = 0; i < K; ++i) {
    int left = 0, right = ln;
    while (right - left > 1) {
      int middle = (left + right) / 2;
      if (Min[Leaf[middle]] < Key[i])
        left = middle;
      else
        right = middle;
    }
    printf("%.10lf\n", Error[Leaf[left]] / Depth[Leaf[left]]);
  }
}
int main() {
  Read();
  Work();
  return 0;
}
