#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5;
struct NonRotateTreap {
  struct TreapNode {
    int sum, tag_sum;
    int cnt, tag_cnt;
    int fix;
    TreapNode *lch, *rch;
  };
  TreapNode pool[Maxn * 2 + 5];
  TreapNode *ncnt, *NIL;
  typedef pair<TreapNode *, TreapNode *> Droot;
  void init() {
    NIL = ncnt = &pool[0];
    NIL->lch = NIL->rch = NIL;
    NIL->fix = 0;
    NIL->sum = NIL->tag_sum = 0;
    NIL->cnt = NIL->tag_cnt = 0;
  }
  TreapNode *newnode(int val) {
    TreapNode *p = ++ncnt;
    p->fix = rand();
    p->lch = p->rch = NIL;
    p->sum = val, p->cnt = p->tag_cnt = p->tag_sum = 0;
    return p;
  }
  void maintain_sum(TreapNode *rt, int val) {
    if (rt == NIL) return;
    rt->sum += val, rt->tag_sum += val;
  }
  void maintain_cnt(TreapNode *rt, int val) {
    if (rt == NIL) return;
    rt->cnt += val, rt->tag_cnt += val;
  }
  void pushdown(TreapNode *rt) {
    if (rt->tag_sum) {
      maintain_sum(rt->lch, rt->tag_sum);
      maintain_sum(rt->rch, rt->tag_sum);
      rt->tag_sum = 0;
    }
    if (rt->tag_cnt) {
      maintain_cnt(rt->lch, rt->tag_cnt);
      maintain_cnt(rt->rch, rt->tag_cnt);
      rt->tag_cnt = 0;
    }
  }
  TreapNode *merge(TreapNode *rt1, TreapNode *rt2) {
    if (rt1 == NIL) return rt2;
    if (rt2 == NIL) return rt1;
    pushdown(rt1), pushdown(rt2);
    if (rt1->fix <= rt2->fix) {
      rt1->rch = merge(rt1->rch, rt2);
      return rt1;
    } else {
      rt2->lch = merge(rt1, rt2->lch);
      return rt2;
    }
  }
  Droot split(TreapNode *rt, int val) {
    Droot d(NIL, NIL);
    if (rt == NIL) return d;
    pushdown(rt);
    if (val <= rt->sum) {
      d = split(rt->lch, val);
      rt->lch = d.second;
      d.second = rt;
    } else {
      d = split(rt->rch, val);
      rt->rch = d.first;
      d.first = rt;
    }
    return d;
  }
  TreapNode *insert(TreapNode *rt, TreapNode *val) {
    Droot x = split(rt, val->sum);
    return merge(merge(x.first, val), x.second);
  }
  void push(TreapNode *&rt, TreapNode *x) {
    if (x == NIL) return;
    pushdown(x);
    push(rt, x->lch), push(rt, x->rch);
    x->lch = x->rch = NIL;
    rt = insert(rt, x);
  }
  TreapNode *update(TreapNode *rt, int val) {
    Droot x = split(rt, val);
    if (x.second == NIL) return merge(x.first, x.second);
    x.second->sum -= val, x.second->tag_sum -= val;
    x.second->cnt++, x.second->tag_cnt++;
    Droot y = split(x.second, val);
    if (y.first != NIL) push(x.first, y.first);
    return merge(x.first, y.second);
  }
  void clear_tag(TreapNode *rt) {
    if (rt == NIL) return;
    pushdown(rt);
    clear_tag(rt->lch), clear_tag(rt->rch);
  }
};
struct T_Shirt {
  int p, c;
  bool operator<(const T_Shirt &rhs) const {
    return (p == rhs.p) ? c < rhs.c : p > rhs.p;
  }
};
T_Shirt t[Maxn + 5];
NonRotateTreap::TreapNode *p[Maxn + 5], *root;
NonRotateTreap tree;
int N;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d %d", &t[i].c, &t[i].p);
  sort(t + 1, t + N + 1);
  int K;
  scanf("%d", &K);
  tree.init(), root = tree.NIL;
  for (int i = 1; i <= K; i++) {
    int val;
    scanf("%d", &val);
    p[i] = tree.newnode(val);
    root = tree.insert(root, p[i]);
  }
  for (int i = 1; i <= N; i++) root = tree.update(root, t[i].c);
  tree.clear_tag(root);
  for (int i = 1; i <= K; i++) printf("%d ", p[i]->cnt);
  return 0;
}
