#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long nmax = 200005;
long long n, k, b[nmax], ans[nmax];
pair<long long, long long> arr[nmax];
bool cmp(pair<long long, long long> a1, pair<long long, long long> a2) {
  if (a1.second == a2.second) {
    return a1.first < a2.first;
  } else {
    return a1.second > a2.second;
  }
}
struct item {
  item *l, *r;
  long long val, pr, lazy, cnt, indx, rs;
  item(long long x, long long i) {
    l = r = NULL;
    val = x;
    pr = rng();
    lazy = cnt = rs = 0;
    indx = i;
  }
};
item *treap = NULL;
void _push(item *&aux) {
  if (aux != NULL) {
    if (aux->lazy) {
      aux->val -= aux->lazy;
      aux->rs += aux->cnt;
      if (aux->l != NULL) {
        aux->l->lazy += aux->lazy;
        aux->l->cnt += aux->cnt;
      }
      if (aux->r != NULL) {
        aux->r->lazy += aux->lazy;
        aux->r->cnt += aux->cnt;
      }
      aux->lazy = 0;
      aux->cnt = 0;
    }
  }
}
void _split(item *aux, item *&l, item *&r, long long val) {
  _push(aux);
  if (aux == NULL) {
    l = r = NULL;
  } else {
    if (aux->val <= val) {
      _split(aux->r, aux->r, r, val);
      l = aux;
    } else {
      _split(aux->l, l, aux->l, val);
      r = aux;
    }
  }
}
void _insert(item *&aux, item *el) {
  _push(aux);
  if (aux == NULL) {
    aux = el;
  } else {
    if (aux->pr <= el->pr) {
      _insert((el->val >= aux->val ? aux->r : aux->l), el);
    } else {
      _split(aux, el->l, el->r, el->val);
      aux = el;
    }
  }
}
void _merge(item *&aux, item *l, item *r) {
  _push(l);
  _push(r);
  if (l == NULL) {
    aux = r;
  } else if (r == NULL) {
    aux = l;
  } else {
    if (l->pr < r->pr) {
      _merge(l->r, l->r, r);
      aux = l;
    } else {
      _merge(r->l, l, r->l);
      aux = r;
    }
  }
}
void dfs(item *aux) {
  _push(aux);
  if (aux != NULL) {
    ans[aux->indx] = aux->rs;
    dfs(aux->l);
    dfs(aux->r);
  }
}
item *min_el(item *&aux) {
  _push(aux);
  if (aux->l == NULL) {
    return aux;
  } else {
    return min_el(aux->l);
  }
}
long long max_el(item *&aux) {
  _push(aux);
  if (aux->r == NULL) {
    return aux->val;
  } else {
    return max_el(aux->r);
  }
}
void _erase(item *&aux) {
  _push(aux);
  if (aux->l == NULL) {
    aux = aux->r;
  } else {
    _erase(aux->l);
  }
}
void dfsparcurs(item *&treap) {
  _push(treap);
  if (treap != NULL) {
    dfsparcurs(treap->l);
    cout << treap->val << ' ';
    dfsparcurs(treap->r);
  }
}
int32_t main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i].first >> arr[i].second;
  }
  sort(arr + 1, arr + n + 1, cmp);
  cin >> k;
  for (long long i = 1; i <= k; i++) {
    cin >> b[i];
  }
  for (long long i = 1; i <= k; i++) {
    _insert(treap, new item(b[i], i));
  }
  for (long long i = 1; i <= n; i++) {
    item *l, *r;
    _split(treap, l, r, arr[i].first - 1);
    if (r != NULL) {
      r->lazy += arr[i].first;
      r->cnt++;
    }
    while (r != NULL && l != NULL) {
      item *mini = min_el(r);
      item *tr = new item(mini->val, mini->indx);
      tr->rs = mini->rs;
      long long maxi = max_el(l);
      if (mini->val <= maxi) {
        _erase(r);
        _insert(l, tr);
      } else {
        break;
      }
    }
    _merge(treap, l, r);
  }
  dfs(treap);
  for (long long i = 1; i <= k; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}
