#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, w = 1;
  char ch = 0;
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') w = -1;
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * w;
}
struct TShirt {
  long long c, p;
  TShirt(long long c = 0, long long p = 0) : c(c), p(p) {}
} tss[200020];
long long v[200020];
struct Node;
typedef Node* ptr_t;
struct Node {
  long long w, rnd, size, tag1, val, tag2, id;
  ptr_t lson, rson;
  Node(long long w, long long id) : w(w), size(1), val(0), id(id) {
    rnd = rand();
    lson = rson = 0;
    tag1 = tag2 = 0;
  }
  int leftSize() { return lson ? lson->size : 0; }
  void pushdown() {
    if (tag1) {
      lson ? lson->tag1 += tag1, lson->w -= tag1 : 0;
      rson ? rson->tag1 += tag1, rson->w -= tag1 : 0;
      tag1 = 0;
    }
    if (tag2) {
      lson ? lson->tag2 += tag2, lson->val += tag2 : 0;
      rson ? rson->tag2 += tag2, rson->val += tag2 : 0;
      tag2 = 0;
    }
  }
  void maintain() {
    size = 1 + (lson ? lson->size : 0) + (rson ? rson->size : 0);
  }
};
void print(ptr_t rt, bool endl = true) {
  if (!rt) return;
  rt->pushdown();
  rt->pushdown();
  rt->pushdown();
  print(rt->lson, false);
  cout << "(" << rt->w << "," << rt->val << "), ";
  print(rt->rson, false);
  if (endl) cout << '\n';
}
void split(ptr_t rt, long long w, ptr_t& l, ptr_t& r) {
  if (rt == 0) return (void)(l = 0, r = 0);
  rt->pushdown();
  if (rt->w <= w) {
    split(rt->rson, w, l, r);
    rt->rson = l;
    rt->maintain();
    if (r) r->maintain();
    l = rt;
  } else {
    split(rt->lson, w, l, r);
    rt->lson = r;
    rt->maintain();
    if (l) l->maintain();
    r = rt;
  }
}
ptr_t merge(ptr_t a, ptr_t b) {
  if (!a || !b) return a ? a : b;
  a->pushdown();
  b->pushdown();
  a->maintain();
  b->maintain();
  if (a->rnd < b->rnd) {
    a->rson = merge(a->rson, b);
    a->maintain();
    return a;
  }
  b->lson = merge(a, b->lson);
  b->maintain();
  return b;
}
void insert(ptr_t& rt, ptr_t node) {
  ptr_t a, b;
  split(rt, node->w, a, b);
  rt = merge(merge(a, node), b);
}
ptr_t root;
void mid(ptr_t rt, ptr_t& insert, long long c) {
  if (!rt) return;
  rt->pushdown();
  mid(rt->lson, insert, c);
  mid(rt->rson, insert, c);
  rt->lson = rt->rson = 0;
  rt->maintain();
  ::insert(insert, rt);
}
long long ans[200020];
void mid2(ptr_t rt) {
  if (!rt) return;
  rt->pushdown();
  ans[rt->id] = rt->val;
  mid2(rt->lson);
  mid2(rt->rson);
}
void addTag(ptr_t rt, long long w, bool tag2) {
  if (rt) {
    if (tag2)
      rt->tag2 += w, rt->val += w;
    else
      rt->tag1 += w, rt->w -= w;
  }
}
int main() {
  long long n = read();
  for (long long i = 1; i <= n; i++) tss[i].c = read(), tss[i].p = read();
  sort(tss + 1, tss + n + 1,
       [](TShirt a, TShirt b) { return a.p == b.p ? a.c < b.c : a.p > b.p; });
  long long m = read();
  for (long long i = 1; i <= m; i++) {
    long long v = read();
    ptr_t node = new Node(v, i);
    insert(root, node);
  }
  for (long long i = 1; i <= n; i++) {
    long long c = tss[i].c;
    ptr_t a, b, d, e;
    split(root, c - 1, a, b);
    split(b, c * 2 - 1, d, e);
    b = d;
    d = e;
    e = 0;
    addTag(b, c, 0);
    addTag(b, 1, 1);
    addTag(d, c, 0);
    addTag(d, 1, 1);
    mid(b, a, c);
    root = merge(a, d);
  }
  mid2(root);
  for (long long i = 1; i <= m; i++) cout << ans[i] << ' ';
}
