#include <bits/stdc++.h>
int T, N, K, M, left[100010], right[100010], key[100010], minv[100010],
    value[100010];
double ans[100010];
struct Input {
  int pre, k, r;
} input[100010];
int inputcmp(const void *_p, const void *_q) {
  Input *p = (Input *)_p, *q = (Input *)_q;
  if (p->pre == q->pre) return p->k < q->k ? -1 : 1;
  return p->pre < q->pre ? -1 : 1;
}
int valuecmp(const void *_p, const void *_q) {
  int *p = (int *)_p, *q = (int *)_q;
  return *p < *q ? -1 : 1;
}
void init() {
  int i, p;
  for (i = 1; i <= N; i++) {
    scanf("%d%d", &input[i].pre, &input[i].k);
    value[i] = input[i].k;
    input[i].r = i;
  }
  qsort(input + 1, N, sizeof(input[0]), inputcmp);
  memset(left + 1, 0, sizeof(left[0]) * N);
  memset(right + 1, 0, sizeof(right[0]) * N);
  for (i = 1; i <= N; i++) {
    if ((p = input[i].pre) == -1)
      T = input[i].r;
    else
      (i & 1) ? right[p] = input[i].r : left[p] = input[i].r;
    key[input[i].r] = input[i].k;
  }
  qsort(value + 1, N, sizeof(value[0]), valuecmp);
}
int BS(int v, int flag) {
  int min, mid, max;
  min = 1, max = N + 1;
  for (;;) {
    mid = (min + max) / 2;
    if (mid == min) break;
    if (value[mid] < v)
      min = mid;
    else
      max = mid;
  }
  return flag ? value[mid + 2] : value[mid];
}
void dfs(int cur, int min, long long int wn, long long int ws) {
  if (left[cur] == 0 && right[cur] == 0) {
    ++M;
    minv[M] = min;
    ans[M] = (double)ws / wn;
    return;
  }
  int v;
  if (left[cur]) {
    v = BS(key[cur], 1);
    dfs(left[cur], min, wn + 1, ws + v);
  }
  if (right[cur]) {
    v = BS(key[cur], 0);
    dfs(right[cur], min > key[cur] ? min : key[cur], wn + 1, ws + v);
  }
}
void solve() {
  int i, j, k, mid, min, max;
  M = minv[0] = 0;
  dfs(T, 0, 0, 0);
  scanf("%d", &K);
  for (i = 0; i < K; i++) {
    scanf("%d", &k);
    min = 1, max = M + 1;
    for (;;) {
      mid = (min + max) / 2;
      if (mid == min) break;
      if (minv[mid] < k)
        min = mid;
      else
        max = mid;
    }
    printf("%.10f\n", ans[mid]);
  }
}
int main() {
  while (scanf("%d", &N) == 1) {
    init();
    solve();
  }
  return 0;
}
