#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
struct Record {
  int c, q;
} rec[MAXN];
struct Query {
  int idx, value;
} qry[MAXN];
template <typename T>
struct Persistent_Treap {
  inline static int ran() {
    static int ret = 1237;
    return ret = ret * 12371237 & 0x7fffffff;
  }
  struct Node {
    int siz, idx;
    T value, maxv, ans;
    pair<T, T> lazy;
    Node* child[2];
    inline bool cmp(Node* x) const { return ran() % (siz + x->siz) < siz; }
    inline int size(int dir) const { return child[dir] ? child[dir]->siz : 0; }
    inline void maintain() {
      siz = 1;
      maxv = value;
      for (int i = 0; i < 2; i++)
        if (child[i]) {
          siz += child[i]->siz;
          maxv = max(maxv, child[i]->maxv);
        }
    }
    inline void update(pair<T, T> v) {
      value += v.first;
      maxv += v.first;
      ans += v.second;
      lazy.first += v.first;
      lazy.second += v.second;
    }
    inline void push_down() {
      if (lazy.first || lazy.second) {
        if (child[0]) child[0]->update(lazy);
        if (child[1]) child[1]->update(lazy);
        lazy.first = lazy.second = 0;
      }
    }
  };
  Node *root, pool[MAXN], *alloc;
  Node* new_Node(T value = 0) {
    Node* ret = alloc++;
    ret->siz = 1;
    ret->value = ret->maxv = value;
    ret->ans = ret->lazy.first = ret->lazy.second = 0;
    ret->child[0] = ret->child[1] = NULL;
    return ret;
  }
  void init() {
    alloc = pool;
    root = NULL;
  }
  void build(int left, int right, Query* qry, Node*& curr) {
    if (left == right) return;
    int mid = (left + right) / 2;
    curr = new_Node(qry[mid].value);
    curr->idx = qry[mid].idx;
    build(left, mid, qry, curr->child[0]);
    build(mid + 1, right, qry, curr->child[1]);
    curr->maintain();
  }
  Node* merge(Node* left, Node* right) {
    if (left == NULL) return right;
    if (right == NULL) return left;
    left->push_down(), right->push_down();
    if (left->cmp(right)) {
      left->child[1] = merge(left->child[1], right);
      left->maintain();
      return left;
    } else {
      right->child[0] = merge(left, right->child[0]);
      right->maintain();
      return right;
    }
  }
  void split(Node* curr, int k, Node*& left, Node*& right) {
    if (curr == NULL) {
      left = right = NULL;
      return;
    }
    curr->push_down();
    if (curr->size(0) >= k) {
      right = curr;
      split(curr->child[0], k, left, curr->child[0]);
    } else {
      left = curr;
      split(curr->child[1], k - curr->size(0) - 1, curr->child[1], right);
    }
    curr->maintain();
  }
  int rank(T value, Node* curr) {
    if (curr == NULL) return 0;
    curr->push_down();
    if (value <= curr->value)
      return rank(value, curr->child[0]);
    else
      return curr->size(0) + 1 + rank(value, curr->child[1]);
  }
  void insert(Node* mid, Node*& curr) {
    Node *left, *right;
    split(curr, rank(mid->value, curr), left, right);
    curr = merge(merge(left, mid), right);
  }
  void recycle(Node* curr, Node*& bin) {
    if (curr == NULL) return;
    curr->push_down();
    recycle(curr->child[0], bin);
    recycle(curr->child[1], bin);
    curr->child[0] = curr->child[1] = NULL;
    insert(curr, bin);
  }
  void modify(T value) {
    Node *left, *mid, *right, *temp;
    split(root, rank(value, root), left, temp);
    if (temp == NULL) {
      root = left;
      return;
    }
    temp->update(make_pair(-value, 1));
    if (left == NULL) {
      root = temp;
      return;
    }
    split(temp, rank(left->maxv, temp), mid, right);
    recycle(mid, left);
    root = merge(left, right);
  }
  void get_ans(T* ans, Node* curr) {
    if (curr == NULL) return;
    curr->push_down();
    ans[curr->idx] = curr->ans;
    get_ans(ans, curr->child[0]);
    get_ans(ans, curr->child[1]);
  }
  void debug(int d, Node* curr) {
    if (curr == NULL) return;
    curr->push_down();
    debug(d + 1, curr->child[0]);
    for (int i = 0; i < d; i++) printf("  ");
    printf("%d: %d %d\n", curr->idx, curr->value, curr->ans);
    debug(d + 1, curr->child[1]);
  }
};
int n, m;
Persistent_Treap<int> tree;
int ans[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &rec[i].c, &rec[i].q);
  scanf("%d", &m);
  sort(rec + 1, rec + n + 1, [](const Record& a, const Record& b) -> bool {
    if (a.q != b.q)
      return a.q > b.q;
    else
      return a.c < b.c;
  });
  for (int i = 1; i <= m; i++) {
    scanf("%d", &qry[i].value);
    qry[i].idx = i;
  }
  sort(qry + 1, qry + m + 1, [](const Query& a, const Query& b) -> bool {
    return a.value < b.value;
  });
  tree.init();
  tree.build(1, m + 1, qry, tree.root);
  for (int i = 1; i <= n; i++) {
    tree.modify(rec[i].c);
  }
  tree.get_ans(ans, tree.root);
  for (int i = 1; i <= m; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
