#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const int M = 2e5 + 7;
struct node {
  int c, q;
} a[M];
int cmp(node x, node y) { return x.q == y.q ? x.c < y.c : x.q > y.q; }
inline int read() {
  char c = getchar();
  int s = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    s = s * 10 + c - '0';
    c = getchar();
  }
  return s;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
int n, m, p[M], rt, rt1, rt2, rt3, rt4, cnt;
struct fhq {
  int add[M], js[M], val[M], num[M], ch[M][2], key[M], p[M];
  inline void pushdown(register int u) {
    if (!add[u]) return;
    if (ch[u][0]) {
      add[ch[u][0]] += add[u];
      js[ch[u][0]] += js[u];
      val[ch[u][0]] -= add[u];
      num[ch[u][0]] += js[u];
    }
    if (ch[u][1]) {
      add[ch[u][1]] += add[u];
      js[ch[u][1]] += js[u];
      val[ch[u][1]] -= add[u];
      num[ch[u][1]] += js[u];
    }
    add[u] = js[u] = 0;
  }
  inline void split(register int u, register int v, register int &l,
                    register int &r) {
    if (!u) {
      l = r = 0;
      return;
    }
    pushdown(u);
    if (val[u] < v) {
      l = u;
      split(ch[u][1], v, ch[u][1], r);
    } else {
      r = u;
      split(ch[u][0], v, l, ch[u][0]);
    }
  }
  inline int merge(register int l, register int r) {
    if (!l or !r) return l | r;
    pushdown(l);
    pushdown(r);
    if (key[l] <= key[r]) {
      ch[l][1] = merge(ch[l][1], r);
      return l;
    } else {
      ch[r][0] = merge(l, ch[r][0]);
      return r;
    }
  }
  inline void insert(register int u) {
    val[++cnt] = u;
    key[cnt] = rand();
  }
  inline void jia(register int l) {
    int x, y;
    split(rt1, val[l], x, y);
    rt1 = merge(x, merge(l, y));
  }
  inline void dfs1(register int u) {
    if (!u) return;
    pushdown(u);
    dfs1(ch[u][0]);
    dfs1(ch[u][1]);
    ch[u][0] = ch[u][1] = 0;
    jia(u);
  }
  inline void dfs2(register int u) {
    if (!u) return;
    pushdown(u);
    dfs2(ch[u][0]);
    dfs2(ch[u][1]);
  }
  inline void slove() {
    for (int i = 1; i <= m; i++) {
      p[i] = read();
      insert(p[i]);
      split(rt, p[i], rt1, rt2);
      rt = merge(merge(rt1, cnt), rt2);
    }
    for (register int i = 1; i <= n; i++) {
      rt1 = rt2 = rt4 = rt3 = 0;
      split(rt, a[i].c, rt1, rt2);
      if (rt2) split(rt2, a[i].c * 2, rt4, rt3);
      rt2 = rt4;
      if (rt2) {
        val[rt2] -= a[i].c;
        add[rt2] += a[i].c;
        js[rt2]++;
        num[rt2]++;
      }
      if (rt3) {
        val[rt3] -= a[i].c;
        add[rt3] += a[i].c;
        js[rt3]++;
        num[rt3]++;
      }
      if (rt2) dfs1(rt2);
      rt = merge(rt1, rt3);
    }
    dfs2(rt);
    for (int i = 1; i <= m; i++) print(num[i]), putchar(' ');
  }
} hh;
int main() {
  n = read();
  srand(time(0));
  for (int i = 1; i <= n; i++) {
    a[i].c = read();
    a[i].q = read();
  }
  sort(a + 1, a + n + 1, cmp);
  m = read();
  hh.slove();
  return 0;
}
