#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int MAXM = 2e5 + 5;
inline int rnd(void) { return (rand() << 15) | rand(); }
struct Treap {
  struct Node {
    int val, num, fix, tval, tnum;
    Node *son[2];
    Node(int val, Node *emp) : val(val), num(0), fix(rnd()), tval(0), tnum(0) {
      son[0] = son[1] = emp;
    }
  } * emp, *root;
  Treap(void) : emp(new Node(-1, 0)), root(emp) {}
  inline Node *new_Node(int val) { return new Node(val, emp); }
  inline void del_Node(Node *&u, Node *to) {
    delete u;
    u = to;
  }
  inline void mark(Node *u, int tval, int tnum) {
    if (~u->val) u->val -= tval, u->num += tnum;
    u->tval += tval, u->tnum += tnum;
  }
  inline void push_down(Node *u) {
    if (u->tnum) {
      mark(u->son[0], u->tval, u->tnum);
      mark(u->son[1], u->tval, u->tnum);
      u->tval = u->tnum = 0;
    }
  }
  void split(Node *u, Node *&l, Node *&r, int k) {
    if (u->val == -1) {
      l = r = emp;
      return;
    }
    push_down(u);
    if (u->val <= k)
      l = u, split(u->son[1], l->son[1], r, k);
    else
      r = u, split(u->son[0], l, r->son[0], k);
  }
  void merge(Node *&u, Node *l, Node *r) {
    if (l->val == -1) {
      u = r;
      return;
    }
    if (r->val == -1) {
      u = l;
      return;
    }
    push_down(l);
    push_down(r);
    if (l->fix < r->fix)
      u = l, merge(u->son[1], l->son[1], r);
    else
      u = r, merge(u->son[0], l, r->son[0]);
  }
  void insert_all(Node *u, Node *&v) {
    if (u->val == -1) return;
    if (v->val == -1) {
      v = u;
      return;
    }
    push_down(u);
    Node *l, *r;
    split(v, l, r, u->val);
    insert_all(u->son[0], l);
    insert_all(u->son[1], r);
    u->son[0] = u->son[1] = emp;
    merge(v, l, u);
    merge(v, v, r);
  }
  Node *insert(int val) {
    Node *l, *r, *mid = new_Node(val);
    split(root, l, r, mid->val);
    merge(root, l, mid);
    merge(root, root, r);
    return mid;
  }
  void update(int val) {
    Node *l, *r, *mid;
    split(root, l, r, val - 1);
    mark(r, val, 1);
    split(r, mid, r, val * 2);
    insert_all(mid, l);
    merge(root, l, r);
  }
  void calc_all(Node *u) {
    if (u->val == -1) return;
    push_down(u);
    calc_all(u->son[0]);
    calc_all(u->son[1]);
  }
  inline void calc_all(void) { calc_all(root); }
} tree;
pair<int, int> a[MAXN];
int b[MAXN];
Treap::Node *p[MAXM];
int main(void) {
  srand((unsigned long long)new char);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int c, q;
    scanf("%d%d", &c, &q);
    a[i] = make_pair(-q, c);
  }
  sort(a + 1, a + n + 1);
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &b[i]);
    p[i] = tree.insert(b[i]);
  }
  for (int i = 1; i <= n; ++i) tree.update(a[i].second);
  tree.calc_all();
  for (int i = 1; i <= m; ++i) printf("%d ", p[i]->num);
  return 0;
}
