#include <bits/stdc++.h>
using namespace std;
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << (int)*i << " ";
  cout << endl;
}
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
struct No {
  int pai, dir, esq;
  int key;
} no[1 << 20];
int n;
long long a[1 << 20];
long long b[1 << 20];
long long ka[1 << 20];
long long kb[1 << 20];
void add(int x, int y, long long z, int no, int ini, int fim, long long t[],
         long long tt[]) {
  if (fim < x || y < ini) return;
  if (ini == fim) {
    t[no] += z;
  } else if (x <= ini && fim <= y) {
    tt[no] += z;
  } else {
    int med = (ini + fim) / 2;
    add(x, y, z, 2 * no, ini, med, t, tt);
    add(x, y, z, 2 * no + 1, med + 1, fim, t, tt);
    t[no] = t[2 * no] + t[2 * no + 1];
  }
}
long long conta(int i, int j, int no, int ini, int fim, long long t[],
                long long tt[]) {
  if (fim < i || j < ini) return 0;
  if (tt[no]) {
    int med = (ini + fim) / 2;
    add(ini, med, tt[no], 2 * no, ini, med, t, tt);
    add(med + 1, fim, tt[no], 2 * no + 1, med + 1, fim, t, tt);
    tt[no] = 0;
  }
  if (i <= ini && fim <= j)
    return t[no];
  else {
    int med = (ini + fim) / 2;
    long long c1 = conta(i, j, 2 * no, ini, med, t, tt);
    long long c2 = conta(i, j, 2 * no + 1, med + 1, fim, t, tt);
    return c1 + c2;
  }
}
map<int, int> mapa;
int q[1 << 20], nq;
int opa, vmin, vmax;
long long folha[1 << 20], nf;
int pred(int x) {
  int res = 0;
  for (int k = 20; k >= 0; k--) {
    int nres = res + (1 << k);
    if (nres < nf && folha[nres] <= x) {
      res = nres;
    }
  }
  return folha[res];
}
int suc(int x) {
  int res = nf - 1;
  for (int k = 20; k >= 0; k--) {
    int nres = res - (1 << k);
    if (nres >= 0 && folha[nres] >= x) {
      res = nres;
    }
  }
  return folha[res];
}
void adicionar(int x, int y, int z) {
  add(mapa[x], mapa[y], z, 1, 1, opa, a, ka);
  add(mapa[x], mapa[y], +1, 1, 1, opa, b, kb);
}
void dfs(int id, int Min, int Max) {
  if (no[id].dir != -1) {
    adicionar(Min, no[id].key, suc(no[id].key));
    adicionar(no[id].key, Max, pred(no[id].key));
    dfs(no[id].dir, no[id].key, Max);
    dfs(no[id].esq, Min, no[id].key);
  }
}
int main() {
  scanf("%d", &n);
  mapa[0] = 1;
  int raiz = -1;
  for (int(i) = (0); (i) < (n); (i)++) {
    int id = i + 1;
    int x, y;
    scanf("%d %d", &x, &y);
    no[id].pai = x;
    no[id].key = y;
    no[id].dir = no[id].esq = -1;
    if (x != -1) {
    } else
      raiz = id;
    mapa[y] = 1;
  }
  for (int(i) = (0); (i) < (n); (i)++) {
    int id = i + 1;
    int x = no[id].pai;
    int y = no[id].key;
    if (x != -1) {
      if (no[x].key > y) {
        no[x].esq = id;
      } else {
        no[x].dir = id;
      }
    } else
      raiz = id;
    mapa[y] = 1;
  }
  for (int(i) = (0); (i) < (n + 1); (i)++)
    if (i) {
      if (no[i].dir == -1) {
        folha[nf++] = no[i].key;
      }
    }
  sort(folha, folha + nf);
  scanf("%d", &nq);
  for (int(i) = (0); (i) < (nq); (i)++) {
    scanf("%d", q + i);
    mapa[q[i]] = 1;
  }
  opa = 1, vmin = 1 << 30, vmax = -(1 << 30);
  for (map<int, int>::iterator iter = mapa.begin(); iter != mapa.end();
       iter++) {
    iter->second = opa++;
    vmin = min(vmin, iter->first);
    vmax = max(vmax, iter->first);
  }
  dfs(raiz, vmin, vmax);
  for (int(i) = (0); (i) < (nq); (i)++) {
    double res = conta(mapa[q[i]], mapa[q[i]], 1, 1, opa, a, ka);
    res /= conta(mapa[q[i]], mapa[q[i]], 1, 1, opa, b, kb);
    cout << fixed << setprecision(9) << res << endl;
  }
  return 0;
}
