#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

struct segtree{
	using D = int;

	int N;
	vector<D> val;

	segtree(){}
	segtree(int n){
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,0);
	}
	segtree(const vector<D>& ds){
		int n = ds.size();
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,0);
		rep(i,n) val[i+N] = ds[i];
		for(int i=N-1;i>0;i--) val[i] = val[i*2] + val[i*2+1];
	}
	D getval(int k){
		k+=N;
		D res = 0;
		while(k){
			res += val[k];
			k/=2;
		}
		return res;
	}
	void add(int a,int b,D v){		//non-commutative & unrecursive
		a+=N,b+=N;
		while(a<b){
			if(a&1){
				val[a] += v;
				a++;
			}
			if(b&1){
				b--;
				val[b] += v;
			}
			a/=2,b/=2;
		}
		return;
	}
	void debug(){
		cerr << " seg debug : ";
		rep(i,N) cerr << getval(i) << " ";
		cerr << endl;
	}

};
struct Ran{
	int l,r;
	Ran(int l_,int r_):l(l_),r(r_){}
	bool operator<(const Ran& y) const {
		return l > y.l;
	}
	friend ostream& operator<<(ostream &o,const Ran& x){ return o<<"("<<x.l<<","<<x.r<<")";}

};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	N++;
	V<int> A(N-1),B(N-1),C(N);
	rep(i,N-1) cin >> A[i] >> B[i];
	rep(i,N) cin >> C[i];

	sort(all(C));
	auto ID = [&](int x){
		return lower_bound(all(C),x) - C.begin();
	};
	rep(i,N-1){
		A[i] = ID(A[i]);
		B[i] = ID(B[i]);
	}
	int Q;
	cin >> Q;
	V<int> D(Q),E(Q);
	rep(i,Q){
		cin >> D[i] >> E[i];
		D[i] = ID(D[i]);
		E[i] = ID(E[i]);
	}



	segtree f(N+1);
	VV<int> r2ls(N+1);
	rep(i,N-1){
		f.add(A[i],N+1,1);
		if(A[i] > B[i]){		// [B,A-1]
			r2ls[A[i]-1].pb(B[i]);
		}
	}
	rep(i,N) f.add(i,i+1,-i);

	if(false){
		show(A);
		show(B);
		f.debug();
	}


	
	priority_queue<Ran> que;
	V<int> ans(N+1);
	const int inf = 1e9;
	ans[N] = inf;

	for(int i=N-1;i>=0;i--){
		for(int l: r2ls[i]){
			que.push(Ran(l,i));
			show(Ran(l,i));
		}
		while(f.getval(i) < 0){
			if(que.empty()){
				rep(i,Q) cout << -1 << endl;
				return 0;
			}
			Ran p = que.top();
			que.pop();
			f.add(p.l,p.r+1,1);
			cerr << "add [" << p.l << "," << p.r << "]" << endl;
			ans[0]++;
		}
	}

	int maxr = -1;
	rep(i,N){
		while(!que.empty() && que.top().l == i){
			chmax(maxr,que.top().r);
			que.pop();
		}
		if(f.getval(i) == 0){
			if(maxr < i){
				for(int j=i+1;j<=N;j++) ans[j] = inf;
				break;
			}
			f.add(i,maxr+1,1);
			ans[i+1] = ans[i] + 1;
		}else{
			ans[i+1] = ans[i];
		}
	}
	show(ans);

	rep(t,Q){
		int tmp = min(ans[D[t]],ans[E[t]]+1);
		if(tmp >= inf) tmp = N+1;
		cout << N-tmp << endl;
	}
}


Measured memory_bytes: 10612