#include <bits/stdc++.h>
using namespace std;
template <typename T>
using v = vector<T>;
const long long inf = 4611686018427387903;
const long double EPS = 1e-10;
void read() {}
template <typename Arg, typename... Args>
void read(Arg& arg, Args&... args) {
  cin >> (arg);
  read(args...);
}
void print() {}
template <typename Arg, typename... Args>
void print(Arg arg, Args... args) {
  cout << (arg) << " ";
  print(args...);
}
int getInt() {
  int a;
  cin >> a;
  return a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long M = 1000000001;
struct treap {
  treap *l = nullptr, *r = nullptr;
  int x, y, ind, tshirt = 0, siz = 1;
  long long lazy = 0;
  int val;
  treap(int xx, int i) : x(xx), y(rng()), ind(i), val(xx) {}
  void upd() {
    pushdown();
    val = x;
    if (l != nullptr) {
      l->pushdown();
      val = min(val, l->val);
    }
    if (r != nullptr) {
      r->pushdown();
      val = min(val, r->val);
    }
    siz = ((l == nullptr) ? 0 : l->siz) + ((r == nullptr) ? 0 : r->siz) + 1;
  }
  void pushdown() {
    if (lazy) {
      tshirt += lazy / M;
      val -= lazy % M;
      x -= lazy % M;
      if (l != nullptr) l->lazy += lazy;
      if (r != nullptr) r->lazy += lazy;
      lazy = 0;
    }
  }
};
int siz(treap* a) { return (a == nullptr) ? 0 : a->siz; }
treap* merge(treap* t1, treap* t2) {
  if (t1 == nullptr) return t2;
  if (t2 == nullptr) return t1;
  t1->pushdown();
  t2->pushdown();
  if (t1->y > t2->y) {
    t1->r = merge(t1->r, t2);
    t1->upd();
    return t1;
  } else {
    t2->l = merge(t1, t2->l);
    t2->upd();
    return t2;
  }
}
int val(treap* t) {
  if (t == nullptr) return 0;
  t->pushdown();
  return t->x;
}
pair<treap*, treap*> split(treap* t, int k) {
  if (t == nullptr) return {nullptr, nullptr};
  t->pushdown();
  if (siz(t->l) >= k) {
    pair<treap*, treap*> res = split(t->l, k);
    t->l = res.second;
    t->upd();
    return {res.first, t};
  } else {
    pair<treap*, treap*> res = split(t->r, k - siz(t->l) - 1);
    t->r = res.first;
    t->upd();
    return {t, res.second};
  }
}
inline treap* addAll(treap* t, long long a) {
  if (t != nullptr) t->lazy += a;
  return t;
}
inline treap* ins(treap* a, treap* t) {
  a->upd();
  treap* cur = t;
  int amount = 0;
  while (cur != nullptr) {
    cur->pushdown();
    if (cur->x < a->x) {
      amount += siz(cur->l) + 1;
      cur = cur->r;
    } else
      cur = cur->l;
  }
  pair<treap*, treap*> p = split(t, amount);
  t = merge(merge(p.first, a), p.second);
  return t;
}
void prnt(treap* cur) {
  if (cur == nullptr) return;
  cur->pushdown();
  prnt(cur->l);
  print(cur->x);
  prnt(cur->r);
}
treap* getLast(treap* t) {
  treap* ans = t;
  for (; t != nullptr; t = t->r) {
    t->pushdown();
    ans = t;
  }
  return ans;
}
treap* getFirst(treap* t) {
  treap* ans = t;
  for (; t != nullptr; t = t->l) {
    t->pushdown();
    ans = t;
  }
  return ans;
}
const int K = 2e5 + 1;
int ans[K];
void makeAns(treap* cur) {
  if (cur == nullptr) return;
  cur->pushdown();
  makeAns(cur->l);
  ans[cur->ind] = cur->tshirt;
  makeAns(cur->r);
}
void run() {
  int n;
  cin >> n;
  pair<int, int> raw[n];
  for (int i = (0); i < (n); i++) {
    int c, q;
    read(c, q);
    raw[i] = {c, q};
  }
  sort(raw, raw + n, [](pair<int, int> a, pair<int, int> b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
  });
  int k;
  cin >> k;
  treap* rt = nullptr;
  for (int i = (0); i < (k); i++) {
    int c;
    cin >> c;
    rt = ins(new treap(c, i), rt);
  }
  for (int i = (0); i < (n); i++) {
    int cost = raw[i].first;
    treap* cur = rt;
    int toRemove = 0;
    while (cur != nullptr) {
      cur->pushdown();
      if (cur->x >= cost)
        cur = cur->l;
      else {
        toRemove += siz(cur->l) + 1;
        cur = cur->r;
      }
    }
    auto tmp = split(rt, toRemove);
    tmp.second = addAll(tmp.second, M + (long long)cost);
    int need = val(getLast(tmp.first));
    assert(need < cost);
    while (tmp.second != nullptr && need > val(getFirst(tmp.second))) {
      pair<treap*, treap*> d = split(tmp.second, 1);
      treap* cur = tmp.first;
      int amount = 0;
      while (cur != nullptr) {
        cur->pushdown();
        if (cur->x < d.first->x) {
          amount += siz(cur->l) + 1;
          cur = cur->r;
        } else
          cur = cur->l;
      }
      pair<treap*, treap*> p = split(tmp.first, amount);
      tmp.first = merge(merge(p.first, d.first), p.second);
      tmp.second = d.second;
    }
    rt = merge(tmp.first, tmp.second);
  }
  makeAns(rt);
  for (int i = (0); i < (k); i++) print(ans[i]);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(12);
  run();
}
