#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
int q;
vector<int> vv;
const int MAXN = 120000;
const int INF = 1e9;
int a[MAXN];
pair<int, int> tmp[MAXN];
int add;
int ad[MAXN];
int n;

void no() {
	for (int i = 0; i < q; ++i) {
		cout << -1 << "\n";
	}
	exit(0);
}

multiset<int> ss;

int fnd(int x) {
	return lower_bound(vv.begin(), vv.end(), x) - vv.begin();
}
int fn;
pair<int, int> rmq[MAXN * 4];
int dd[MAXN * 4];
int ans[MAXN];

int get(int x) {
	if (x >= fn)
		return -INF;
	return ans[x + 1];
}

void build(int v, int tl, int tr) {
	dd[v] = 0;
	if (tl + 1 == tr) {
		rmq[v] = make_pair(a[tl], tl);
		return;
	}
	int m = (tl + tr) >> 1;
	build(v * 2 + 1, tl, m);
	build(v * 2 + 2, m, tr);
	rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}

void del(int v, int tl, int tr, int l, int r) {
	if (r <= tl || tr <= l)
		return;
	if (l <= tl && tr <= r) {
		--dd[v];
		--rmq[v].first;
		return;
	}
	int m = (tl + tr) >> 1;
	del(v * 2 + 1, tl, m, l, r);
	del(v * 2 + 2, m, tr, l, r);
	rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]);
	rmq[v].first += dd[v];
}

pair<int, int> get(int v, int tl, int tr, int l, int r) {
	if (r <= tl || tr <= l)
		return make_pair(INF, 0);
	if (l <= tl && tr <= r)
		return rmq[v];
	int m = (tl + tr) >> 1;
	auto ans = min(get(v * 2 + 1, tl, m, l, r), get(v * 2 + 2, m, tr, l, r));
	ans.first += dd[v];
	return ans;
}

bool cmp(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

bool cmp2(pair<int, int> a, pair<int, int> b) {
	return a.first > b.first;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> tmp[i].first >> tmp[i].second;
	}
	for (int i = 0; i < n + 1; ++i) {
		int x;
		cin >> x;
		ss.insert(x);
	}
	cin >> q;
	for (int i = 0; i < n; ++i) {
		if (tmp[i].first <= tmp[i].second) {
			++add;
			auto it = ss.lower_bound(tmp[i].first);
			if (it == ss.end())
				no();
			ss.erase(it);
		}
	}
	for (int i: ss)
		vv.push_back(i);
	vv.resize(unique(vv.begin(), vv.end()) - vv.begin());
	for (int i: ss) {
		++ad[fnd(i)];
	}
	vector<pair<int, int> > sg;
	for (int i = 0; i < n; ++i) {
		if (tmp[i].first > tmp[i].second) {
			int x = fnd(tmp[i].second);
			if (x == vv.size())
				no();
			--ad[x];
			int y = fnd(tmp[i].first);
			if (y < vv.size()) {
				sg.push_back(make_pair(x + 1, y + 1));
			}
		}
	}
	int now = 0;
	fn = vv.size();
	for (int i = vv.size() - 1; i >= 0; --i) {
		now += ad[i];
		a[i] = now;
		if (now < 0)
			no();
		if (now == 0)
			fn = i;
	}

	for (int i = 0; i < vv.size(); ++i)
		--a[i];

	build(0, 0, vv.size());
	sort(sg.begin(), sg.end(), cmp);
	vector<pair<int, int> > sg2;
	for (int i = 0; i < sg.size(); ++i) {
		int l, r;
		tie(l, r) = sg[i];
		if (get(0, 0, vv.size(), l, r).first > 0)
			del(0, 0, vv.size(), l, r), ++add;
		else
			sg2.push_back(make_pair(l, r));
	}
	sort(sg2.begin(), sg2.end(), cmp2);
	for (int i = 0; i < sg2.size(); ++i) {
		int l, r;
		tie(l, r) = sg2[i];
		auto tmp = get(0, 0, vv.size(), l, r);
		if (tmp.first == -1)
			continue;
		else {
			++ans[tmp.second];
			del(0, 0, vv.size(), l, r);
		}
	}
	ans[vv.size()] = add;
	for (int i = vv.size() - 1; i >= 0; --i) {
		ans[i] += ans[i + 1];
	}

	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x = fnd(x);
		y = fnd(y);
		int ans = max(get(x) + 1, get(y));
		if (ans < 0)
			cout << -1 << "\n";
		else
			cout << ans << "\n";
	}
	return 0;
}




Measured memory_bytes: 14712