#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
mt19937 rng(time(0));
pair<long long, long long> operator+(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  return pair<long long, long long>(a.first + b.first, a.second + b.second);
}
template <typename T>
struct treap {
  struct node {
    node *l, *r;
    int sz, prior;
    int res;
    pair<long long, long long> lazy;
    T key;
    node(T v, int res)
        : key(v),
          l(0),
          r(0),
          sz(1),
          prior(rng()),
          res(res),
          lazy(pair<long long, long long>(0, 0)) {}
  };
  typedef node *pnode;
  pnode root;
  treap() : root(0) {}
  int sz(pnode p) { return p ? p->sz : 0; }
  void update(pnode p) {
    if (p) p->sz = 1 + sz(p->l) + sz(p->r);
  }
  void up(pnode p, pair<long long, long long> x) {
    if (!p) return;
    p->key.first += x.first;
    p->res += x.second;
    p->lazy = p->lazy + x;
  }
  void push(pnode p) {
    if (!p) return;
    if (p->lazy == pair<long long, long long>(0, 0)) return;
    up(p->l, p->lazy);
    up(p->r, p->lazy);
    p->lazy = pair<long long, long long>(0, 0);
  }
  void update(int c) {
    pnode l, r;
    split(root, pair<long long, long long>(c - 1, (long long)(2e5 + 5)), l, r);
    up(r, pair<long long, long long>(-c, 1));
    push(r);
    if (!sz(l) || !sz(r)) {
      merge(root, l, r);
      return;
    }
    int szl = sz(l);
    pair<long long, long long> last = find_kth(l, szl)->key;
    while (sz(r)) {
      pnode kk = find_kth(r, 1);
      pair<long long, long long> ke = kk->key;
      int res = kk->res;
      if (ke > last) break;
      erase(r, pair<long long, long long>(ke));
      pnode nn = new node(ke, res);
      insert(l, nn);
    }
    merge(root, l, r);
  }
  void split(pnode p, T key, pnode &l, pnode &r) {
    push(p);
    if (!p)
      l = r = 0;
    else if (key < p->key) {
      split(p->l, key, l, p->l);
      r = p;
    } else {
      split(p->r, key, p->r, r);
      l = p;
    }
    update(p);
  }
  void insert(T key, int res) {
    pnode add = new node(key, res);
    insert(root, add);
  }
  void erase(T key) {
    int pos = order_of_key(key);
    if (pos && key == find_kth(pos)) erase(root, key);
  }
  int order_of_key(T key) { return order_of_key(root, key); }
  T find_kth(int k) { return find_kth(root, k)->key; }
  int size() { return sz(root); }
  int order_of_key(pnode p, T key) {
    push(p);
    if (!p) return 0;
    if (p->key <= key) return sz(p->l) + 1 + order_of_key(p->r, key);
    return order_of_key(p->l, key);
  }
  pnode find_kth(pnode p, int k) {
    push(p);
    int pos = sz(p->l) + 1;
    if (pos == k) return p;
    if (pos > k) return find_kth(p->l, k);
    return find_kth(p->r, k - pos);
  }
  void insert(pnode &p, pnode it) {
    push(p);
    if (!p)
      p = it;
    else if (it->prior > p->prior) {
      split(p, it->key, it->l, it->r);
      p = it;
    } else {
      if (it->key < p->key)
        insert(p->l, it);
      else
        insert(p->r, it);
    }
    update(p);
  }
  void merge(pnode &p, pnode l, pnode r) {
    push(p);
    if (!l || !r) {
      if (l)
        p = l;
      else
        p = r;
    } else if (l->prior > r->prior) {
      merge(l->r, l->r, r);
      p = l;
    } else {
      merge(r->l, l, r->l);
      p = r;
    }
    update(p);
  }
  void erase(pnode &p, T key) {
    push(p);
    if (p->key == key)
      merge(p, p->l, p->r);
    else if (key < p->key)
      erase(p->l, key);
    else
      erase(p->r, key);
    update(p);
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, long long> > cs;
  for (int i = 0; i < n; i++) {
    int c, q;
    cin >> c >> q;
    cs.push_back(pair<long long, long long>(q, -c));
  }
  sort((cs).rbegin(), (cs).rend());
  int k;
  cin >> k;
  vector<pair<long long, long long> > vt;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    vt.push_back(pair<long long, long long>(x, i));
  }
  sort((vt).begin(), (vt).end());
  treap<pair<long long, long long> > t;
  for (int i = 0; i < k; i++)
    t.insert(pair<long long, long long>(vt[i].first, vt[i].second), 0);
  for (int i = 0; i < n; i++) {
    int c = -cs[i].second;
    t.update(c);
  }
  vector<int> res(k);
  for (int i = 1; i <= k; i++) {
    int r1 = t.find_kth(t.root, i)->res;
    int id = t.find_kth(t.root, i)->key.second;
    res[id] = r1;
  }
  for (int i = 0; i < k; i++) cout << res[i] << ' ';
  cout << '\n';
  return 0;
}
