#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long fact(long long n) {
  long long ret = 1;
  for (int i = 1; i <= n; i++) ret *= i;
  return ret;
}
bool is_vowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
    return 1;
  return 0;
}
long double getDistance(long double x1, long double y1, long double x2,
                        long double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
long long power(long long base, long long p) {
  if (p == 1) return base;
  if (!p) return 1ll;
  long long ret = power(base, p / 2);
  ret *= ret;
  ret %= 1000000007ll;
  if (p & 1) ret *= base;
  return ret % 1000000007ll;
}
const int MAXN = 200000;
const int NEUTRAL_VALUE = INT_MIN;
const int NEUTRAL_DELTA = 0;
int joinValues(int leftValue, int rightValue) {
  return max(leftValue, rightValue);
}
int joinDeltas(int oldDelta, int newDelta) { return oldDelta + newDelta; }
int joinValueWithDelta(int value, int delta, int length) {
  return value + delta;
}
struct treap {
  int nodeValue;
  int subTreeValue;
  int delta;
  int delta2;
  int count;
  int prio;
  int arrayidx;
  int tshirts;
  treap *l;
  treap *r;
};
treap nodes[MAXN];
int nodes_cnt;
vector<int> rnd;
static int getCount(treap *root) { return root ? root->count : 0; }
static int getSubTreeValue(treap *root) {
  return root ? root->subTreeValue : NEUTRAL_VALUE;
}
void update(treap *root) {
  if (!root) return;
  root->count = 1 + getCount(root->l) + getCount(root->r);
}
void applyDelta(treap *root, int delta, int delta2) {
  if (!root) return;
  root->delta = joinDeltas(root->delta, delta);
  root->nodeValue = joinValueWithDelta(root->nodeValue, delta, 1);
  root->delta2 = joinDeltas(root->delta2, delta2);
  root->tshirts = joinValueWithDelta(root->tshirts, delta2, 1);
}
void pushDelta(treap *root) {
  if (!root) return;
  applyDelta(root->l, root->delta, root->delta2);
  applyDelta(root->r, root->delta, root->delta2);
  root->delta = NEUTRAL_DELTA;
  root->delta2 = NEUTRAL_DELTA;
}
void merge(treap *&t, treap *l, treap *r) {
  pushDelta(l);
  pushDelta(r);
  if (!l)
    t = r;
  else if (!r)
    t = l;
  else if (l->prio < r->prio)
    merge(l->r, l->r, r), t = l;
  else
    merge(r->l, l, r->l), t = r;
  update(t);
}
void split(treap *t, treap *&l, treap *&r, int key) {
  pushDelta(t);
  if (!t)
    l = r = NULL;
  else if (key < t->nodeValue)
    split(t->l, l, t->l, key), r = t;
  else
    split(t->r, t->r, r, key), l = t;
  update(t);
}
int get(treap *t, int index) {
  pushDelta(t);
  if (index < getCount(t->l))
    return get(t->l, index);
  else if (index > getCount(t->l))
    return get(t->r, index - getCount(t->l) - 1);
  return t->nodeValue;
}
void insert(treap *&t, treap *item, int index) {
  pushDelta(t);
  if (!t)
    t = item;
  else if (item->prio < t->prio)
    split(t, item->l, item->r, index), t = item;
  else if (index < t->nodeValue)
    insert(t->l, item, index);
  else
    insert(t->r, item, index);
  update(t);
}
void insert(treap *&root, int index, int value, int arrayidx) {
  treap *item = &nodes[nodes_cnt];
  item->nodeValue = value;
  item->subTreeValue = value;
  item->delta = NEUTRAL_DELTA;
  item->delta2 = NEUTRAL_DELTA;
  item->count = 1;
  item->prio = rnd[nodes_cnt];
  item->arrayidx = arrayidx;
  item->tshirts = 0;
  ++nodes_cnt;
  insert(root, item, value);
}
void remove(treap *&t, treap *&p, int index) {
  pushDelta(t);
  if (index == getCount(t->l)) {
    p = t;
    merge(t, t->l, t->r);
  } else if (index < getCount(t->l))
    remove(t->l, p, index);
  else
    remove(t->r, p, index - getCount(t->l) - 1);
  update(t);
}
int query(treap *&root, int a, int b) {
  treap *l1, *r1;
  split(root, l1, r1, b + 1);
  treap *l2, *r2;
  split(l1, l2, r2, a);
  int res = getSubTreeValue(r2);
  treap *t;
  merge(t, l2, r2);
  merge(root, t, r1);
  return res;
}
void modify(treap *&root, int a, int b, int delta, int delta2) {
  applyDelta(root, delta, delta2);
}
int sol[MAXN];
void print(treap *t) {
  if (!t) return;
  pushDelta(t);
  print(t->l);
  sol[t->arrayidx] = t->tshirts;
  print(t->r);
}
int main() {
  for (int i = 0; i < MAXN; i++) rnd.push_back(rand());
  treap *t = NULL;
  int m;
  scanf("%d", &m);
  vector<pair<int, int> > v(m);
  for (int i = (0); i <= (m - 1); ++i) {
    scanf("%d", &v[i].second);
    v[i].second *= -1;
    scanf("%d", &v[i].first);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > a(n);
  for (int i = (0); i <= (n - 1); ++i) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  for (int i = (0); i <= (n - 1); ++i) {
    insert(t, i, a[i].first, a[i].second);
  }
  for (int i = (0); i <= (m - 1); ++i) {
    int cost = -v[i].second;
    treap *l, *r;
    split(t, l, r, cost - 1);
    if (r) modify(r, 0, r->count - 1, -cost, 1);
    while (r && l) {
      if (get(l, l->count - 1) > get(r, 0)) {
        treap *removed;
        remove(r, removed, 0);
        removed->l = removed->r = NULL;
        update(removed);
        treap *l1, *r1;
        split(l, l1, r1, removed->nodeValue);
        insert(l1, removed, removed->nodeValue);
        merge(l, l1, r1);
      } else
        break;
    }
    merge(t, l, r);
  }
  print(t);
  for (int i = (0); i <= (n - 1); ++i) cout << sol[i] << ' ';
}
