#include <bits/stdc++.h>
using namespace std;
int tree[100005][2];
int val[100005], n, m, cnt, p[100005], mnv[100005], mxv[100005];
int inp[100005];
pair<int, int> all[100005];
double ans[100005 + 100005];
void calcMinMax(int i) {
  mnv[i] = mxv[i] = val[i];
  if (tree[i][0] == 0) return;
  for (int k = 0; k < (2); ++k) calcMinMax(tree[i][k]);
  mnv[i] = min(mnv[i], mnv[tree[i][0]]);
  mxv[i] = max(mxv[i], mxv[tree[i][1]]);
}
void solve(int i, long long v, int c) {
  if (tree[i][0] == 0) {
    ans[i] = (double)v / c;
    return;
  }
  ++c;
  solve(tree[i][0], v + mnv[tree[i][1]], c);
  solve(tree[i][1], v + mxv[tree[i][0]], c);
}
double getAns(int v) {
  int lo = 0, hi = n - 1;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (all[mid].first <= v)
      lo = mid;
    else
      hi = mid - 1;
  }
  if (all[0].first > v) lo = 0;
  if (tree[all[lo].second][0] == 0) return ans[all[lo].second];
  return ans[all[lo + 1].second];
}
char *buf, str[10000000];
int main() {
  int root = -1;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &p[i], &val[i]);
    if (p[i] == -1) root = i;
  }
  for (int i = 1; i <= n; ++i)
    if (p[i] != -1) tree[p[i]][val[i] < val[p[i]] ? 0 : 1] = i;
  calcMinMax(root);
  solve(root, 0, 0);
  for (int i = 1; i <= n; ++i) all[i - 1] = make_pair(val[i], i);
  scanf("%d", &m);
  buf = str;
  sort(all, all + n);
  for (int i = 0; i < (m); ++i) {
    int v;
    scanf("%d", &v);
    buf += sprintf(buf, "%.010lf\n", getAns(v));
  }
  printf("%s", str);
  return 0;
}
