#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, m, rt;
int ch[N][2], sz[N], rnd[N], add1[N], add2[N], ans[N], val[N];
struct node {
  int c, q;
} s[N];
inline void update(int p) { sz[p] = sz[ch[p][0]] + sz[ch[p][1]] + 1; }
inline void down(int p) {
  if (add1[p]) {
    add1[ch[p][0]] += add1[p];
    add1[ch[p][1]] += add1[p];
    ans[ch[p][0]] += add1[p];
    ans[ch[p][1]] += add1[p];
    add1[p] = 0;
  }
  if (add2[p]) {
    add2[ch[p][0]] += add2[p];
    add2[ch[p][1]] += add2[p];
    val[ch[p][0]] += add2[p];
    val[ch[p][1]] += add2[p];
    add2[p] = 0;
  }
}
inline int Rank(int p, int v, int r = 0) {
  for (; p;
       down(p), p = v <= val[p] ? ch[p][0] : (r += sz[ch[p][0]] + 1, ch[p][1]))
    ;
  return r;
}
inline void split(int p, int k, int &x, int &y) {
  if (!p) return x = y = 0, void();
  down(p);
  if (k <= sz[ch[p][0]])
    split(ch[p][0], k, x, ch[p][0]), y = p, update(p);
  else
    split(ch[p][1], k - sz[ch[p][0]] - 1, ch[p][1], y), x = p, update(p);
}
inline int merge(int x, int y) {
  if (!x || !y) return x | y;
  if (rnd[x] > rnd[y])
    return down(x), ch[x][1] = merge(ch[x][1], y), update(x), x;
  else
    return down(y), ch[y][0] = merge(x, ch[y][0]), update(y), y;
}
inline vector<int> Get(int r) {
  vector<int> que;
  if (!r) return que;
  int head = 0;
  que.push_back(r);
  while (head < que.size()) {
    int x = que[head++];
    down(x);
    if (ch[x][0]) que.push_back(ch[x][0]);
    if (ch[x][1]) que.push_back(ch[x][1]);
  }
  return que;
}
inline int read(register int x = 0, register char ch = getchar(),
                register int f = 0) {
  for (; !isdigit(ch); ch = getchar()) f = ch == '-';
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return f ? -x : x;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) s[i].c = read(), s[i].q = read();
  sort(s + 1, s + n + 1, [](const node &a, const node &b) {
    return a.q == b.q ? a.c < b.c : a.q > b.q;
  });
  m = read();
  for (int i = 1, a; i <= m; ++i) {
    val[i] = read();
    sz[i] = 1;
    rnd[i] = rand();
    split(rt, Rank(rt, val[i]), rt, a);
    rt = merge(rt, merge(i, a));
  }
  for (int i = 1, a, b; i <= n; ++i) {
    split(rt, Rank(rt, s[i].c), rt, a);
    ++add1[a];
    ++ans[a];
    add2[a] -= s[i].c;
    val[a] -= s[i].c;
    split(a, Rank(a, 2 * s[i].c), a, b);
    vector<int> F = Get(a);
    for (auto p : F)
      split(rt, Rank(rt, val[p]), rt, a), ch[p][0] = ch[p][1] = 0, sz[p] = 1,
                                          add1[p] = add2[p] = 0,
                                          rt = merge(rt, merge(p, a));
    rt = merge(rt, b);
  }
  Get(rt);
  for (int i = 1; i <= m; ++i) printf("%d ", ans[i]);
  return puts(""), 0;
}
