#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
inline int read_int() {
  char c;
  int ret = 0, sgn = 1;
  do {
    c = getchar();
  } while ((c < '0' || c > '9') && c != '-');
  if (c == '-')
    sgn = -1;
  else
    ret = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  return sgn * ret;
}
inline long long read_ll() {
  char c;
  long long ret = 0, sgn = 1;
  do {
    c = getchar();
  } while ((c < '0' || c > '9') && c != '-');
  if (c == '-')
    sgn = -1;
  else
    ret = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  return sgn * ret;
}
struct node {
  int ls, rs, Size, Rand, value;
} arr[maxn + 5];
struct Query {
  bool operator<(const Query& rhs) const {
    return q == rhs.q ? c < rhs.c : q > rhs.q;
  }
  int q, c;
} q[maxn + 5];
int tot, root, lazy[maxn + 5], tag[maxn + 5], res[maxn + 5];
int n, k;
inline void Push_Up(int index) {
  arr[index].Size = arr[arr[index].ls].Size + arr[arr[index].rs].Size + 1;
}
inline void Push_Down(int index) {
  if (tag[index]) {
    if (arr[index].ls)
      tag[arr[index].ls] += tag[index], res[arr[index].ls] += tag[index];
    if (arr[index].rs)
      tag[arr[index].rs] += tag[index], res[arr[index].rs] += tag[index];
    tag[index] = 0;
  }
  if (lazy[index]) {
    if (arr[index].ls)
      lazy[arr[index].ls] += lazy[index],
          arr[arr[index].ls].value -= lazy[index];
    if (arr[index].rs)
      lazy[arr[index].rs] += lazy[index],
          arr[arr[index].rs].value -= lazy[index];
    lazy[index] = 0;
  }
}
int Merge(int x, int y) {
  if (!x || !y) return x + y;
  Push_Down(x);
  Push_Down(y);
  if (arr[x].Rand < arr[y].Rand) {
    arr[x].rs = Merge(arr[x].rs, y);
    Push_Up(x);
    return x;
  } else {
    arr[y].ls = Merge(x, arr[y].ls);
    Push_Up(y);
    return y;
  }
}
void Split(int now, int k, int& x, int& y) {
  if (!now) {
    x = y = 0;
    return;
  }
  Push_Down(now);
  if (arr[now].value <= k) {
    x = now;
    Split(arr[now].rs, k, arr[now].rs, y);
  } else {
    y = now;
    Split(arr[now].ls, k, x, arr[now].ls);
  }
  Push_Up(now);
}
inline void Insert(int value) {
  int x = 0, y = 0, now = ++tot;
  Split(root, value, x, y);
  arr[now].value = value, arr[now].Rand = rand(), arr[now].Size = 1;
  root = Merge(x, tot);
  root = Merge(root, y);
}
void DFS_ans(int index) {
  if (!index) return;
  Push_Down(index);
  DFS_ans(arr[index].ls);
  DFS_ans(arr[index].rs);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &q[i].c, &q[i].q);
  sort(q + 1, q + 1 + n);
  scanf("%d", &k);
  for (int i = 1; i <= k; ++i) {
    int v;
    scanf("%d", &v);
    Insert(v);
  }
  for (int i = 1; i <= n; ++i) {
    int x = 0, y = 0, z = 0;
    Split(root, q[i].c - 1, x, y);
    Split(y, q[i].c + q[i].c - 1, y, z);
    lazy[z] += q[i].c;
    arr[z].value -= q[i].c;
    tag[z]++;
    res[z]++;
    queue<int> Q;
    Q.push(y);
    while (!Q.empty()) {
      int t = Q.front();
      Q.pop();
      Push_Down(t);
      if (arr[t].ls) Q.push(arr[t].ls);
      if (arr[t].rs) Q.push(arr[t].rs);
      int a, b;
      Split(x, arr[t].value - q[i].c, a, b);
      arr[t].ls = arr[t].rs = 0;
      arr[t].value -= q[i].c;
      arr[t].Size = 1;
      tag[t] = lazy[t] = 0;
      ++res[t];
      x = Merge(Merge(a, t), b);
    }
    root = Merge(x, z);
  }
  DFS_ans(root);
  for (int i = 1; i <= k; ++i) printf("%d ", res[i]);
  cout << endl;
  return 0;
}
