#include <bits/stdc++.h>
using namespace std;
const int nsz = 2e5;
int n, m;
struct treap {
  int rt, sz, s[nsz + 5][2], val[nsz + 5], key[nsz + 5], cnt[nsz + 5],
      siz[nsz + 5], del[nsz + 5][2];
  void inline chg(int u, int v1, int v2) {
    val[u] += v1;
    cnt[u] += v2;
    del[u][0] += v1;
    del[u][1] += v2;
  }
  void inline up(int u) { siz[u] = siz[s[u][0]] + siz[s[u][1]] + 1; }
  void inline down(int u) {
    if (!del[u][0] && !del[u][1]) return;
    int ls = s[u][0], rs = s[u][1];
    if (ls) {
      chg(ls, del[u][0], del[u][1]);
    }
    if (rs) {
      chg(rs, del[u][0], del[u][1]);
    }
    del[u][0] = del[u][1] = 0;
  }
  int inline node(int w) {
    int u = ++sz;
    val[u] = w;
    siz[u] = 1;
    key[u] = rand();
    return u;
  }
  int merge(int v1, int v2) {
    if (!v1 || !v2) return v1 | v2;
    if (key[v1] > key[v2]) {
      down(v1);
      s[v1][1] = merge(s[v1][1], v2);
      up(v1);
      return v1;
    } else {
      down(v2);
      s[v2][0] = merge(v1, s[v2][0]);
      up(v2);
      return v2;
    }
  }
  void split(int u, int w, int &v1, int &v2) {
    if (!u) {
      v1 = v2 = 0;
      return;
    }
    down(u);
    if (val[u] <= w) {
      v1 = u;
      split(s[u][1], w, s[u][1], v2);
    } else {
      v2 = u;
      split(s[u][0], w, v1, s[u][0]);
    }
    up(u);
  }
  void ins(int w) {
    int v1, v2;
    split(rt, w, v1, v2);
    rt = merge(merge(v1, node(w)), v2);
  }
  void ins(int &u, int v) {
    int v1, v2;
    split(u, val[v], v1, v2);
    u = merge(merge(v1, v), v2);
  }
};
treap tr;
struct data {
  int q, w;
  data() {}
  data(int q, int w) {
    this->q = q;
    this->w = w;
  }
};
data dat[nsz + 5];
bool inline operator<(data a, data b) {
  return a.q != b.q ? a.q > b.q : a.w < b.w;
}
void down(int u = tr.rt) {
  int ls = tr.s[u][0], rs = tr.s[u][1];
  tr.down(u);
  if (ls) {
    down(ls);
  }
  if (rs) {
    down(rs);
  }
}
void ins(int &to, int u) {
  tr.down(u);
  int ls = tr.s[u][0], rs = tr.s[u][1];
  if (ls) {
    ins(to, ls);
  }
  if (rs) {
    ins(to, rs);
  }
  tr.s[u][0] = tr.s[u][1] = 0;
  tr.ins(to, u);
}
void inline upd(int w) {
  int v1, v2, v3;
  tr.split(tr.rt, w - 1, v1, v2);
  if (v2) {
    tr.chg(v2, -w, 1);
    tr.split(v2, w - 1, v2, v3);
    if (v2) {
      ins(v1, v2);
    }
    tr.rt = tr.merge(v1, v3);
  }
}
int inline read() {
  int res = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar())
    ;
  return res;
}
void inline write(int a, char c) {
  int s = 0, d[10] = {0};
  for (; a; d[s++] = a % 10, a /= 10)
    ;
  for (s = s ? s : 1; s; putchar(d[--s] + 48))
    ;
  putchar(c);
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    dat[i].w = read(), dat[i].q = read();
  }
  sort(dat + 1, dat + n + 1);
  m = read();
  for (int i = 1; i <= m; ++i) {
    int w = read();
    tr.ins(w);
  }
  for (int i = 1; i <= n; ++i) {
    int w = dat[i].w;
    upd(w);
  }
  down();
  for (int i = 1; i <= m; ++i) {
    write(tr.cnt[i], ' ');
  }
  putchar('\n');
}
