#include <bits/stdc++.h>
using namespace std;
struct node {
 public:
  int key, y, secondaryKey;
  int size;
  int ansrez;
  int lazykey, lazyrez;
  node *L, *R;
  node(int k, int sk) {
    key = k;
    secondaryKey = sk;
    L = R = NULL;
    size = 1;
    y = rand();
    ansrez = 0;
    lazykey = lazyrez = 0;
  }
  node *&left() {
    propagate();
    return L;
  }
  node *&right() {
    propagate();
    return R;
  }

 private:
  void propagate() {
    if (lazykey != 0) {
      if (L) {
        L->key += lazykey;
        L->lazykey += lazykey;
      }
      if (R) {
        R->key += lazykey;
        R->lazykey += lazykey;
      }
      lazykey = 0;
    }
    if (lazyrez != 0) {
      if (L) {
        L->ansrez += lazyrez;
        L->lazyrez += lazyrez;
      }
      if (R) {
        R->ansrez += lazyrez;
        R->lazyrez += lazyrez;
      }
      lazyrez = 0;
    }
  }
};
inline bool isSmaller(int key, int sk, node *n) {
  if (key < n->key) return true;
  if (key > n->key) return false;
  return (sk < n->secondaryKey);
}
inline int size(node *p) { return p ? p->size : 0; }
void recalc(node *p) {
  if (!p) return;
  p->size = size(p->left()) + size(p->right()) + 1;
}
void tsplit(node *root, int k, node **l, node **r, int sk) {
  if (root == NULL) {
    *l = NULL;
    *r = NULL;
    return;
  }
  if (isSmaller(k, sk, root)) {
    tsplit(root->left(), k, l, &root->left(), sk);
    *r = root;
    recalc(root);
  } else {
    tsplit(root->right(), k, &root->right(), r, sk);
    *l = root;
    recalc(root);
  }
}
node *tmerge(node *l, node *r) {
  if (l == NULL) return r;
  if (r == NULL) return l;
  if (l->y < r->y) {
    r->left() = tmerge(l, r->left());
    recalc(r);
    return r;
  } else {
    l->right() = tmerge(l->right(), r);
    recalc(l);
    return l;
  }
}
node *tadd(node *root, node *n) {
  if (root == NULL) return n;
  if (n->y > root->y) {
    node *r, *l;
    tsplit(root, n->key, &l, &r, n->secondaryKey);
    n->left() = l;
    n->right() = r;
    recalc(n);
    return n;
  }
  if (isSmaller(n->key, n->secondaryKey, root))
    root->left() = tadd(root->left(), n);
  else
    root->right() = tadd(root->right(), n);
  recalc(root);
  return root;
}
node *tremove(node *root, int k, int sk) {
  if (root == NULL) return root;
  if (root->key == k && root->secondaryKey == sk) {
    root = tmerge(root->left(), root->right());
    return root;
  }
  if (isSmaller(k, sk, root))
    root->left() = tremove(root->left(), k, sk);
  else
    root->right() = tremove(root->right(), k, sk);
  recalc(root);
  return root;
}
node *tkthelement(node *root, int k) {
  if (root == NULL) return NULL;
  if (size(root->left()) == k - 1) return root;
  if (size(root->left()) >= k) return tkthelement(root->left(), k);
  return tkthelement(root->right(), k - size(root->left()) - 1);
}
pair<int, int> v[200010];
int qres[200010];
bool compareShirts(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first != p2.first) return p1.first > p2.first;
  return p1.second < p2.second;
}
void fillResults(node *root) {
  if (root == NULL) return;
  qres[root->secondaryKey] = root->ansrez;
  fillResults(root->left());
  fillResults(root->right());
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d%d", &v[i].second, &v[i].first);
  int Q;
  scanf("%d", &Q);
  node *T = NULL;
  for (int i = 0; i < Q; ++i) {
    int a;
    scanf("%d", &a);
    T = tadd(T, new node(a, i));
  }
  sort(v, v + N, compareShirts);
  for (int i = 0; i < N; ++i) {
    int ai = v[i].second;
    node *B, *A;
    tsplit(T, ai, &B, &A, -1);
    if (A == NULL) {
      T = tmerge(B, A);
      continue;
    }
    A->ansrez += 1;
    A->lazyrez += 1;
    A->lazykey -= ai;
    A->key -= ai;
    if (B == NULL) {
      T = tmerge(B, A);
      continue;
    }
    node *bmax = tkthelement(B, size(B));
    while (size(A) > 0) {
      node *amin = tkthelement(A, 1);
      if (!isSmaller(amin->key, amin->secondaryKey, bmax)) break;
      A = tremove(A, amin->key, amin->secondaryKey);
      amin->left() = amin->right() = NULL;
      recalc(amin);
      B = tadd(B, amin);
    }
    T = tmerge(B, A);
  }
  fillResults(T);
  for (int i = 0; i < Q; ++i) printf("%d ", qres[i]);
  return 0;
}
