#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
mt19937_64 rng(time(0) + 972);
struct node {
  int son[2], val, siz, sum, id, tag, sag;
  unsigned dat;
} t[N];
int rt, sl;
inline int Ads(int val, int id) {
  t[++sl].val = val, t[sl].siz = 1, t[sl].dat = rng(), t[sl].id = id;
  return sl;
}
inline void up(int p) {
  t[p].siz = t[t[p].son[0]].siz + t[t[p].son[1]].siz + 1;
}
inline void opt(int p, int val, int sum) { t[p].tag += val, t[p].sag += sum; }
inline void down(int p) {
  if (t[p].tag || t[p].sag) {
    t[p].val += t[p].tag, t[p].sum += t[p].sag;
    if (t[p].son[0]) opt(t[p].son[0], t[p].tag, t[p].sag);
    if (t[p].son[1]) opt(t[p].son[1], t[p].tag, t[p].sag);
    t[p].tag = t[p].sag = 0;
  }
}
void split(int p, int key, int& x, int& y) {
  if (!p) return x = y = 0, void();
  down(p);
  if (t[p].val <= key)
    x = p, split(t[p].son[1], key, t[p].son[1], y);
  else
    y = p, split(t[p].son[0], key, x, t[p].son[0]);
  up(p);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  down(x), down(y);
  if (t[x].dat > t[y].dat) {
    t[x].son[1] = merge(t[x].son[1], y);
    return up(x), x;
  } else {
    t[y].son[0] = merge(x, t[y].son[0]);
    return up(y), y;
  }
  return -1;
}
void solve(int p) {
  if (!p) return;
  down(p), solve(t[p].son[0]), solve(t[p].son[1]);
}
inline void ins(int val, int id) {
  static int rtx, rty;
  split(rt, val - 1, rtx, rty);
  rt = merge(merge(rtx, Ads(val, id)), rty);
}
void insdfs(int& rt, int p) {
  if (!p) return;
  down(p);
  int rtx, rty;
  insdfs(rt, t[p].son[0]), insdfs(rt, t[p].son[1]);
  t[p].son[0] = t[p].son[1] = 0;
  t[p].siz = 1;
  split(rt, t[p].val, rtx, rty);
  rt = merge(merge(rtx, p), rty);
}
int n, m, c[N], q[N], id[N];
inline bool cmp(int A, int B) {
  return q[A] == q[B] ? c[A] < c[B] : q[A] > q[B];
}
int main() {
  scanf("%d", &n);
  for (register int i = (1); i <= (n); ++i)
    scanf("%d%d", c + i, q + i), id[i] = i;
  scanf("%d", &m);
  for (register int i = (1); i <= (m); ++i) {
    static int x;
    scanf("%d", &x), ins(x, i);
  }
  sort(id + 1, id + n + 1, cmp);
  for (register int i = (1); i <= (n); ++i) {
    int L = c[id[i]] - 1, R = c[id[i]] << 1, rtx, rty, rtz;
    split(rt, L, rtx, rty), split(rty, R, rty, rtz);
    opt(rty, -c[id[i]], 1), opt(rtz, -c[id[i]], 1);
    insdfs(rtx, rty), rt = merge(rtx, rtz);
  }
  solve(rt);
  for (register int i = (1); i <= (m); ++i) id[t[i].id] = t[i].sum;
  for (register int i = (1); i <= (m); ++i)
    printf("%d%c", id[i], " \n"[i == m]);
  return 0;
}
