#include <bits/stdc++.h>
using namespace std;
const int N = 201 * 1001;
struct node {
  int l, r, h, b, lazyb, lazya, ans;
} p[N];
inline void add(int id, int x, int y) {
  p[id].b += x;
  p[id].lazyb += x;
  p[id].ans += y;
  p[id].lazya += y;
}
inline void shift(int x) {
  int l = p[x].l, r = p[x].r;
  if (r != -1) add(r, p[x].lazyb, p[x].lazya);
  if (l != -1) add(l, p[x].lazyb, p[x].lazya);
  p[x].lazyb = 0;
  p[x].lazya = 0;
}
pair<int, int> split(int root, int x) {
  if (root == -1) return {-1, -1};
  shift(root);
  if (p[root].b >= x) {
    pair<int, int> tmp = split(p[root].l, x);
    p[root].l = tmp.second;
    return {tmp.first, root};
  }
  pair<int, int> tmp = split(p[root].r, x);
  p[root].r = tmp.first;
  return {root, tmp.second};
}
int merge(int x, int y) {
  if (min(x, y) == -1) return max(x, y);
  if (p[x].h < p[y].h) {
    shift(x);
    p[x].r = merge(p[x].r, y);
    return x;
  }
  shift(y);
  p[y].l = merge(x, p[y].l);
  return y;
}
inline int insert(int root, int x) {
  if (root == -1) return x;
  pair<int, int> pp = split(root, p[x].b);
  int v = pp.first, u = pp.second;
  v = merge(v, x);
  root = merge(v, u);
  return root;
}
pair<int, int> a[N];
int b[N];
vector<int> seen;
void dfs(int u) {
  if (u == -1) return;
  seen.push_back(u);
  shift(u);
  dfs(p[u].l);
  dfs(p[u].r);
}
int32_t main() {
  srand(time(NULL));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].second, &a[i].first);
    a[i].first *= -1;
  }
  iota(b, b + n, 0);
  random_shuffle(b, b + n);
  sort(a, a + n);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    p[i].l = p[i].r = -1;
    p[i].lazya = p[i].lazyb = p[i].ans = 0;
    p[i].h = b[i];
    scanf("%d", &p[i].b);
  }
  int root = 0;
  for (int i = 1; i < q; i++) root = insert(root, i);
  for (int i = 0; i < n; i++) {
    int val = a[i].second;
    pair<int, int> pp = split(root, val);
    int v = pp.first, u = pp.second, w;
    if (u == -1) continue;
    pp = split(u, 2 * val);
    u = pp.first, w = pp.second;
    seen.clear();
    if (w != -1) add(w, -val, 1);
    dfs(u);
    for (auto u : seen) {
      p[u].b -= val;
      p[u].ans++;
      p[u].l = p[u].r = -1;
      v = insert(v, u);
    }
    root = merge(v, w);
  }
  dfs(root);
  for (int i = 0; i < q; i++) printf("%d ", p[i].ans);
  printf("\n");
}
