#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -f;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
const int N = 200100;
int m, n;
struct article {
  int p, c;
} seq[N];
bool cmp(article a, article b) {
  if (a.p != b.p)
    return a.p > b.p;
  else
    return a.c < b.c;
}
int cT, root;
struct Treap {
  int lc, rc;
  int val, dat, id;
  int money;
  int tagV, tagM;
} t[N];
int New(int val, int id) {
  cT++;
  t[cT].lc = t[cT].rc = 0;
  t[cT].val = val, t[cT].dat = rand(), t[cT].id = id;
  t[cT].money = 0;
  t[cT].tagV = t[cT].tagM = 0;
  return cT;
}
void spread(int p) {
  int lc = t[p].lc, rc = t[p].rc;
  if (t[p].tagV) {
    if (lc) t[lc].val += t[p].tagV, t[lc].tagV += t[p].tagV;
    if (rc) t[rc].val += t[p].tagV, t[rc].tagV += t[p].tagV;
    t[p].tagV = 0;
  }
  if (t[p].tagM) {
    if (lc) t[lc].money += t[p].tagM, t[lc].tagM += t[p].tagM;
    if (rc) t[rc].money += t[p].tagM, t[rc].tagM += t[p].tagM;
    t[p].tagM = 0;
  }
}
void split_v(int p, int val, int &x, int &y) {
  if (!p)
    x = y = 0;
  else {
    spread(p);
    if (t[p].val <= val)
      x = p, split_v(t[p].rc, val, t[x].rc, y);
    else
      y = p, split_v(t[p].lc, val, x, t[y].lc);
  }
}
int merge(int p, int q) {
  if (!p || !q) return p ^ q;
  spread(p), spread(q);
  if (t[p].dat > t[q].dat) {
    t[p].rc = merge(t[p].rc, q);
    return p;
  } else {
    t[q].lc = merge(p, t[q].lc);
    return q;
  }
}
void insert(int &rt, int p) {
  int X, Z;
  split_v(rt, t[p].val, X, Z);
  rt = merge(X, p), rt = merge(rt, Z);
}
void search(int p, int &rt) {
  if (!p) return;
  spread(p);
  search(t[p].lc, rt), search(t[p].rc, rt);
  t[p].lc = t[p].rc = 0;
  insert(rt, p);
}
int ans[N];
void solve(int p) {
  if (!p) return;
  spread(p);
  solve(t[p].lc), solve(t[p].rc);
  ans[t[p].id] = t[p].money;
}
int main() {
  m = read();
  for (int i = 1; i <= m; i++) seq[i].c = read(), seq[i].p = read();
  sort(seq + 1, seq + 1 + m, cmp);
  n = read();
  for (int i = 1; i <= n; i++) {
    int x = read();
    int p = New(x, i);
    insert(root, p);
  }
  for (int i = 1; i <= m; i++) {
    int c = seq[i].c, p = seq[i].p;
    int X, Y, Z;
    split_v(root, c - 1, X, Y);
    split_v(Y, 2 * c - 1, Y, Z);
    if (Z) {
      t[Z].val -= c, t[Z].tagV -= c;
      t[Z].money++, t[Z].tagM++;
    }
    if (Y) {
      t[Y].val -= c, t[Y].tagV -= c;
      t[Y].money++, t[Y].tagM++;
      search(Y, X);
    }
    root = merge(X, Z);
  }
  solve(root);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
