#include <bits/stdc++.h>
using namespace std;

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;

  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  vector<array<int, 2>> p(n);
  for (int i = 0; i < n; i++) {
    p[i][0] = a[i];
    p[i][1] = b[i];
  }
  sort(p.begin(), p.end());
  vector<array<int, 2>> p2;
  p2.push_back(p[0]);
  for (int i = 1; i < n; i++) {
    if (p[i][1] > p2.back()[1]) {
      p2.push_back(p[i]);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    auto it = upper_bound(p2.begin(), p2.end(), array<int, 2>{x+1, 0});
    if (it == p2.begin()) {
      cout << -1 << '\n';
      continue;
    }
    int o = prev(it) - p2.begin();
    cout << p2[o][1] << '\n';
  }

  return 0;
}