#include <bits/stdc++.h>
using namespace std;
class R {
 public:
  double value;
  long a, b;
  R(long __a, long __b, double __value);
};
R::R(long __a, long __b, double __value) {
  a = __a;
  b = __b;
  value = __value;
}
bool operator<(const R &a, const R &b) { return a.a < b.a; }
vector<R> Ranges;
class S {
 public:
  long n, am, a, b;
  long long sum;
  S(long __n, long long __sum, long __am, long __a, long __b);
};
S::S(long __n, long long __sum, long __am, long __a, long __b) {
  n = __n;
  sum = __sum;
  am = __am;
  a = __a;
  b = __b;
}
struct T {
  long key;
  long left, right;
  long in;
  long parent;
} Node[100005];
long In[100005];
long InIndex;
long N;
long Root;
void in() {
  scanf("%ld", &N);
  long p;
  for (long i = 0; i < N; i++) {
    scanf("%ld %ld", &Node[i].parent, &Node[i].key);
    Node[i].parent -= Node[i].parent == -1 ? 0 : 1;
  }
}
void makeTree() {
  for (long i = 0; i < N; i++) Node[i].left = Node[i].right = -1;
  for (long i = 0; i < N; i++) {
    if (Node[i].parent == -1) {
      Root = i;
      continue;
    }
    if (Node[Node[i].parent].key > Node[i].key)
      Node[Node[i].parent].left = i;
    else
      Node[Node[i].parent].right = i;
  }
}
void dfs(long n) {
  if (Node[n].left != -1) dfs(Node[n].left);
  Node[n].in = InIndex;
  In[InIndex++] = Node[n].key;
  if (Node[n].right != -1) dfs(Node[n].right);
}
void dfs(long n, long long sum, long am, long a, long b) {
  stack<S> s;
  s.push(S(n, sum, am, a, b));
  S temp(0, 0, 0, 0, 0);
  while (!s.empty()) {
    temp = s.top();
    s.pop();
    if (Node[temp.n].left == -1) {
      Ranges.push_back(
          R(temp.a, temp.b, (double)((double)temp.sum / (double)temp.am)));
      continue;
    }
    s.push(S(Node[temp.n].left, temp.sum + In[Node[temp.n].in + 1], temp.am + 1,
             temp.a, Node[temp.n].key - 1));
    s.push(S(Node[temp.n].right, temp.sum + In[Node[temp.n].in - 1],
             temp.am + 1, Node[temp.n].key + 1, temp.b));
  }
}
double searchKey(long key) {
  long a = 0;
  long b = Ranges.size() - 1;
  long pos = (a + b) / 2;
  while (b - a > 1) {
    if (Ranges[pos].b < key)
      a = pos;
    else
      b = pos;
    pos = (a + b) / 2;
  }
  if (Ranges[a].a <= key && Ranges[a].b >= key) return Ranges[a].value;
  return Ranges[b].value;
}
void solve() {
  long k;
  scanf("%ld", &k);
  long key;
  for (long i = 0; i < k; i++) {
    scanf("%ld", &key);
    printf("%.9lf\n", searchKey(key));
  }
}
int main() {
  in();
  makeTree();
  dfs(Root);
  dfs(Root, 0, 0, 1, 1000000000);
  sort(Ranges.begin(), Ranges.end());
  solve();
  return 0;
}
