/**
 *    author:  tourist
 *    created: 07.01.2020 01:21:37       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable {
 public:
  int n;
  vector<vector<T>> mat;
  F func;

  SparseTable(const vector<T>& a, const F& f) : func(f) {
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    mat.resize(max_log);
    mat[0] = a;
    for (int j = 1; j < max_log; j++) {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++) {
        mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
      }
    }
  }

  T get(int from, int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 32 - __builtin_clz(to - from + 1) - 1;
    return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};

int main() {
  ios::sync_with_stdio(false);
  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];
    b[i] = min(b[i], a[i]);
  }
  vector<int> c(n + 1);
  for (int i = 0; i < n + 1; i++) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  vector<pair<int, int>> e(2 * n);
  for (int i = 0; i < n; i++) {
    e[i] = make_pair(a[i], i);
    e[i + n] = make_pair(b[i], ~i);
  }
  sort(e.begin(), e.end());
  vector<int> match(n + 1);
  const int inf = (int) 1.01e9;
  multiset<int> s;
  int ptr = 0;
  int fails = 0;
  int value = 0;
  for (int i = 0; i < n + 1; i++) {
    while (ptr < 2 * n && e[ptr].first <= c[i]) {
      int id = e[ptr].second;
      if (id >= 0) {
        auto it = s.find(a[id]);
        if (it != s.end()) {
          s.erase(it);
          s.insert(inf);
        }
      } else {
        id = ~id;
        s.insert(a[id]);
      }
      ++ptr;
    }
    if (s.empty()) {
      match[i] = -1;
      ++fails;
      if (fails > 1) {
        int tt;
        cin >> tt;
        while (tt--) {
          cout << -1 << '\n';
        }
        return 0;
      }
    } else {
      auto it = prev(s.end());
      match[i] = *it;
      value += (match[i] == inf);
      s.erase(it);
    }
  }
  debug(match);
  SparseTable<int> st(match, [&](int i, int j) { return min(i, j); });
  vector<int> res(n + 1, -1);
  {
    int i = n;
    while (match[i] != -1) {
      --i;
    }
    res[i] = value;
    while (i > 0) {
      --i;
      if (match[i] == inf) {
        res[i] = res[i + 1];
      } else {
        int low = i + 1, high = n;
        while (low < high) {
          int mid = (low + high) >> 1;
          if (st.get(i + 1, mid) > match[i]) {
            low = mid + 1;
          } else {
            high = mid;
          }
        }
        int pos = low;
        if (c[pos] >= match[i]) {
          pos = (int) (lower_bound(c.begin(), c.end(), match[i]) - c.begin());
          res[i] = res[pos] + 1;
        } else {
          res[i] = res[pos];
        }
      }
    }
  }
  debug(res);
  int tt;
  cin >> tt;
  while (tt--) {
    int x, y;
    cin >> x >> y;
    y = min(y, x);
    int pos = (int) (lower_bound(c.begin(), c.end(), y) - c.begin());
    int low = pos, high = n + 1;
    while (low < high) {
      int mid = (low + high) >> 1;
      if (st.get(pos, mid) > x) {
        low = mid + 1;
      } else {
        high = mid;
      }
    }
    if (low == n + 1) {
      cout << -1 << '\n';
      continue;
    }
    int ans;
    if (c[low] >= x) {
      pos = (int) (lower_bound(c.begin(), c.end(), x) - c.begin());
      ans = (res[pos] == -1 ? -1 : res[pos] + 1);
    } else {
      ans = res[low];
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 10624