#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9;
inline int rd() {
  int x = 0;
  char c = getchar();
  bool f = false;
  while (!isdigit(c)) {
    if (c == '-') f = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int sqr(int x) { return x * x; }
int n, m, root;
int lson[200005], rson[200005], val[200005], rnd[200005];
int cnt[200005], add[200005], ans[200005];
void pushdown(int v) {
  if (add[v]) {
    add[lson[v]] += add[v];
    add[rson[v]] += add[v];
    val[lson[v]] += add[v];
    val[rson[v]] += add[v];
    add[v] = 0;
  }
  if (ans[v]) {
    ans[lson[v]] += ans[v];
    ans[rson[v]] += ans[v];
    cnt[lson[v]] += ans[v];
    cnt[rson[v]] += ans[v];
    ans[v] = 0;
  }
}
void split(int k, int &x, int &y, int v) {
  if (!k) {
    x = y = 0;
    return;
  }
  pushdown(k);
  if (val[k] < v) {
    x = k;
    split(rson[k], rson[x], y, v);
  } else {
    y = k;
    split(lson[k], x, lson[y], v);
  }
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  if (rnd[x] < rnd[y]) {
    pushdown(x);
    rson[x] = merge(rson[x], y);
    return x;
  } else {
    pushdown(y);
    lson[y] = merge(x, lson[y]);
    return y;
  }
}
int ins(int x, int y) {
  int r1 = 0, r2 = 0;
  split(x, r1, r2, val[y]);
  x = merge(merge(r1, y), r2);
  return x;
}
int build(int v, int y) {
  if (!v) return y;
  pushdown(v);
  y = build(lson[v], y);
  y = build(rson[v], y);
  lson[v] = rson[v] = 0;
  return ins(y, v);
}
void dfs(int v) {
  if (!v) return;
  pushdown(v);
  dfs(lson[v]);
  dfs(rson[v]);
}
pair<int, int> a[200005];
int main() {
  n = rd();
  int c, q;
  for (int i = 1; i <= n; i++) {
    c = rd();
    q = rd();
    a[i] = make_pair(-q, c);
  }
  sort(a + 1, a + 1 + n);
  m = rd();
  for (int i = 1; i <= m; i++) {
    val[i] = rd();
    rnd[i] = rand();
    root = ins(root, i);
  }
  for (int i = 1; i <= n; i++) {
    int c = a[i].second;
    int r1 = 0, r2 = 0, r3 = 0, r4 = 0;
    split(root, r1, r2, c);
    val[r2] -= c;
    add[r2] -= c;
    cnt[r2]++;
    ans[r2]++;
    split(r2, r3, r4, c - 1);
    r1 = build(r3, r1);
    root = merge(r1, r4);
  }
  dfs(root);
  for (int i = 1; i <= m; i++) printf("%d ", cnt[i]);
  return 0;
}
