#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e6) + 5;
const int oo = 2e9;
struct treap {
  treap *l, *r;
  int pr;
  int key;
  int ans;
  int ind;
  int to_key, to_ans;
  void up(void) {
    key += to_key;
    ans += to_ans;
    if (l) l->to_ans += to_ans, l->to_key += to_key;
    if (r) r->to_ans += to_ans, r->to_key += to_key;
    to_ans = to_key = 0;
  }
  treap(int key, int ind)
      : ans(0),
        ind(ind),
        key(key),
        pr(rand()),
        l(0),
        r(0),
        to_key(0),
        to_ans(0) {
    up();
  }
};
int ans[N];
typedef treap *tr;
tr Merge(tr a, tr b) {
  if (a) a->up();
  if (b) b->up();
  if (!a) return b;
  if (!b) return a;
  if (a->pr > b->pr) {
    a->r = Merge(a->r, b);
    a->up();
    return a;
  } else {
    b->l = Merge(a, b->l);
    b->up();
    return b;
  }
}
void Split(tr Root, tr &Left, tr &Right, int k) {
  if (!Root) return void(Left = Right = 0);
  Root->up();
  if (Root->key <= k) {
    Split(Root->r, Root->r, Right, k);
    Left = Root;
  } else {
    Split(Root->l, Left, Root->l, k);
    Right = Root;
  }
  if (Left) Left->up();
  if (Right) Right->up();
}
void add(tr &Root, int key, int id) {
  tr Left, Right;
  Split(Root, Left, Right, key);
  Root = Merge(Merge(Left, new treap(key, id)), Right);
}
int Min(tr Root) {
  if (!Root) return oo;
  Root->up();
  if (!Root->l)
    return Root->key;
  else
    return Min(Root->l);
}
int Max(tr Root) {
  if (!Root) return -oo;
  Root->up();
  if (!Root->r)
    return Root->key;
  else
    return Max(Root->r);
}
void go(tr &Root, int C) {
  tr Left, Right;
  Split(Root, Left, Right, C - 1);
  if (Right) Right->to_ans++, Right->to_key -= C;
  while (Min(Right) < Max(Left)) {
    int cnt = Min(Right);
    tr A, B;
    Split(Right, A, B, cnt);
    Right = B;
    tr C, D;
    Split(Left, C, D, cnt);
    Left = Merge(Merge(C, A), D);
  }
  Root = Merge(Left, Right);
}
void dfs(tr Root) {
  if (!Root) return;
  Root->up();
  ans[Root->ind] = Root->ans;
  dfs(Root->l);
  dfs(Root->r);
}
tr Root = 0;
int main(void) {
  srand(time(0));
  int n;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end(), [&](pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) return a.second > b.second;
    return a.first < b.first;
  });
  int m;
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    int val;
    cin >> val;
    add(Root, val, i);
  }
  for (auto it : v) go(Root, it.first);
  dfs(Root);
  for (int i = 1; i <= m; ++i) cout << ans[i] << " \n"[i == m];
  return 0;
}
