#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
pair<int, int> s[N];
int ls[N], rs[N], rnd[N], v[N], tagv[N], tagc[N], cnt[N], root, n, m;
void pushdown(int x) {
  int l = ls[x], r = rs[x];
  if (tagc[x]) {
    tagc[l] += tagc[x];
    tagc[r] += tagc[x];
    cnt[l] += tagc[x];
    cnt[r] += tagc[x];
    tagc[x] = 0;
  }
  if (tagv[x]) {
    tagv[l] += tagv[x];
    tagv[r] += tagv[x];
    v[l] -= tagv[x];
    v[r] -= tagv[x];
    tagv[x] = 0;
  }
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int z = 0;
  if (rnd[x] > rnd[y])
    pushdown(y), z = y, ls[z] = merge(x, ls[y]);
  else
    pushdown(x), z = x, rs[z] = merge(rs[x], y);
  return z;
}
void split(int x, int& y, int& z, int k) {
  y = z = 0;
  if (!x) return;
  pushdown(x);
  if (v[x] >= k)
    z = x, split(ls[x], y, ls[z], k);
  else
    y = x, split(rs[x], rs[y], z, k);
}
void insert(int& k, int x) {
  int y, z;
  split(k, y, z, v[x]);
  k = merge(merge(y, x), z);
}
void dfs(int& x, int y) {
  if (!y) return;
  pushdown(y);
  dfs(x, ls[y]);
  dfs(x, rs[y]);
  rs[y] = ls[y] = 0;
  insert(x, y);
}
void down(int x) {
  if (!x) return;
  pushdown(x);
  down(ls[x]);
  down(rs[x]);
}
void DFS(int x) {
  if (!x) return;
  DFS(ls[x]);
  printf("%d\n", v[x]);
  DFS(rs[x]);
}
int main() {
  srand(time(0));
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", &s[i].second, &s[i].first), s[i].first = -s[i].first;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int x;
    scanf("%d", &x);
    rnd[i] = rand();
    v[i] = x;
    insert(root, i);
  }
  sort(s + 1, s + n + 1);
  for (int i = 1; i <= n; ++i) {
    int c = s[i].second;
    int x, y, a, b;
    split(root, x, y, c);
    v[y] -= c;
    tagv[y] += c;
    cnt[y]++;
    tagc[y]++;
    split(y, a, b, c - 1);
    dfs(x, a);
    root = merge(x, b);
  }
  down(root);
  for (int i = 1; i <= m; ++i) printf("%d%c", cnt[i], i == m ? '\n' : ' ');
  return 0;
}
