#include <bits/stdc++.h>
#pragma warning(disable : 4996)
template <typename T>
T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T max(T x, T y) {
  return x > y ? x : y;
};
const long long MAXN = 1000005;
const long long INF = 2000000005;
struct tree {
  long long id;
  long long w;
  long long cnt;
  long long tag;
  long long add;
  long long size;
  tree *lson;
  tree *rson;
  tree(long long W, long long ID, long long CNT) {
    w = W;
    id = ID;
    cnt = CNT;
    tag = add = 0;
    size = 1;
    lson = rson = NULL;
  }
  void addcnt(long long k) {
    cnt += k;
    tag += k;
  }
  void addw(long long k) {
    w += k;
    add += k;
  }
  void pushdown() {
    if (tag) {
      if (lson) lson->addcnt(tag);
      if (rson) rson->addcnt(tag);
      tag = 0;
    }
    if (add) {
      if (lson) lson->addw(add);
      if (rson) rson->addw(add);
      add = 0;
    }
  }
  void fixup() { size = (lson ? lson->size : 0) + (rson ? rson->size : 0) + 1; }
};
struct pair {
  tree *fir;
  tree *sec;
  pair(tree *F = NULL, tree *S = NULL) {
    fir = F;
    sec = S;
  }
};
long long RAND;
bool shouldleft(long long a, long long b) {
  RAND = (RAND * 10007 + 13) % 998244353;
  return RAND % (a + b) < a;
}
tree *merge(tree *T1, tree *T2) {
  if (!T1) return T2;
  if (!T2) return T1;
  if (shouldleft(T1->size, T2->size)) {
    T1->pushdown();
    T1->rson = merge(T1->rson, T2);
    T1->fixup();
    return T1;
  }
  T2->pushdown();
  T2->lson = merge(T1, T2->lson);
  T2->fixup();
  return T2;
}
pair split(tree *T, long long k) {
  if (!T) return pair();
  T->pushdown();
  if (T->w <= k) {
    pair t = split(T->rson, k);
    T->rson = t.fir;
    T->fixup();
    return pair(T, t.sec);
  }
  pair t = split(T->lson, k);
  T->lson = t.sec;
  T->fixup();
  return pair(t.fir, T);
}
void insert(tree *&T, long long w, long long id, long long cnt) {
  pair t = split(T, w);
  T = merge(t.fir, merge(new tree(w, id, cnt), t.sec));
}
void join(tree *T1, tree *&T2) {
  if (!T1) return;
  insert(T2, T1->w, T1->id, T1->cnt);
  T1->pushdown();
  join(T1->lson, T2);
  join(T1->rson, T2);
}
tree *minimum(tree *T) {
  while (T->lson) {
    T->pushdown();
    T = T->lson;
  }
  return T;
}
tree *maximum(tree *T) {
  while (T->rson) {
    T->pushdown();
    T = T->rson;
  }
  return T;
}
struct obj {
  long long w;
  long long p;
  bool operator<(obj t) const {
    if (w != t.w) return w > t.w;
    return p < t.p;
  }
};
long long N, K;
obj a[MAXN];
tree *T;
long long ans[MAXN];
void init() {
  scanf("%I64d", &N);
  for (long long i = 1; i <= N; i++) scanf("%I64d %I64d", &a[i].p, &a[i].w);
  std::sort(a + 1, a + N + 1);
  long long t;
  scanf("%I64d", &K);
  for (long long i = 1; i <= K; i++) {
    scanf("%I64d", &t);
    insert(T, t, i, 0);
  }
}
void solve() {
  for (long long i = 1; i <= N; i++) {
    pair t = split(T, a[i].p - 1);
    if (t.sec) {
      t.sec->addcnt(1);
      t.sec->addw(-a[i].p);
      while (t.fir && t.sec && minimum(t.sec)->w < maximum(t.fir)->w) {
        pair t2 = split(t.sec, minimum(t.sec)->w);
        t.sec = t2.sec;
        join(t2.fir, t.fir);
      }
      T = merge(t.fir, t.sec);
    } else
      T = t.fir;
  }
  while (T) {
    ans[T->id] = T->cnt;
    T->pushdown();
    T = merge(T->lson, T->rson);
  }
  for (long long i = 1; i <= K; i++) printf("%I64d ", ans[i]);
}
int main() {
  init();
  solve();
  return 0;
}
