#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 200;
int root = 0;
pair<int, int> a[N];
struct node {
  int R, L, lazy, h, val, lazy2, ans;
  node() {
    R = L = -1;
    lazy = lazy2 = 0;
    ans = 0;
  }
} p[N];
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first > b.first;
  }
  return a.second < b.second;
}
void shift(int x) {
  int val = p[x].lazy;
  int val2 = p[x].lazy2;
  p[x].lazy = p[x].lazy2 = 0;
  if (p[x].R != -1) {
    int y = p[x].R;
    p[y].lazy += val;
    p[y].val += val;
    p[y].ans += val2;
    p[y].lazy2 += val2;
  }
  if (p[x].L != -1) {
    int y = p[x].L;
    p[y].lazy += val;
    p[y].val += val;
    p[y].ans += val2;
    p[y].lazy2 += val2;
  }
}
int merge(int x, int y) {
  if (min(x, y) == -1) return max(x, y);
  shift(x);
  shift(y);
  if (p[x].h < p[y].h) {
    p[x].R = merge(p[x].R, y);
    return x;
  }
  p[y].L = merge(x, p[y].L);
  return y;
}
pair<int, int> split(int v, int c) {
  if (v == -1) return make_pair(-1, -1);
  shift(v);
  if (p[v].val > c) {
    pair<int, int> tmp = split(p[v].L, c);
    p[v].L = tmp.second;
    return make_pair(tmp.first, v);
  }
  pair<int, int> tmp = split(p[v].R, c);
  p[v].R = tmp.first;
  return make_pair(v, tmp.second);
}
void add(int x) {
  pair<int, int> tmp = split(root, p[x].val);
  int s = merge(tmp.first, x);
  root = merge(s, tmp.second);
}
void dfs(int v, bool flag = true) {
  if (v == -1) return;
  shift(v);
  dfs(p[v].L, flag);
  dfs(p[v].R, flag);
  if (flag) {
    p[v].L = p[v].R = -1;
    add(v);
  }
}
void query(int x) {
  pair<int, int> tmp = split(root, x - 1);
  int u = tmp.first;
  int v = tmp.second;
  if (v == -1) {
    root = u;
    return;
  }
  p[v].lazy2++;
  p[v].ans++;
  p[v].lazy -= x;
  p[v].val -= x;
  tmp = split(v, x - 1);
  int mid = tmp.first;
  v = tmp.second;
  root = u;
  dfs(mid);
  root = merge(root, v);
}
int32_t main() {
  srand(time(NULL));
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].second >> a[i].first;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i].val;
  }
  sort(a, a + n, cmp);
  for (int i = 0; i < m; i++) {
    p[i].h = rand();
  }
  for (int i = 1; i < m; i++) {
    add(i);
  }
  for (int i = 0; i < n; i++) {
    query(a[i].second);
  }
  dfs(root, false);
  for (int i = 0; i < m; i++) {
    cout << p[i].ans << " ";
  }
  cout << "\n";
  return 0;
}
