#include <bits/stdc++.h>
using namespace std;
int sz[1000010], ls[1000010], rs[1000010], val[1000010], por[1000010],
    ans[1000010], tag[1000010];
int del[1000010], n, m, rt;
pair<int, int> a[1000010];
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
void update(int p) { sz[p] = sz[ls[p]] + sz[rs[p]] + 1; }
void pushdown(int p) {
  if (tag[p]) {
    if (ls[p]) tag[ls[p]] += tag[p], ans[ls[p]] += tag[p];
    if (rs[p]) tag[rs[p]] += tag[p], ans[rs[p]] += tag[p];
    tag[p] = 0;
  }
  if (del[p]) {
    if (ls[p]) del[ls[p]] += del[p], val[ls[p]] -= del[p];
    if (rs[p]) del[rs[p]] += del[p], val[rs[p]] -= del[p];
    del[p] = 0;
  }
  return;
}
void pdd(int p) {
  pushdown(p);
  if (ls[p]) pdd(ls[p]);
  if (rs[p]) pdd(rs[p]);
}
int merge(int x, int y) {
  if (!x || !y) return x ^ y;
  if (por[x] >= por[y]) {
    pushdown(x);
    rs[x] = merge(rs[x], y);
    update(x);
    return x;
  } else {
    pushdown(y);
    ls[y] = merge(x, ls[y]);
    update(y);
    return y;
  }
}
pair<int, int> splitval(int p, int k) {
  if (!p) return {0, 0};
  pushdown(p);
  pair<int, int> ans;
  if (val[p] > k) {
    ans = splitval(ls[p], k);
    ls[p] = ans.second;
    update(p);
    ans.second = p;
  } else {
    ans = splitval(rs[p], k);
    rs[p] = ans.first;
    update(p);
    ans.first = p;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int c, q;
    scanf("%d%d", &c, &q);
    a[i] = {q, c};
  }
  sort(a + 1, a + 1 + n, cmp);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int q;
    scanf("%d", &q);
    pair<int, int> tmp = splitval(rt, q);
    val[i] = q;
    sz[i] = 1;
    por[i] = rand();
    rt = merge(merge(tmp.first, i), tmp.second);
  }
  for (int i = 1; i <= n; i++) {
    pair<int, int> ab = splitval(rt, a[i].second - 1);
    pair<int, int> cd = splitval(ab.second, a[i].second + a[i].second - 1);
    del[cd.second] += a[i].second;
    val[cd.second] -= a[i].second;
    tag[cd.second]++;
    ans[cd.second]++;
    queue<int> Q;
    Q.push(cd.first);
    while (!Q.empty()) {
      int nowp = Q.front();
      Q.pop();
      pushdown(nowp);
      if (ls[nowp]) Q.push(ls[nowp]);
      if (rs[nowp]) Q.push(rs[nowp]);
      pair<int, int> aa = splitval(ab.first, val[nowp] - a[i].second);
      del[nowp] = tag[nowp] = ls[nowp] = rs[nowp] = 0;
      val[nowp] -= a[i].second, ans[nowp]++, sz[nowp] = 1;
      ab.first = merge(merge(aa.first, nowp), aa.second);
    }
    rt = merge(ab.first, cd.second);
  }
  pdd(rt);
  for (int i = 1; i <= m; i++) {
    printf("%d ", ans[i]);
  }
}
