#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long res = 0, f = 1;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  do {
    res = res * 10 + ch - '0';
  } while (isdigit(ch = getchar()));
  return res * f;
}
const long long N = 4e5 + 5;
long long n, m;
struct node {
  long long c, q;
} a[N];
inline bool cmp(node x, node y) { return x.q != y.q ? x.q > y.q : x.c < y.c; }
long long f[N], ch[N][2], val[N], ans[N], tag[N], del[N], rt;
inline void push1(long long x, long long c) { ans[x] += c, tag[x] += c; }
inline void push2(long long x, long long c) { val[x] -= c, del[x] += c; }
inline void pushdown(long long x) {
  if (tag[x]) {
    if (ch[x][0]) push1(ch[x][0], tag[x]);
    if (ch[x][1]) push1(ch[x][1], tag[x]);
    tag[x] = 0;
  }
  if (del[x]) {
    if (ch[x][0]) push2(ch[x][0], del[x]);
    if (ch[x][1]) push2(ch[x][1], del[x]);
    del[x] = 0;
  }
}
inline bool get(long long x) { return ch[f[x]][1] == x; }
inline void rotate(long long x) {
  long long fa = f[x], grfa = f[fa], k = get(x), c = ch[x][!k];
  if (grfa) ch[grfa][get(fa)] = x;
  ch[x][!k] = fa;
  ch[fa][k] = c;
  if (c) f[c] = fa;
  f[fa] = x;
  f[x] = grfa;
}
long long s[N], top;
inline void pushall(long long x) {
  s[top = 1] = x;
  while (f[x]) s[++top] = x = f[x];
  while (top) pushdown(s[top--]);
}
inline void splay(long long x, long long to) {
  if (!x) return;
  pushall(x);
  while (f[x] != to) {
    if (f[f[x]] != to) rotate(get(x) != get(f[x]) ? x : f[x]);
    rotate(x);
  }
  if (to == 0) rt = x;
}
inline long long qpre(long long key) {
  long long x = rt, ans = 0;
  while (pushdown(x), x) {
    if (val[x] > key)
      x = ch[x][0];
    else
      ans = x, x = ch[x][1];
  }
  return splay(ans, 0), ans;
}
inline long long qsuf(long long key) {
  long long x = rt, ans = 0;
  while (pushdown(x), x) {
    if (val[x] < key)
      x = ch[x][1];
    else
      ans = x, x = ch[x][0];
  }
  return splay(ans, 0), ans;
}
inline long long split(long long vx, long long vy) {
  long long x = qpre(vx - 1), y = qsuf(vy + 1);
  splay(x, 0), splay(y, x);
  return ch[y][0];
}
inline void insert(long long key, long long id) {
  if (!rt) {
    rt = id, val[id] = key;
    return;
  }
  long long x = rt;
  while (pushdown(x), x) {
    if (key < val[x] || (key == val[x] && id < x)) {
      if (ch[x][0])
        x = ch[x][0];
      else {
        ch[x][0] = id, val[id] = key, f[id] = x;
        splay(id, 0);
        return;
      }
    } else {
      if (ch[x][1])
        x = ch[x][1];
      else {
        ch[x][1] = id, val[id] = key, f[id] = x;
        splay(id, 0);
        return;
      }
    }
  }
}
long long t[N], vl[N], tp;
inline void dfs(long long x) {
  pushdown(x);
  if (ch[x][0]) dfs(ch[x][0]);
  if (x) t[++tp] = x, vl[tp] = val[x];
  if (ch[x][1]) dfs(ch[x][1]);
}
inline void destroy(long long x) {
  f[x] = ch[x][0] = ch[x][1] = val[x] = tag[x] = del[x] = 0;
}
inline void rebuild(long long d) {
  long long x = split(d, 2 * d - 1);
  tp = 0, ch[f[x]][get(x)] = 0, dfs(x);
  for (register long long i = 1; i <= tp; ++i) destroy(t[i]);
  for (register long long i = 1; i <= tp; ++i) {
    ++ans[t[i]];
    if (vl[i] - d != 0 || t[i] == 1) insert(vl[i] - d, t[i]);
  }
}
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i) a[i].c = read(), a[i].q = read();
  insert(0, 1);
  m = read();
  for (register long long i = 1; i <= m; ++i) insert(read(), i + 1);
  insert(0x3ffffffffffffff, m + 2);
  sort(a + 1, a + n + 1, cmp);
  for (register long long i = 1; i <= n; ++i) {
    rebuild(a[i].c);
    splay(qpre(a[i].c), 0);
    push1(ch[rt][1], 1), push2(ch[rt][1], a[i].c);
  }
  dfs(rt);
  for (register long long i = 1; i <= m; ++i) printf("%d ", ans[i + 1]);
  return 0;
}
