#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
struct TShirt {
  int c, q;
  bool operator<(const TShirt &tmp) const {
    if (q == tmp.q) return c < tmp.c;
    return q > tmp.q;
  }
} a[maxn];
struct Customer {
  int w, id;
  bool operator<(const Customer &tmp) const { return w < tmp.w; }
} b[maxn];
struct TreapNode {
  int ls, rs, id, rnd;
  int w, sz, ans;
  int dec, inc;
} tr[maxn];
int tot;
void update(int p, int dec, int inc) {
  tr[p].dec += dec;
  tr[p].inc += inc;
  tr[p].w -= dec;
  tr[p].ans += inc;
}
void pushup(int p) {
  int ls = tr[p].ls, rs = tr[p].rs;
  tr[p].sz = tr[ls].sz + tr[rs].sz + 1;
}
void pushdown(int p) {
  int ls = tr[p].ls, rs = tr[p].rs;
  if (tr[p].dec) {
    if (ls) update(ls, tr[p].dec, tr[p].inc);
    if (rs) update(rs, tr[p].dec, tr[p].inc);
    tr[p].dec = tr[p].inc = 0;
  }
}
int newNode(int w, int id) {
  int p = ++tot;
  tr[p].ls = tr[p].rs = 0;
  tr[p].id = id;
  tr[p].rnd = rand();
  tr[p].w = w;
  tr[p].sz = 1;
  tr[p].ans = 0;
  tr[p].dec = tr[p].inc = 0;
  return p;
}
int build(int l, int r) {
  int mid = (l + r) >> 1;
  int p = newNode(b[mid].w, b[mid].id);
  if (l <= mid - 1) tr[p].ls = build(l, mid - 1);
  if (mid + 1 <= r) tr[p].rs = build(mid + 1, r);
  pushup(p);
  return p;
}
void split(int p, int w, int &x, int &y) {
  if (!p) {
    x = y = 0;
    return;
  }
  pushdown(p);
  if (tr[p].w > w) {
    y = p;
    split(tr[p].ls, w, x, tr[p].ls);
  } else {
    x = p;
    split(tr[p].rs, w, tr[p].rs, y);
  }
  pushup(p);
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  if (tr[x].rnd > tr[y].rnd) {
    pushdown(x);
    tr[x].rs = merge(tr[x].rs, y);
    pushup(x);
    return x;
  } else {
    pushdown(y);
    tr[y].ls = merge(x, tr[y].ls);
    pushup(y);
    return y;
  }
}
void insert(int &x, int y) {
  if (!y) return;
  pushdown(y);
  insert(x, tr[y].ls);
  insert(x, tr[y].rs);
  tr[y].ls = tr[y].rs = 0;
  tr[y].sz = 1;
  int A, B;
  split(x, tr[y].w, A, B);
  x = merge(merge(A, y), B);
}
int ans[maxn];
void getAns(int p) {
  if (!p) return;
  pushdown(p);
  ans[tr[p].id] = tr[p].ans;
  getAns(tr[p].ls);
  getAns(tr[p].rs);
}
int main() {
  srand(time(0));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].c, &a[i].q);
  }
  sort(a + 1, a + 1 + n);
  int k;
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &b[i].w);
    b[i].id = i;
  }
  sort(b + 1, b + 1 + k);
  int rt = build(1, k);
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    split(rt, a[i].c - 1, x, y);
    update(y, a[i].c, 1);
    split(y, a[i].c - 1, y, z);
    insert(x, y);
    rt = merge(x, z);
  }
  getAns(rt);
  for (int i = 1; i <= k; i++) {
    printf("%d%c", ans[i], i == k ? '\n' : ' ');
  }
  return 0;
}
