#include <bits/stdc++.h>
using namespace std;
struct zero {
  int cost, pos;
} lib[400005];
int n, k, root = 0, x, y, z;
int ans[400005], tag[400005], tag2[400005];
int ch[400005][2], val[400005], aux[400005];
void push_down(int now) {
  if (tag[now]) {
    val[now] += tag[now];
    if (ch[now][0]) tag[ch[now][0]] += tag[now];
    if (ch[now][1]) tag[ch[now][1]] += tag[now];
    tag[now] = 0;
  }
  if (tag2[now]) {
    ans[now] += tag2[now];
    if (ch[now][0]) tag2[ch[now][0]] += tag2[now];
    if (ch[now][1]) tag2[ch[now][1]] += tag2[now];
    tag2[now] = 0;
  }
}
void split(int now, int k, int &x, int &y) {
  if (!now) {
    x = y = 0;
    return;
  }
  push_down(now);
  if (val[now] <= k)
    x = now, split(ch[now][1], k, ch[now][1], y);
  else
    y = now, split(ch[now][0], k, x, ch[now][0]);
}
int merge(int A, int B) {
  if (!A || !B) return A + B;
  if (aux[A] < aux[B]) {
    ch[A][1] = merge(ch[A][1], B);
    return A;
  } else {
    ch[B][0] = merge(A, ch[B][0]);
    return B;
  }
}
void pushall(int now) {
  push_down(now);
  if (ch[now][0]) pushall(ch[now][0]);
  if (ch[now][1]) pushall(ch[now][1]);
}
void solve(int now) {
  push_down(now);
  if (ch[now][0]) solve(ch[now][0]);
  if (ch[now][1]) solve(ch[now][1]);
  ch[now][0] = ch[now][1] = 0;
  int a, b, c;
  split(root, val[now], a, b);
  root = merge(merge(a, now), b);
}
bool cmp(zero a, zero b) {
  return (a.pos == b.pos) ? a.cost < b.cost : a.pos > b.pos;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &lib[i].cost, &lib[i].pos);
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) scanf("%d", val + i);
  sort(lib + 1, lib + n + 1, cmp);
  for (int i = 1; i <= k; i++) aux[i] = rand() % 1000000009;
  for (int i = 1; i <= k; i++) {
    split(root, val[i], x, y);
    root = merge(merge(x, i), y);
  }
  for (int i = 1; i <= n; i++) {
    split(root, lib[i].cost - 1, root, y);
    if (!y) continue;
    tag[y] -= lib[i].cost, tag2[y]++;
    split(y, lib[i].cost - 1, y, z);
    solve(y);
    root = merge(root, z);
  }
  pushall(root);
  for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
}
