#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0; char ch = getchar();
	while( ch < '0' || ch > '9' ) ch = getchar();
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc;
}

const int MAXN = 100010;
const int INF = 1e9 + 7;

int n, a[MAXN], b[MAXN], c[MAXN], d[MAXN], ans[MAXN], cur;
bool usd[MAXN];
priority_queue < pa > q;
vector < pa > v[MAXN];

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ ) a[ i ] = read(), b[ i ] = read();
	for( int i = 1 ; i <= n + 1 ; i++ ) c[ i ] = read();
	int Q = read();
	sort( c + 1, c + n + 2 );
	for( int i = 1 ; i <= n ; i++ ) a[ i ] = lower_bound( c + 1, c + n + 2, a[ i ] ) - c, b[ i ] = lower_bound( c + 1, c + n + 2, b[ i ] ) - c;
	for( int i = 1 ; i <= n ; i++ ) d[ a[ i ] - 1 ]--, v[ a[ i ] - 1 ].pb( mp( -b[ i ], i ) );
	d[ n + 2 ] = n;
	for( int i = n + 1 ; i ; i-- )
	{
		for( auto y : v[ i ] ) q.push( y );
		for( d[ i ] += d[ i + 1 ] ; d[ i ] - i < -1 ; q.pop() )
		{
			if( q.empty() || -q.top().xx > i ) goto yjq;
			usd[ q.top().yy ] = 1; d[ i ]++; d[ -q.top().xx - 1 ]--; ans[ 0 ]++;
		}
	}
	fill( d, 0 ); while( !q.empty() ) q.pop();
	for( int i = 1 ; i <= n ; i++ ) v[ i ].clear();
	for( int i = 1 ; i <= n ; i++ ) { d[ usd[ i ] ? b[ i ] : a[ i ] ]++; if( !usd[ i ] ) v[ b[ i ] ].pb( mp( a[ i ] - 1, i ) ); } 
	for( int i = 1 ; i <= n + 1 ; i++ )
	{
		for( auto y : v[ i ] ) q.push( y );
		d[ i ] += d[ i - 1 ]; ans[ i ] = ans[ i - 1 ];
		if( d[ i ] - i == -1 && cur < i )
		{
			if( q.empty() || q.top().xx < i ) ans[ i ] = INF;
			else cur = q.top().xx, q.pop(), ans[ i ]++;
		}
	}
	while( Q-- )
	{
		int a = lower_bound( c + 1, c + n + 2, read() ) - c - 1, b = lower_bound( c + 1, c + n + 2, read() ) - c - 1, ret;
		ret = min( ans[ a ], ans[ b ] + 1 );
		if( ret > n + 1 ) puts( "-1" );
		else printf( "%d\n", n + 1 - ret );
	}
	return 0;
yjq:while( Q-- ) puts( "-1" );
	return 0;
}
