#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, q, nod, rt, per[N], ans[N];
struct shirt {
  int c, q;
} A[N];
struct Treap {
  int ch[2], val, fix, tag, id, ans, tga;
} t[N];
int cmp(const shirt &a, const shirt &b) {
  return a.q > b.q || (a.q == b.q && a.c < b.c);
}
void add(int x, int v1, int v2) {
  t[x].val += v1;
  t[x].tag += v1;
  t[x].ans += v2;
  t[x].tga += v2;
}
void pushdown(int x) {
  int &v1 = t[x].tag, &v2 = t[x].tga;
  if (t[x].ch[0]) add(t[x].ch[0], v1, v2);
  if (t[x].ch[1]) add(t[x].ch[1], v1, v2);
  v1 = v2 = 0;
}
void split(int x, int k, int &a, int &b) {
  pushdown(x);
  if (!x) {
    a = b = 0;
    return;
  }
  if (t[x].val <= k)
    a = x, split(t[x].ch[1], k, t[x].ch[1], b);
  else
    b = x, split(t[x].ch[0], k, a, t[x].ch[0]);
}
int merge(int x, int y) {
  pushdown(x);
  pushdown(y);
  if (!x || !y) return x + y;
  if (t[x].fix < t[y].fix)
    return t[x].ch[1] = merge(t[x].ch[1], y), x;
  else
    return t[y].ch[0] = merge(x, t[y].ch[0]), y;
}
void ins(int &root, int k, int id, int p, int as) {
  t[p] = (Treap){{0, 0}, k, rand(), 0, id, as, 0};
  int x, y;
  split(root, k, x, y);
  root = merge(merge(x, p), y);
}
void dfspush(int x, int &root) {
  pushdown(x);
  if (t[x].ch[0]) dfspush(t[x].ch[0], root), t[x].ch[0] = 0;
  if (t[x].ch[1]) dfspush(t[x].ch[1], root), t[x].ch[1] = 0;
  ins(root, t[x].val, t[x].id, x, t[x].ans);
}
void dfscalc(int x) {
  pushdown(x);
  if (t[x].ch[0]) dfscalc(t[x].ch[0]);
  if (t[x].ch[1]) dfscalc(t[x].ch[1]);
  ans[t[x].id] = t[x].ans;
}
void dfsprint(int x) {
  printf("t[%d]:lc=%d,rc=%d,id=%d,ans=%d,val=%d,tag=%d,tga=%d\n", x, t[x].ch[0],
         t[x].ch[1], t[x].id, t[x].ans, t[x].val, t[x].tag, t[x].tga);
  if (t[x].ch[0]) dfsprint(t[x].ch[0]);
  if (t[x].ch[1]) dfsprint(t[x].ch[1]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d%d", &A[i].c, &A[i].q);
  cin >> q;
  for (int i = 1; i <= q; i++) scanf("%d", &per[i]);
  for (int i = 1; i <= q; i++) ins(rt, per[i], i, ++nod, 0);
  sort(A + 1, A + n + 1, cmp);
  for (int i = 1, x, y, z; i <= n; i++) {
    split(rt, A[i].c - 1, x, y);
    add(y, -A[i].c, 1);
    split(y, A[i].c - 1, y, z);
    dfspush(y, x);
    rt = merge(x, z);
  }
  dfscalc(rt);
  for (int i = 1; i <= q; i++) printf("%d ", ans[i]);
  return puts(""), 0;
}
