#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int neg = 1, num = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - '0';
  return neg * num;
}
struct query {
  int c, w;
} q[200010];
int n, m, cnt, rt, ls[200010], rs[200010], val[200010], key[200010],
    tag[200010], sub[200010], res[200010];
bool cmp(query x, query y) { return x.w ^ y.w ? x.w > y.w : (x.c < y.c); }
inline int New(int w) {
  val[++cnt] = w;
  tag[cnt] = 0;
  key[cnt] = (rand() << 15) + rand();
  return cnt;
}
inline void Push_down(int u) {
  res[ls[u]] += tag[u];
  res[rs[u]] += tag[u];
  tag[ls[u]] += tag[u];
  tag[rs[u]] += tag[u];
  val[ls[u]] -= sub[u];
  val[rs[u]] -= sub[u];
  sub[ls[u]] += sub[u];
  sub[rs[u]] += sub[u];
  tag[u] = sub[u] = 0;
}
inline int Merge(int u, int v) {
  if (!u || !v) return u | v;
  if (key[u] > key[v]) {
    Push_down(u), rs[u] = Merge(rs[u], v);
    return u;
  } else {
    Push_down(v), ls[v] = Merge(u, ls[v]);
    return v;
  }
}
inline void Split(int x, int w, int &u, int &v) {
  if (!x) {
    u = v = 0;
    return;
  }
  Push_down(x);
  if (val[x] <= w)
    u = x, Split(rs[x], w, rs[x], v);
  else
    v = x, Split(ls[x], w, u, ls[x]);
}
inline void Insert(int x) {
  int A, B;
  Split(rt, val[x], A, B);
  rt = Merge(A, Merge(x, B));
}
inline void dfs(int u) {
  Push_down(u);
  if (ls[u]) dfs(ls[u]);
  ls[u] = 0;
  if (rs[u]) dfs(rs[u]);
  rs[u] = 0;
  Insert(u);
}
inline void print(int u) {
  Push_down(u);
  if (ls[u]) print(ls[u]);
  if (rs[u]) print(rs[u]);
}
int main() {
  m = read();
  for (int i = 1; i <= m; i++) q[i].c = read(), q[i].w = read();
  n = read();
  for (int i = 1; i <= n; i++) Insert(New(read()));
  sort(q + 1, q + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int x, y, z, w = q[i].c;
    Split(rt, w - 1, x, y);
    res[y] += 1;
    tag[y] += 1;
    val[y] -= w;
    sub[y] += w;
    Split(y, 2 * w - 1, y, z);
    rt = Merge(x, z);
    dfs(y);
  }
  print(rt);
  for (int i = 1; i <= n; i++) printf("%d ", res[i]);
  return 0;
}
