#include <bits/stdc++.h>
using namespace std;
uint32_t xor32(void) {
  static uint32_t y = 2463534242;
  y = y ^ (y << 13);
  y = y ^ (y >> 17);
  return y = y ^ (y << 5);
}
template <class T>
struct treap {
  struct node {
    T val;
    T lazy;
    bool lazy_flag;
    node *lch, *rch;
    int pri;
    node(const T& v)
        : val(v),
          lazy{},
          lazy_flag(false),
          lch(NULL),
          rch(NULL),
          pri(xor32()) {}
  };
  node* root;
  treap() : root(NULL) {}
  node* update(node* t) { return t; }
  void lazy_push(node* t) {
    if (t && t->lazy_flag) {
      t->val += t->lazy;
      if (t->lch) {
        t->lch->lazy += t->lazy;
        t->lch->lazy_flag = true;
      }
      if (t->rch) {
        t->rch->lazy += t->lazy;
        t->rch->lazy_flag = true;
      }
      t->lazy = {};
      t->lazy_flag = false;
      update(t);
    }
  }
  void insert(const T& val) { root = insert(root, val); }
  node* insert(node* t, const T& val) {
    node *a, *b, *c;
    tie(a, c) = split(t, val);
    b = new node(val);
    return merge(a, merge(b, c));
  }
  node* merge(node* l, node* r) {
    lazy_push(l);
    lazy_push(r);
    if (!l) return r;
    if (!r) return l;
    if (l->pri > r->pri) {
      l->rch = merge(l->rch, r);
      return update(l);
    } else {
      r->lch = merge(l, r->lch);
      return update(r);
    }
  }
  pair<node*, node*> split(node* t, const T& val) {
    lazy_push(t);
    if (!t) return {NULL, NULL};
    node *a, *b;
    if (val <= t->val) {
      tie(a, b) = split(t->lch, val);
      t->lch = b;
      return {a, update(t)};
    } else {
      tie(a, b) = split(t->rch, val);
      t->rch = a;
      return {update(t), b};
    }
  }
  node* insert_nodes(node* a, node* b) {
    lazy_push(b);
    if (!b) return a;
    a = insert_nodes(a, b->lch);
    a = insert_nodes(a, b->rch);
    return insert(a, b->val);
  }
  void add(node* t, const T& val) {
    if (!t) return;
    t->lazy += val;
    t->lazy_flag = true;
    lazy_push(t);
    update(t);
  }
  void query(const T& val) {
    node *a, *b, *c;
    tie(a, b) = split(root, val);
    add(b, -val);
    tie(b, c) = split(b, val);
    a = insert_nodes(a, b);
    root = merge(a, c);
  }
  void dfs(int* ans) { dfs(root, ans); }
  void dfs(node* t, int* ans) {
    if (!t) return;
    lazy_push(t);
    ans[t->val.id] = t->val.cnt;
    dfs(t->lch, ans);
    dfs(t->rch, ans);
  }
};
const int NMAX = 2e5;
int N, K;
int C[NMAX];
int Q[NMAX];
struct customer {
  int id;
  int cnt;
  int money;
  bool operator<=(const customer& rhs) const { return money <= rhs.money; }
  customer& operator+=(const customer& rhs) {
    money += rhs.money;
    cnt += rhs.cnt;
    return *this;
  }
  customer operator-() const {
    customer t = *this;
    t.money *= -1;
    return t;
  }
};
int order[NMAX];
treap<customer> S;
int ans[NMAX];
void dfs(treap<customer>::node* t) {
  if (!t) return;
  dfs(t->lch);
  dfs(t->rch);
  ans[t->val.id] = t->val.cnt;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d %d", &C[i], &Q[i]);
  scanf("%d", &K);
  for (int i = 0; i < K; i++) {
    int b;
    scanf("%d", &b);
    S.insert({i, 0, b});
  }
  iota(order, order + N, 0);
  sort(order, order + N,
       [&](int a, int b) { return Q[a] == Q[b] ? C[a] < C[b] : Q[a] > Q[b]; });
  for (int i = 0; i < N; i++) {
    int price = C[order[i]];
    S.query({0, 1, price});
  }
  S.dfs(ans);
  for (int i = 0; i < K; i++) printf("%d%c", ans[i], " \n"[i == K - 1]);
}
