#include <bits/stdc++.h>
using namespace std;
struct Shirt {
  int c, q;
  bool operator<(const Shirt& rhs) const {
    return q > rhs.q || q == rhs.q && c < rhs.c;
  }
} shirts[200000];
int b[200000], ans[200000];
struct Node {
  int l, r, sz, key, ind, cnt, tag_cost, tag_cnt, rnd;
} nodes[200000];
inline void update(int x) {
  nodes[x].sz = 1 + (nodes[x].l == -1 ? 0 : nodes[nodes[x].l].sz) +
                (nodes[x].r == -1 ? 0 : nodes[nodes[x].r].sz);
}
inline void clean(int x) {
  Node& n = nodes[x];
  if (n.l != -1) {
    Node& c = nodes[n.l];
    c.tag_cost += n.tag_cost;
    c.key -= n.tag_cost;
    c.tag_cnt += n.tag_cnt;
    c.cnt += n.tag_cnt;
  }
  if (n.r != -1) {
    Node& c = nodes[n.r];
    c.tag_cost += n.tag_cost;
    c.key -= n.tag_cost;
    c.tag_cnt += n.tag_cnt;
    c.cnt += n.tag_cnt;
  }
  n.tag_cost = n.tag_cnt = 0;
}
inline int size(int x, int v) {
  int ans = 0;
  while (x != -1) {
    clean(x);
    if (v < nodes[x].key) {
      x = nodes[x].l;
    } else {
      ans += nodes[x].l == -1 ? 1 : nodes[nodes[x].l].sz + 1;
      x = nodes[x].r;
    }
  }
  return ans;
}
pair<int, int> split(int x, int k) {
  if (!k) return {-1, x};
  clean(x);
  Node& nx = nodes[x];
  if (k == nx.sz) return {x, -1};
  if (nx.l != -1 && k == nodes[nx.l].sz) {
    int t = nx.l;
    nx.l = -1;
    update(x);
    return {t, x};
  }
  if (k == (nx.l == -1 ? 1 : nodes[nx.l].sz + 1)) {
    int t = nx.r;
    nx.r = -1;
    update(x);
    return {x, t};
  }
  if (nx.l != -1 && k < nodes[nx.l].sz) {
    auto p = split(nx.l, k);
    nx.l = p.second;
    update(x);
    return {p.first, x};
  } else {
    auto p = split(nx.r, k - (nx.l == -1 ? 1 : nodes[nx.l].sz + 1));
    nx.r = p.first;
    update(x);
    return {x, p.second};
  }
}
int merge(int x, int y) {
  if (!~x || !~y) return x & y;
  if (nodes[x].rnd < nodes[y].rnd) {
    clean(x);
    nodes[x].r = merge(nodes[x].r, y);
    update(x);
    return x;
  } else {
    clean(y);
    nodes[y].l = merge(x, nodes[y].l);
    update(y);
    return y;
  }
}
int insert(int x, int dst) {
  if (!~x) return dst;
  clean(x);
  Node& nx = nodes[x];
  dst = insert(nx.l, insert(nx.r, dst));
  nx.l = nx.r = -1;
  nx.sz = 1;
  auto p = split(dst, size(dst, nx.key));
  return merge(merge(p.first, x), p.second);
}
void get_ans(int x, int* ans) {
  if (!~x) return;
  clean(x);
  Node& nx = nodes[x];
  ans[nx.ind] = nx.cnt;
  get_ans(nx.l, ans);
  get_ans(nx.r, ans);
}
void traverse(int x, int sp = 0) {
  if (x == -1) return;
  Node& n = nodes[x];
  traverse(n.l, sp + 1);
  for (int i = 0; i < sp; ++i) printf("  ");
  printf("[%d] <%d> sz: %d i: %d c: %d\n", n.key, n.rnd, n.sz, n.ind, n.cnt);
  if (n.tag_cost) printf(" -%d", n.tag_cost);
  if (n.tag_cnt) printf(" +%d", n.tag_cnt);
  puts("");
  traverse(n.r, sp + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, i, root = -1;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> shirts[i].c >> shirts[i].q;
  sort(shirts, shirts + n);
  cin >> k;
  for (i = 0; i < k; ++i) {
    cin >> b[i];
    nodes[i].l = nodes[i].r = -1;
    nodes[i].key = b[i];
    nodes[i].ind = i;
    nodes[i].rnd = rand();
    nodes[i].sz = 1;
    auto p = split(root, size(root, b[i]));
    root = merge(merge(p.first, i), p.second);
  }
  for (i = 0; i < n; ++i) {
    int s = size(root, shirts[i].c - 1);
    if (s == nodes[root].sz) continue;
    auto p = split(root, s);
    nodes[p.second].tag_cost += shirts[i].c;
    nodes[p.second].key -= shirts[i].c;
    ++nodes[p.second].tag_cnt;
    ++nodes[p.second].cnt;
    auto q = split(p.second, size(p.second, shirts[i].c - 1));
    root = merge(insert(q.first, p.first), q.second);
  }
  get_ans(root, ans);
  for (i = 0; i < k; ++i) cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}
