#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0, b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 200007;
mt19937 randing(time(0));
inline int randlr(int l, int r) {
  if (l >= r) return l;
  return l + randing() % (r - l + 1);
}
inline int randgar(int a, int b) { return randlr(1, a + b) > a; }
struct treap {
  int lc[_], rc[_], sz[_], rt, tcnt;
  int val[_], tval[_], ans[_], tans[_];
  inline int alloc(int pval) {
    int a = ++tcnt;
    lc[a] = rc[a] = 0, sz[a] = 1;
    val[a] = pval, tval[a] = ans[a] = tans[a] = 0;
    return a;
  }
  inline void up(int x) {
    if (!x) return;
    sz[x] = sz[lc[x]] + 1 + sz[rc[x]];
  }
  inline void putval(int x, int dlt) {
    if (x) val[x] += dlt, tval[x] += dlt;
  }
  inline void putans(int x, int dlt) {
    if (x) ans[x] += dlt, tans[x] += dlt;
  }
  inline void dwn(int x) {
    if (!x) return;
    if (tval[x]) putval(lc[x], tval[x]), putval(rc[x], tval[x]), tval[x] = 0;
    if (tans[x]) putans(lc[x], tans[x]), putans(rc[x], tans[x]), tans[x] = 0;
  }
  inline void splitval(int x, int k, int &a, int &b) {
    if (!x) {
      a = b = 0;
      return;
    }
    dwn(x);
    if (val[x] <= k)
      a = x, splitval(rc[x], k, rc[x], b);
    else
      b = x, splitval(lc[x], k, a, lc[x]);
    up(x);
  }
  inline void splitsz(int x, int k, int &a, int &b) {
    if (!x) {
      a = b = 0;
      return;
    }
    dwn(x);
    if (sz[lc[x]] < k)
      a = x, splitsz(rc[x], k - sz[lc[x]] - 1, rc[x], b);
    else
      b = x, splitsz(lc[x], k, a, lc[x]);
    up(x);
  }
  inline int merging(int a, int b) {
    if (!a || !b) return a | b;
    dwn(a), dwn(b), up(a), up(b);
    if (!randgar(sz[a], sz[b])) {
      rc[a] = merging(rc[a], b), up(rc[a]);
      return a;
    }
    lc[b] = merging(a, lc[b]), up(lc[b]);
    return b;
  }
  inline void push(int pval) {
    int a, b;
    splitval(rt, pval, a, b);
    rt = merging(merging(a, alloc(pval)), b);
  }
  inline void output(int x, int to[]) {
    dwn(x), to[x] = ans[x];
    if (lc[x]) output(lc[x], to);
    if (rc[x]) output(rc[x], to);
    up(x);
  }
  treap() {
    memset(lc, 0, sizeof(lc));
    memset(rc, 0, sizeof(rc));
    memset(sz, 0, sizeof(sz));
    rt = tcnt = 0;
  }
} t;
struct shits {
  int co, val;
  shits(int _co = 0, int _val = 0) { co = _co, val = _val; }
  inline friend int operator<(shits a, shits b) {
    if (a.val == b.val) return a.co < b.co;
    return a.val > b.val;
  }
} p[_];
int n, m, sl[_];
int main() {
  n = ty();
  for (int i = 1, a, b; i <= n; i++) a = ty(), b = ty(), p[i] = shits(a, b);
  sort(p + 1, p + n + 1);
  m = ty();
  for (int i = 1; i <= m; i++) t.push(ty());
  for (int i = 1; i <= n; i++) {
    int co = p[i].co;
    int a, b, c;
    t.splitval(t.rt, co + co - 1, a, c);
    t.splitval(a, co - 1, a, b);
    t.putans(c, 1), t.putval(c, -co);
    queue<int> q;
    q.emplace(b);
    while (!q.empty()) {
      int x = q.front();
      q.pop(), t.dwn(x);
      if (t.lc[x]) q.emplace(t.lc[x]);
      if (t.rc[x]) q.emplace(t.rc[x]);
      int y, z;
      t.lc[x] = t.rc[x] = 0, t.sz[x] = 1, t.val[x] -= co, t.ans[x]++,
      t.tval[x] = t.tans[x] = 0;
      t.splitval(a, t.val[x], y, z), a = t.merging(t.merging(y, x), z);
    }
    t.rt = t.merging(a, c);
  }
  t.output(t.rt, sl);
  for (int i = 1; i <= m; i++) printf("%d", sl[i]), putchar(" \n"[i == m]);
  return 0;
}
