#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n), b(n);
        for (int i = 0; i < n; i ++) scanf("%d%d", &a[i], &b[i]);
        vector<int> c(n + 1);
        for (int i = 0; i < n + 1; i ++) scanf("%d", &c[i]);
        sort(c.begin(), c.end());
        auto convert = [&](int x) {
                auto d = lower_bound(c.begin(), c.end(), x) - c.begin();
                return d;
        };
        vector<vector<int>> g(n + 1);
        for (int i = 0; i < n; i ++) {
                a[i] = convert(a[i]);
                b[i] = convert(b[i]);
                //cerr << a[i] << ' ' << b[i] << endl;
                if (a[i] > b[i]) { 
                        g[a[i] - 1].push_back(b[i]);
                        //cerr << "g = " << b[i] << ' ' << a[i] << endl;
                }
        }
        vector<int> sum(n + 1, 0);
        for (int i = 0; i < n + 1; i ++) sum[i] --;
        for (int i = 0; i < n; i ++) sum[a[i]] ++;
        vector<int> realsum = sum;

        vector<int> revsum(n + 1, 0);
        for (int i = 0; i < n; i ++) sum[i + 1] += sum[i];
        revsum[n] = sum[n];
        for (int i = n; i > 0; i --) revsum[i - 1] = sum[i - 1] - sum[i];

        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> seg;
        vector<pair<int, int>> used;

        //for (int i = 0; i < n + 1; i ++) cerr << sum[i] << ' '; cerr << endl;

        bool ok = true;
        for (int i = n; i >= 0; i --) {
                if (i < n) revsum[i] += revsum[i + 1];
                for (auto to : g[i]) {
                        seg.emplace(to, i);
                }
                while (revsum[i] < -1 && !seg.empty()) {
                        pair<int, int> get = seg.top();
                        seg.pop();
                        int left = get.first;
                        revsum[i] ++;
                        if (left > 0) revsum[left - 1] --;
                        used.push_back(get);
                }
                if (revsum[i] < -1) {
                        ok = false;
                }
        }
        //for (int i = 0; i < n + 1; i ++) cerr << sum[i] << ' '; cerr << endl;
        vector<vector<int>> rest(n + 1);
        while (!seg.empty()) {
                pair<int, int> get = seg.top();
                seg.pop();
                rest[get.first].push_back(get.second + 1);
                //cerr << "rest " << get.first << ' ' << get.second << endl;
        }

        //cerr << "used" << endl;
        //for (auto it : used) cerr << it.first << ' ' << it.second; cerr << endl;

        //for (int i = 0; i < n + 1; i ++) cerr << realsum[i] << ' '; cerr << endl;
        for (auto it : used) {
                realsum[it.first] ++;
                realsum[it.second + 1] --;
        }
        //for (int i = 0; i < n + 1; i ++) cerr << realsum[i] << ' '; cerr << endl;

        int necessary = (int) used.size();
        //cerr << "necessary = " << necessary << endl;

        priority_queue<pair<int, int>> seg2;
        vector<int> cnt(n + 1);
        for (int i = 0; i < n + 1; i ++) {
                if (i > 0) { 
                        realsum[i] += realsum[i - 1];
                        cnt[i] += cnt[i - 1];
                }
                for (auto to : rest[i]) {
                        seg2.emplace(to, i);
                }
                while (realsum[i] < 0 && !seg2.empty()) {
                        pair<int, int> get = seg2.top();
                        seg2.pop();
                        int right = get.first;
                        //add 1 to [i, right) (virtually)
                        realsum[i] ++;
                        realsum[right] --;
                        cnt[i] ++;
                }
                if (realsum[i] < 0) {
                        cnt[i] = 1 << 30;
                }
        }
        //cerr << "cnt" << endl;
        //for (int i = 0; i < n + 1; i ++) cerr << cnt[i] << ' '; cerr << endl;
        int q;
        scanf("%d", &q);
        while (q --) {
                int d, e;
                scanf("%d%d", &d, &e);
                d = convert(d);
                e = convert(e);
                //cerr << "query = " << d << ' ' << e << endl;
                if (!ok) {
                        printf("%d\n", -1);
                        continue;
                }
                int res1 = (d == 0 ? 0 : cnt[d - 1]);
                int res2 = (e == 0 ? 1 : cnt[e - 1] + 1);
                //cerr << res1 << ' ' << res2 << endl;
                int res = min(res1, res2);
                int ans = n - necessary - res + 1;
                if (ans < 0) printf("%d\n", -1);
                else printf("%d\n", ans);
        }                                      
        return 0;
}


Measured memory_bytes: 15344