#include <bits/stdc++.h>
using namespace std;
const int N = 200005, inf = 0x7fffffff;
int n, m, top, minc;
int num[N];
struct shirt {
  int ci, qi;
} a[N];
bool operator<(const shirt x, const shirt y) {
  if (x.qi != y.qi) return x.qi > y.qi;
  return x.ci < y.ci;
}
int input() {
  int x = 0, F = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') F = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * F;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
struct fhq {
  int rt, tot;
  int val[N], rnd[N], tag[N], ans[N], ch[N][2], pool[N], id[N];
  inline int random() { return rand() << 15 | rand(); }
  inline void cover(int u, int x, int y) {
    if (u) tag[u] += x, val[u] += x, ans[u] += y, num[id[u]] += y;
  }
  inline void pushdown(int u) {
    if (tag[u] != 0)
      cover(ch[u][0], tag[u], ans[u]), cover(ch[u][1], tag[u], ans[u]),
          tag[u] = ans[u] = 0;
  }
  void split(int u, int k, int &x, int &y) {
    if (!u) {
      x = y = 0;
      return;
    }
    pushdown(u);
    if (val[u] <= k)
      x = u, split(ch[u][1], k, ch[u][1], y);
    else
      y = u, split(ch[u][0], k, x, ch[u][0]);
  }
  int Merge(int u, int v) {
    if (!u || !v) return u | v;
    pushdown(u);
    pushdown(v);
    if (rnd[u] > rnd[v]) {
      ch[u][1] = Merge(ch[u][1], v);
      return u;
    } else {
      ch[v][0] = Merge(u, ch[v][0]);
      return v;
    }
  }
  void ins(int x, int ID) {
    int l, r, u = pool[tot--];
    val[u] = x;
    rnd[u] = random();
    id[u] = ID;
    tag[u] = ans[u] = ch[u][0] = ch[u][1] = 0;
    split(rt, x, l, r);
    rt = Merge(Merge(l, u), r);
  }
  void trans(int u, int x) {
    if (!u) return;
    pushdown(u);
    trans(ch[u][0], x);
    trans(ch[u][1], x);
    pool[++tot] = u;
    num[id[u]]++;
    if (val[u] - x >= minc) ins(val[u] - x, id[u]);
  }
  void dfs(int u) {
    if (!u) return;
    pushdown(u);
    dfs(ch[u][0]);
    dfs(ch[u][1]);
  }
  void solve() {
    int l, r, mid;
    tot = 0;
    for (int i = 1; i <= m; i++) pool[++tot] = i;
    for (register int i = 1; i <= m; i++) ins(input(), i);
    for (register int i = 1; i <= n; i++) {
      split(rt, (a[i].ci << 1) - 1, l, r);
      split(l, a[i].ci - 1, l, mid);
      if (r) cover(r, -a[i].ci, 1);
      rt = Merge(l, r);
      trans(mid, a[i].ci);
    }
    dfs(rt);
    for (register int i = 1; i <= m; i++) {
      print(num[i]);
      if (i < m) putchar(' ');
    }
  }
} tf;
struct Splay {
  int rt, tot;
  int val[N], id[N], fa[N], ch[N][2], tag[N], ans[N], pool[N];
  inline void con(int u, int v, int w) {
    fa[u] = v;
    ch[v][w] = u;
  }
  inline void cover(int u, int x, int y) {
    if (u) tag[u] += x, val[u] += x, ans[u] += y, num[id[u]] += y;
  }
  inline void pushdown(int u) {
    if (tag[u] != 0)
      cover(ch[u][0], tag[u], ans[u]), cover(ch[u][1], tag[u], ans[u]),
          tag[u] = ans[u] = 0;
  }
  void rot(int u) {
    int v = fa[u], d = (u == ch[v][1]);
    con(u, fa[v], v == ch[fa[v]][1]);
    con(ch[u][d ^ 1], v, d);
    con(v, u, d ^ 1);
  }
  void splay(int u, int v) {
    pushdown(u);
    while (fa[u] != v) {
      int f1 = fa[u], f2 = fa[f1];
      if (f2 != v) rot(((u == ch[f1][1]) ^ (f1 == ch[f2][1])) ? u : f1);
      rot(u);
    }
    if (!v) rt = u;
  }
  void ins(int x, int ID) {
    int u = rt, f = 0;
    while (u) pushdown(u), f = u, u = ch[u][x > val[u]];
    u = pool[tot--];
    val[u] = x;
    id[u] = ID;
    ch[u][0] = ch[u][1] = fa[u] = tag[u] = ans[u] = 0;
    if (f) con(u, f, x > val[f]);
    splay(u, 0);
  }
  int pre(int x) {
    int u = rt, res = 0;
    while (u) {
      pushdown(u);
      if (val[u] < x)
        res = u, u = ch[u][1];
      else
        u = ch[u][0];
    }
    return res;
  }
  int nxt(int x) {
    int u = rt, res = 0;
    while (u) {
      pushdown(u);
      if (val[u] > x)
        res = u, u = ch[u][0];
      else
        u = ch[u][1];
    }
    return res;
  }
  void trans(int u, int x) {
    if (!u) return;
    pushdown(u);
    trans(ch[u][0], x);
    trans(ch[u][1], x);
    pool[++tot] = u;
    num[id[u]]++;
    if (val[u] - x >= minc) ins(val[u] - x, id[u]);
  }
  void dfs(int u) {
    if (!u) return;
    pushdown(u);
    dfs(ch[u][0]);
    dfs(ch[u][1]);
  }
  void solve() {
    for (register int i = 1; i <= m + 1; i++) pool[++tot] = i;
    for (register int i = 1; i <= m; i++) ins(input(), i);
    ins(-inf, 0);
    for (register int i = 1; i <= n; i++) {
      int u, v, k;
      u = pre(a[i].ci);
      splay(u, 0);
      v = nxt((a[i].ci << 1) - 1);
      if (v) {
        splay(v, u);
        k = ch[v][0];
        ch[v][0] = 0;
        cover(v, -a[i].ci, 1);
        trans(k, a[i].ci);
      } else
        k = ch[u][1], ch[u][1] = 0, trans(k, a[i].ci);
    }
    dfs(rt);
    for (int i = 1; i <= m; i++) {
      print(num[i]);
      if (i < m) putchar(' ');
    }
  }
} ts;
void File() {
  freopen("data.in", "r", stdin);
  freopen("ans.out", "w", stdout);
}
int main() {
  srand(time(0));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    a[i].ci = input(), a[i].qi = input(), minc = min(minc, a[i].ci);
  sort(a + 1, a + n + 1);
  scanf("%d", &m);
  ts.solve();
  return 0;
}
