#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, k, ans[N];
struct Tshirt {
  int c, q;
  Tshirt() {}
  void input() { scanf("%d%d", &c, &q); }
  bool operator<(const Tshirt &a) const {
    if (q == a.q) return c < a.c;
    return q > a.q;
  }
} T[N];
struct Cus {
  int x, id;
  Cus() {}
  void input() { scanf("%d", &x); }
  bool operator<(const Cus &a) const { return x < a.x; }
} a[N];
struct Treap {
  Treap *l, *r;
  int fix, key, size, id, ans, lazy, lazy1;
  Treap(int key_, int id_)
      : fix(rand()),
        key(key_),
        id(id_),
        l(NULL),
        r(NULL),
        size(1),
        ans(0),
        lazy(0),
        lazy1(0) {}
  inline void update() { size = 1 + (l ? l->size : 0) + (r ? r->size : 0); }
} * root;
typedef pair<Treap *, Treap *> Droot;
inline int Size(Treap *x) { return x ? x->key : 0; }
inline void pushdown(Treap *x) {
  if (!x) return;
  if (x->l)
    x->l->ans += x->lazy, x->l->lazy += x->lazy, x->l->key -= x->lazy1,
        x->l->lazy1 += x->lazy1;
  if (x->r)
    x->r->ans += x->lazy, x->r->lazy += x->lazy, x->r->key -= x->lazy1,
        x->r->lazy1 += x->lazy1;
  x->lazy = x->lazy1 = 0;
}
Treap *Merge(Treap *A, Treap *B) {
  pushdown(A);
  pushdown(B);
  if (!A) return B;
  if (!B) return A;
  if (A->fix < B->fix) {
    A->r = Merge(A->r, B);
    A->update();
    return A;
  } else {
    B->l = Merge(A, B->l);
    B->update();
    return B;
  }
}
Treap *Build(Cus *a) {
  static Treap *stack[N], *x, *last;
  int p = 0;
  sort(a + 1, a + 1 + k);
  for (int i = 1; i <= k; i++) {
    x = new Treap(a[i].x, a[i].id);
    last = NULL;
    while (p && stack[p]->fix > x->fix) {
      stack[p]->update();
      last = stack[p];
      stack[p--] = NULL;
    }
    if (p) stack[p]->r = x;
    x->l = last;
    stack[++p] = x;
  }
  while (p) stack[p--]->update();
  return stack[1];
}
Droot Split(Treap *x, int k) {
  pushdown(x);
  if (!x) return Droot(NULL, NULL);
  Droot y;
  if (Size(x) <= k) {
    y = Split(x->r, k);
    x->r = y.first;
    x->update();
    y.first = x;
  } else {
    y = Split(x->l, k);
    x->l = y.second;
    x->update();
    y.second = x;
  }
  return y;
}
Droot Split1(Treap *x) {
  pushdown(x);
  if (!x) return Droot(NULL, NULL);
  Droot y;
  if (x->l) {
    y = Split1(x->l);
    x->l = y.second;
    x->update();
    y.second = x;
  } else {
    y.first = x;
    y.second = x->r;
    x->r = NULL;
    x->update();
  }
  return y;
}
int Getmin(Treap *x) {
  if (!x) return 1e9 + 7;
  while (x->l) pushdown(x), x = x->l;
  return x->key;
}
int Getmax(Treap *x) {
  if (!x) return -1;
  while (x->r) pushdown(x), x = x->r;
  return x->key;
}
void work(int k) {
  Droot x = Split(root, k - 1);
  if (x.second == NULL) return;
  x.second->ans++;
  x.second->lazy++;
  x.second->key -= k;
  x.second->lazy1 += k;
  int Min = Getmin(x.second);
  int Max = Getmax(x.first);
  while (Min < Max) {
    Droot y = Split1(x.second);
    x.second = y.second;
    Droot yy = Split(x.first, y.first->key);
    x.first = Merge(Merge(yy.first, y.first), yy.second);
    Min = Getmin(x.second);
  }
  root = Merge(x.first, x.second);
}
void Dfs(Treap *x) {
  if (!x) return;
  pushdown(x);
  ans[x->id] = x->ans;
  Dfs(x->l);
  Dfs(x->r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) T[i].input();
  sort(T + 1, T + 1 + n);
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) a[i].id = i, a[i].input();
  root = Build(a);
  for (int i = 1; i <= n; i++) work(T[i].c);
  Dfs(root);
  for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
}
