#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, ls[N], rs[N], key[N], st[N], tp = 0;
long long val[N], ans[N], t1[N], t2[N];
pair<int, int> a[N];
void modify(int x, long long v1, long long v2) {
  val[x] -= v1, ans[x] += v2, t1[x] += v1, t2[x] += v2;
}
void pushdown(int x) {
  if (t1[x] || t2[x]) {
    modify(ls[x], t1[x], t2[x]);
    modify(rs[x], t1[x], t2[x]);
    t1[x] = t2[x] = 0;
  }
}
int merge(int a, int b) {
  if (!a || !b) return a | b;
  if (key[a] < key[b]) {
    pushdown(a);
    rs[a] = merge(rs[a], b);
    return a;
  } else {
    pushdown(b);
    ls[b] = merge(a, ls[b]);
    return b;
  }
}
pair<int, int> split(int x, int v) {
  if (!x) return make_pair(0, 0);
  pair<int, int> y;
  pushdown(x);
  if (val[x] > v) {
    y = split(ls[x], v);
    ls[x] = y.second;
    y.second = x;
  } else {
    y = split(rs[x], v);
    rs[x] = y.first;
    y.first = x;
  }
  return y;
}
void dfs(int x) {
  if (!x) return;
  pushdown(x);
  dfs(ls[x]), dfs(rs[x]);
  st[++tp] = x;
  ls[x] = rs[x] = 0;
}
int main() {
  srand(114514);
  cin >> n;
  for (int i = 1; i <= n; i++) a[i].first = gi(), a[i].second = gi();
  sort(a + 1, a + n + 1, [&](pair<int, int> x, pair<int, int> y) {
    return x.second > y.second || (x.second == y.second && x.first < y.first);
  });
  int k = gi(), rt = 0;
  for (int i = 1; i <= k; i++) {
    key[i] = rand(), val[i] = gi();
    pair<int, int> x = split(rt, val[i]);
    rt = merge(x.first, merge(i, x.second));
  }
  for (int i = 1; i <= n; i++) {
    pair<int, int> x = split(rt, a[i].first - 1);
    modify(x.second, a[i].first, 1);
    pair<int, int> y = split(x.second, a[i].first - 1);
    tp = 0, dfs(y.first);
    for (int j = 1; j <= tp; j++) {
      pair<int, int> z = split(x.first, val[st[j]]);
      x.first = merge(z.first, merge(st[j], z.second));
    }
    rt = merge(x.first, y.second);
  }
  dfs(rt);
  for (int i = 1; i <= k; i++) cout << ans[i] << ' ';
  return 0;
}
