#include <bits/stdc++.h>
using namespace std;
struct Tshirt {
  int q, c;
} f[200005];
int ans[200005];
inline bool cmp(Tshirt aa, Tshirt bb) {
  return aa.q == bb.q ? aa.c < bb.c : aa.q > bb.q;
}
struct treap {
  int v, id, ls, rs, sz, pri, tg, dec;
} t[200005];
inline bool CC(treap aa, treap bb) { return aa.v < bb.v; }
inline void up(int now) { t[now].sz = t[t[now].ls].sz + t[t[now].rs].sz + 1; }
inline void down(int now) {
  if (t[now].tg) {
    ans[t[now].id] += t[now].tg;
    t[t[now].ls].tg += t[now].tg;
    t[t[now].rs].tg += t[now].tg;
    t[now].tg = 0;
  }
  if (t[now].dec) {
    t[t[now].ls].v -= t[now].dec;
    t[t[now].rs].v -= t[now].dec;
    t[t[now].ls].dec += t[now].dec;
    t[t[now].rs].dec += t[now].dec;
    t[now].dec = 0;
  }
}
void merge(int &now, int x, int y) {
  if (!(x && y)) {
    now = x | y;
    return;
  }
  if (t[x].pri < t[y].pri)
    now = x, down(x), merge(t[now].rs, t[now].rs, y);
  else
    now = y, down(y), merge(t[now].ls, x, t[now].ls);
  up(now);
}
void split(int now, int &x, int &y, int v) {
  if (!now) {
    x = y = 0;
    return;
  }
  down(now);
  if (t[now].v <= v)
    x = now, split(t[now].rs, t[now].rs, y, v);
  else
    y = now, split(t[now].ls, x, t[now].ls, v);
  up(now);
}
void insert(int &rt, int x) {
  int X, Y;
  split(rt, X, Y, t[x].v);
  merge(X, X, x);
  merge(rt, X, Y);
}
void ins(int &rt, int &now, int v) {
  if (!now) return;
  down(now);
  ++ans[t[now].id];
  ins(rt, t[now].ls, v);
  ins(rt, t[now].rs, v);
  t[now].v -= v;
  insert(rt, now);
  now = 0;
}
void downtag(int now) {
  down(now);
  if (t[now].ls) downtag(t[now].ls);
  if (t[now].rs) downtag(t[now].rs);
}
int n, i, X, Y, Z, g, rt, m;
signed main() {
  cin >> n;
  srand(time(NULL));
  for (i = 1; i <= n; ++i) cin >> f[i].c >> f[i].q;
  sort(f + 1, f + n + 1, cmp);
  for (cin >> m, i = 1; i <= m; ++i) {
    t[i].id = i;
    cin >> t[i].v;
    t[i].sz = 1;
    t[i].pri = rand();
  }
  sort(t + 1, t + m + 1, CC);
  for (i = 1; i <= m; ++i) merge(rt, rt, i);
  for (i = 1; i <= n; ++i) {
    split(rt, X, Y, (g = f[i].c) - 1);
    split(Y, Y, Z, g << 1);
    t[Z].dec += g;
    t[Z].v -= g;
    ++t[Z].tg;
    ins(X, Y, g);
    merge(rt, X, Z);
  }
  downtag(rt);
  for (i = 1; i <= m; ++i) {
    cout << ans[i] << " ";
  }
  return 0;
}
