#include <bits/stdc++.h>
using namespace std;
int N;
int ps[1 << 20];
int vs[1 << 20];
long double res[1 << 20];
int lx[1 << 20], rx[1 << 20];
int lleft[1 << 20], rright[1 << 20];
void calc(int n, long double sum, int d) {
  if (d > 0) res[n] = sum / d;
  if (!lleft[n]) return;
  calc(lleft[n], sum + lx[rright[n]], d + 1);
  calc(rright[n], sum + rx[lleft[n]], d + 1);
}
void calc0(int n) {
  lx[n] = rx[n] = vs[n];
  if (!lleft[n]) return;
  calc0(lleft[n]);
  calc0(rright[n]);
  lx[n] = lx[lleft[n]];
  rx[n] = rx[rright[n]];
}
pair<int, int> xs[1 << 20];
int main() {
  cin.sync_with_stdio(0);
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    int p, v;
    cin >> p >> v;
    ps[i] = p;
    vs[i] = v;
    xs[i - 1] = pair<int, int>(vs[i], i);
  }
  for (int i = 1; i <= N; ++i) {
    int p = ps[i];
    if (p < 0) continue;
    (vs[i] < vs[p] ? lleft : rright)[p] = i;
  }
  int r = 1;
  while (ps[r] >= 0) ++r;
  calc0(r);
  calc(r, 0, 0);
  sort(xs, xs + N);
  int k;
  cin >> k;
  while (k-- > 0) {
    int a;
    cin >> a;
    pair<int, int> p(a, 0);
    int x = lower_bound(xs, xs + N, p) - xs;
    if (x == N || lleft[xs[x].second]) --x;
    cout << fixed << setprecision(15) << res[xs[x].second] << '\n';
  }
}
