#include <bits/stdc++.h>
using namespace std;
int ls[200010];
int rs[200010];
int val[200010];
int num[200010];
int r[200010];
int sum[200010];
int tag[200010];
int res[200010];
int root;
int n, m, x;
int cnt;
int a, b, c, d;
int L, R;
struct lty {
  int c, v;
} q[200010];
queue<int> Q;
inline int build(int v) {
  int rt = ++cnt;
  r[rt] = rand();
  val[rt] = v;
  return rt;
}
inline void add(int rt, int x, int y) {
  tag[rt] += x;
  val[rt] += x;
  sum[rt] += y;
  res[rt] += y;
}
inline void pushdown(int rt) {
  add(ls[rt], tag[rt], sum[rt]);
  add(rs[rt], tag[rt], sum[rt]);
  tag[rt] = sum[rt] = 0;
}
inline int merge(int x, int y) {
  if (!x || !y) {
    return x + y;
  }
  pushdown(x);
  pushdown(y);
  if (r[x] < r[y]) {
    rs[x] = merge(rs[x], y);
    return x;
  } else {
    ls[y] = merge(x, ls[y]);
    return y;
  }
}
inline void split(int rt, int &x, int &y, int k) {
  if (!rt) {
    x = y = 0;
    return;
  }
  pushdown(rt);
  if (val[rt] >= k) {
    y = rt;
    split(ls[rt], x, ls[y], k);
  } else {
    x = rt;
    split(rs[rt], rs[x], y, k);
  }
}
inline bool cmp(lty a, lty b) { return a.v == b.v ? a.c < b.c : a.v > b.v; }
inline void dfs(int rt) {
  pushdown(rt);
  if (ls[rt]) {
    dfs(ls[rt]);
  }
  if (rs[rt]) {
    dfs(rs[rt]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &q[i].c, &q[i].v);
  }
  sort(q + 1, q + 1 + n, cmp);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &x);
    split(root, a, b, x);
    root = merge(merge(a, build(x)), b);
  }
  for (int i = 1; i <= n; i++) {
    split(root, a, b, q[i].c);
    split(b, b, c, 2 * q[i].c);
    add(b, -q[i].c, 1);
    add(c, -q[i].c, 1);
    Q.push(b);
    while (!Q.empty()) {
      int now = Q.front();
      Q.pop();
      pushdown(now);
      if (ls[now]) {
        Q.push(ls[now]);
      }
      if (rs[now]) {
        Q.push(rs[now]);
      }
      ls[now] = rs[now] = 0;
      split(a, a, d, val[now]);
      a = merge(merge(a, now), d);
    }
    root = merge(a, c);
  }
  dfs(root);
  for (int i = 1; i <= m; i++) {
    printf("%d ", res[i]);
  }
}
