#include <bits/stdc++.h>
using namespace std;
mt19937 rnd;
struct node {
  int id;
  unsigned rnk;
  int c, lc, s, ls;
  node *l, *r;
  node(int _id, int _c) {
    rnk = rnd();
    id = _id, c = _c;
    lc = s = ls = 0;
    l = r = nullptr;
  }
  void push() {
    c += lc, s += ls;
    if (l) l->lc += lc, l->ls += ls;
    if (r) r->lc += lc, r->ls += ls;
    lc = ls = 0;
  }
  void print() {
    printf("id:%d, rnk:%u, c:%d, lc:%d, s:%d, ls:%d\n", id, rnk, c, lc, s, ls);
    if (l) l->print();
    if (r) r->print();
  }
};
pair<node*, node*> split(node* n, int k) {
  if (!n) return {n, n};
  n->push();
  node *l, *r;
  if (n->c >= k) {
    tie(l, r) = split(n->l, k);
    n->l = r;
    return {l, n};
  } else {
    tie(l, r) = split(n->r, k);
    n->r = l;
    return {n, r};
  }
}
node* merge(node* p, node* q) {
  if (!p) return q;
  if (!q) return p;
  p->push(), q->push();
  if (p->rnk > q->rnk) {
    p->r = merge(p->r, q);
    return p;
  } else {
    q->l = merge(p, q->l);
    return q;
  }
}
node* get_left(node* n) {
  if (!n) return n;
  n->push();
  if (!n->l) return n;
  return get_left(n->l);
}
node* get_right(node* n) {
  if (!n) return n;
  n->push();
  if (!n->r) return n;
  return get_right(n->r);
}
node* insert(node* root, node* n) {
  if (!root) return n;
  node *l, *r;
  tie(l, r) = split(root, n->c);
  return merge(l, merge(n, r));
}
struct shirt {
  int c, q;
  bool operator<(const shirt& rhs) const {
    if (q == rhs.q) return c < rhs.c;
    return q > rhs.q;
  }
};
shirt sh[200000];
int ans[200000];
void dfs(node* n) {
  n->push();
  ans[n->id] = n->s;
  if (n->l) dfs(n->l);
  if (n->r) dfs(n->r);
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int c, q;
    scanf("%d%d", &c, &q);
    sh[i] = {c, q};
  }
  sort(sh, sh + N);
  int K;
  scanf("%d", &K);
  node* root = nullptr;
  for (int i = 0; i < K; i++) {
    int c;
    scanf("%d", &c);
    node* here = new node(i, c);
    root = insert(root, here);
  }
  for (int i = 0; i < N; i++) {
    node *l, *r;
    int c = sh[i].c;
    tie(l, r) = split(root, c);
    if (r) {
      r->ls += 1;
      r->lc -= c;
      while (1) {
        node *ld = get_right(l), *rd = get_left(r);
        if (!ld || !rd) break;
        if (ld->c <= rd->c) break;
        node* n;
        tie(n, r) = split(r, rd->c + 1);
        l = insert(l, n);
      }
      root = merge(l, r);
    } else
      root = l;
  }
  dfs(root);
  for (int i = 0; i < K; i++) printf("%d ", ans[i]);
}
