#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
struct node {
  int l, r, key, fix, sz, down, ans, id, cnt;
  node() {}
  node(int _key, int _id)
      : l(0),
        r(0),
        key(_key),
        fix(rand()),
        sz(1),
        down(0),
        ans(0),
        id(_id),
        cnt(0) {}
} tree[N];
int tcnt, root;
int Newnode(int key, int id) {
  tcnt++;
  tree[tcnt] = node(key, id);
  return tcnt;
}
void Pushup(int x) {
  if (x) {
    tree[x].sz = tree[tree[x].l].sz + tree[tree[x].r].sz + 1;
  }
}
void Pushdown(int x) {
  if (tree[x].down) {
    tree[x].key -= tree[x].down;
    if (tree[x].l) tree[tree[x].l].down += tree[x].down;
    if (tree[x].r) tree[tree[x].r].down += tree[x].down;
    tree[x].down = 0;
  }
  if (tree[x].cnt) {
    tree[x].ans += tree[x].cnt;
    if (tree[x].l) tree[tree[x].l].cnt += tree[x].cnt;
    if (tree[x].r) tree[tree[x].r].cnt += tree[x].cnt;
    tree[x].cnt = 0;
  }
}
int Merge(int x, int y) {
  if (!x) return y;
  if (!y) return x;
  Pushdown(x);
  Pushdown(y);
  if (tree[x].fix < tree[y].fix) {
    tree[x].r = Merge(tree[x].r, y);
    Pushup(x);
    return x;
  } else {
    tree[y].l = Merge(x, tree[y].l);
    Pushup(y);
    return y;
  }
}
void Split(int x, int val, int &l, int &r) {
  if (x == 0) {
    l = 0, r = 0;
    return;
  }
  Pushdown(x);
  if (tree[x].key > val) {
    Split(tree[x].l, val, l, tree[x].l);
    Pushup(x);
    r = x;
  } else {
    Split(tree[x].r, val, tree[x].r, r);
    Pushup(x);
    l = x;
  }
}
void Insert(int &x, int y) {
  int r1, r2;
  Split(x, tree[y].key - 1, r1, r2);
  x = Merge(Merge(r1, y), r2);
}
int Find_max(int x) {
  while (1) {
    Pushdown(x);
    if (!tree[x].r) return tree[x].key;
    x = tree[x].r;
  }
}
void SuperMerge(int &t, int x) {
  if (!x) return;
  Pushdown(x);
  SuperMerge(t, tree[x].l);
  int y = Newnode(tree[x].key, tree[x].id);
  tree[y].ans = tree[x].ans;
  Insert(t, y);
  SuperMerge(t, tree[x].r);
}
void Reduce(int val) {
  int r1, r2, r3, r4;
  Split(root, val - 1, r1, r2);
  tree[r2].down += val;
  tree[r2].cnt++;
  int maxval = Find_max(r1);
  Split(r2, maxval - 1, r3, r4);
  if (tree[r1].sz > tree[r3].sz) {
    SuperMerge(r1, r3);
    root = Merge(r1, r4);
  } else {
    SuperMerge(r3, r1);
    root = Merge(r3, r4);
  }
}
int s[N], top;
pair<int, int> cu[N];
int Build(int n) {
  sort(cu + 1, cu + n + 1);
  top = 0;
  int x = 0, last = 0;
  for (int i = 1; i <= n; i++) {
    last = 0;
    x = Newnode(cu[i].first, cu[i].second);
    while (top > 0 && tree[s[top]].fix > tree[x].fix) {
      Pushup(s[top]);
      last = s[top];
      top--;
    }
    if (top) tree[s[top]].r = x;
    tree[x].l = last;
    s[++top] = i;
  }
  while (top) Pushup(s[top--]);
  return s[1];
}
int ans[N];
void Getans(int x) {
  if (!x) return;
  Pushdown(x);
  Getans(tree[x].l);
  ans[tree[x].id] = tree[x].ans;
  Getans(tree[x].r);
}
struct clothes {
  int q, c;
} shirt[N];
bool cmp(clothes a, clothes b) {
  if (a.q != b.q) return a.q > b.q;
  return a.c < b.c;
}
void Debug() {
  puts("-------");
  printf("root:%d\n", root);
  for (int i = 1; i <= tcnt; i++)
    printf("%d l:%d r:%d key:%d sz:%d ans:%d down:%d cnt:%d\n", i, tree[i].l,
           tree[i].r, tree[i].key, tree[i].sz, tree[i].ans, tree[i].down,
           tree[i].cnt);
  puts("-------");
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &shirt[i].c, &shirt[i].q);
  sort(shirt + 1, shirt + n + 1, cmp);
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &cu[i].first);
    cu[i].second = i;
  }
  root = Build(m);
  for (int i = 1; i <= n; i++) {
    Reduce(shirt[i].c);
  }
  Getans(root);
  for (int i = 1; i <= m; i++) printf("%d ", ans[i]);
}
