#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
inline int rin(int &r) {
  int b = 1, c = getchar();
  r = 0;
  while (c < '0' || '9' < c) b = c == '-' ? -1 : b, c = getchar();
  while ('0' <= c && c <= '9')
    r = (r << 1) + (r << 3) + (c ^ '0'), c = getchar();
  return r *= b;
}
struct TNode {
  int nxt[2], key, ans, fix, lkey, lans;
  inline int &operator[](const int &i) { return nxt[i]; }
};
struct Treap {
  TNode nod[N];
  int rt;
  void update(const int &u, const int &key, const int &ans) {
    nod[u].key += key, nod[u].lkey += key;
    nod[u].ans += ans, nod[u].lans += ans;
  }
  void pushDown(const int &u) {
    if (nod[u].lkey || nod[u].lans) {
      if (nod[u][0]) update(nod[u][0], nod[u].lkey, nod[u].lans);
      if (nod[u][1]) update(nod[u][1], nod[u].lkey, nod[u].lans);
      nod[u].lans = nod[u].lkey = 0;
    }
  }
  int ina_merge(const int &u, const int &v) {
    if (!u || !v) return u | v;
    pushDown(u), pushDown(v);
    if (nod[u].fix < nod[v].fix) {
      nod[u][1] = ina_merge(nod[u][1], v);
      return u;
    } else {
      nod[v][0] = ina_merge(u, nod[v][0]);
      return v;
    }
  }
  pair<int, int> splitKey(const int &u, const int &key) {
    pair<int, int> res(0, 0);
    if (!u) return res;
    pushDown(u);
    if (nod[u].key > key) {
      res = splitKey(nod[u][0], key);
      nod[u][0] = res.second, res.second = u;
    } else {
      res = splitKey(nod[u][1], key);
      nod[u][1] = res.first, res.first = u;
    }
    return res;
  }
  int initValue(const int &u, const int &key) {
    nod[u] = (TNode){{0, 0}, key, 0, rand(), 0, 0};
    return u;
  }
  void ina_insert(const int &u, int &to) {
    pair<int, int> tmp = splitKey(to, nod[u].key);
    to = ina_merge(ina_merge(tmp.first, u), tmp.second);
  }
  void bfInsert(const int &u, int &to) {
    if (!u) return;
    pushDown(u);
    bfInsert(nod[u][0], to), bfInsert(nod[u][1], to);
    nod[u][0] = nod[u][1] = 0;
    ina_insert(u, to);
  }
  void toggleAns(const int &u) {
    if (!u) return;
    pushDown(u);
    toggleAns(nod[u][0]), toggleAns(nod[u][1]);
  }
} tr;
int n, m;
pair<int, int> shirt[N];
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second != b.second) return a.second > b.second;
  return a.first < b.first;
}
int main() {
  rin(n);
  for (int i = 1; i <= n; i++) rin(shirt[i].first), rin(shirt[i].second);
  sort(shirt + 1, shirt + 1 + n, cmp);
  rin(m);
  for (int i = 1, val; i <= m; i++)
    tr.ina_insert(tr.initValue(i, rin(val)), tr.rt);
  for (int i = 1; i <= n; i++) {
    pair<int, int> tmp = tr.splitKey(tr.rt, shirt[i].first - 1);
    tr.update(tmp.second, -shirt[i].first, 1);
    pair<int, int> tmp2 = tr.splitKey(tmp.second, shirt[i].first - 1);
    tr.bfInsert(tmp2.first, tmp.first);
    tr.rt = tr.ina_merge(tmp.first, tmp2.second);
  }
  tr.toggleAns(tr.rt);
  for (int i = 1; i <= m; i++)
    printf("%d%c", tr.nod[i].ans, i == m ? '\n' : ' ');
  return 0;
}
