#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct node {
  int v;
  int w;
} a[N];
int val[N], ans[N], key[N], sz[N];
int lc[N], rc[N];
int add[N], tag[N];
int cnt = 0, root = 0;
void pushdown(int x) {
  if (!x) return;
  val[lc[x]] += add[x], val[rc[x]] += add[x];
  add[lc[x]] += add[x], add[rc[x]] += add[x];
  add[x] = 0;
  ans[lc[x]] += tag[x], ans[rc[x]] += tag[x];
  tag[lc[x]] += tag[x], tag[rc[x]] += tag[x];
  tag[x] = 0;
}
void dfs(int x) {
  if (!x) return;
  pushdown(x);
  dfs(lc[x]);
  dfs(rc[x]);
}
void pushup(int x) { sz[x] = sz[lc[x]] + sz[rc[x]] + 1; }
int point(int x) {
  cnt++;
  val[cnt] = x;
  sz[cnt] = 1;
  key[cnt] = rand();
  return cnt;
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  pushdown(x);
  pushdown(y);
  if (key[x] < key[y]) {
    lc[y] = merge(x, lc[y]);
    pushup(y);
    return y;
  } else {
    rc[x] = merge(rc[x], y);
    pushup(x);
    return x;
  }
}
void split(int rt, int k, int& x, int& y) {
  if (!rt) {
    x = 0, y = 0;
    return;
  }
  pushdown(rt);
  if (val[rt] <= k) {
    x = rt;
    split(rc[rt], k, rc[rt], y);
    pushup(rt);
  } else {
    y = rt;
    split(lc[rt], k, x, lc[rt]);
    pushup(rt);
  }
}
int insert(int x, int& y) {
  int a, b;
  split(y, val[x], a, b);
  return merge(a, merge(x, b));
}
int hebing(int x, int& y) {
  if (!x) return y;
  pushdown(x);
  hebing(lc[x], y);
  hebing(rc[x], y);
  lc[x] = rc[x] = 0, sz[x] = 1;
  return y = insert(x, y);
}
bool cmp(node a, node b) {
  if (a.w != b.w) return a.w > b.w;
  return a.v < b.v;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].v, &a[i].w);
  sort(a + 1, a + n + 1, cmp);
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, a, b;
    scanf("%d", &x);
    root = insert(point(x), root);
  }
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    split(root, a[i].v - 1, x, y);
    ans[y]++;
    tag[y]++;
    add[y] -= a[i].v;
    val[y] -= a[i].v;
    split(y, a[i].v + a[i].v - 1, y, z);
    root = merge(x, z);
    if (sz[root] < sz[y])
      root = hebing(root, y);
    else
      root = hebing(y, root);
  }
  dfs(root);
  for (int i = 1; i <= m; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
