#include<bits/stdc++.h>
using namespace std;
#define hi ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef int64_t ll;
typedef long double ld;
typedef long long unsigned llu;
#define test                int test; cin>>test; while(test--)
#define loop(i,n,k)         for(int i=n;i<k;i++)
#define rloop(i,n,k)         for(int i=n;i>=k;i--)
#define INT(a)                 int a;scanf("%d",&a);
#define intin(temp)            scanf("%d",&temp);
#define longin(temp)        scanf("%lld",&temp);
#define LLI(a)                 ll a;scanf("%lld",&a);
#define DOUBLE(a)             double a;scanf("%f",&a);
#define LD(a)                 long double a;scanf("%lf",&a);
#define pb(i)                 push_back(i)
#define sz(i)                 i.size()
#define mkp(i,j)            make_pair(i,j)
#define ip                     pair<int,int>
#define lp                    pair<ll,ll>
#define FOR(i,n)            for(i=0;i<n;i++)
#define range(v)            v.begin(),v.end()
#define bye                    return 0;
#define file                freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

template<class c>
c gcd (c a,c b){
    if(b==0)
        return a;
    gcd(b,a%b);
}
template<class c>
c lcm(c a,c b){
    return a/gcd(a,b)*b;
}
template<class a>
bool prime(a n){
    for(a i=2;i<=sqrt(n);i++){
        if(n%i==0)
            return 0;
    }
    return 1;
}
bool bigger(pair<int,int>picachu,pair<int,int> qicachu){
    return (picachu.first<qicachu.first);
}void printarr(int arr[],int n){
    for(int i=0;i<n;i++)
        cout<<arr[i]<<' ';
    cout<<endl;
}
int chartoint(char c) {
    if (c >= 'a' && c <= 'z') return c - 'a';
    if (c >= 'A' && c <= 'Z') return c - 'A' + 26;
    return 52;
}
int kadane(int arr[],int n){
    int maximum= arr[0];
    int max_so_far = 0;
    for(int i=0;i<n;i++){
        max_so_far+=arr[i];
        if(max_so_far>maximum)
            maximum = max_so_far;
        if(max_so_far<0)
            max_so_far = 0;
    }
    return maximum;
}
const int MOD = 1e9+7;
void run(){    
    int n,s,d;
    cin >> n >> s >> d;
    int x,y;
    bool flag = false;
    loop(i,0,n){
        cin >> x >> y;
        if(x<s && y>d){
            flag = true;
        }
    }
    if(flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main(){
    hi;
    #ifndef ONLINE_JUDGE 
       freopen("input.txt", "r", stdin); 
      freopen("error.txt", "w", stderr); 
      freopen("output.txt", "w", stdout); 
       #endif 
   
  
       { 
          run(); 
       }
      cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
     bye;
}
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

ll solve(vector <ll> &A, vector <int> &T, int n, ll a) {
	ll ats=a;
	for (int i=0;i<n;i++) {
		if (T[i]==1) {
			ats+=A[i];
			}
		else {
			if (T[i]==2) {
				ats=max(ats,A[i]);
				}
			else {ats=min(ats,A[i]);}
			}
		}
	return ats;
	}
	
ll s(ll a,ll maz, ll did, ll suma, ll r1, ll r2) {
	if (a<=maz) {return r1;}
	if (a>=did) {return r2;}
	return a+suma;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <ll> A(n);
    vector <int> T(n);
    for (int i=0;i<n;i++) {cin>>A[i]>>T[i];}
    int q;
    cin>>q;
    vector <ll> X(q);
    set<ll> Q;
    for (int i=0;i<q;i++) {cin>>X[i];Q.insert(X[i]);}
    ll maz=*Q.begin()-1;
    ll did=*Q.rbegin()+1;
    ll r1=solve(A,T,n,maz+1);
    ll r2=solve(A,T,n,did-1);
    ll suma=0;
    vector <ll> Y;
    for (ll x:Q) {Y.push_back(x);}
    sort(Y.begin(),Y.end());
    int ind1=0;
    int ind2=(int)Y.size()-1;
    while (ind2-ind1>2) {
		int c=(ind1+ind2)/2;
		if (solve(A,T,n,Y[c])>r1) {ind2=c;}
		else {ind1=c;}
		}
	while (solve(A,T,n,Y[ind2])>r1) {ind2--;}
	maz=Y[ind2];
	
	ind1=0;
    ind2=(int)Y.size()-1;
    while (ind2-ind1>2) {
		int c=(ind1+ind2)/2;
		if (solve(A,T,n,Y[c])>=r2) {ind2=c;}
		else {ind1=c;}
		}
	while (solve(A,T,n,Y[ind1])<r2) {ind1++;}
	did=Y[ind1];
	//cout<<ind1-1<<" "<<solve(A,T,n,Y[ind1-1])<<" "<<Y[ind1-1]<<endl;
	if (ind1>0) {
		suma=solve(A,T,n,Y[ind1-1])-Y[ind1-1];
		}
	//cout<<maz<<" "<<did<<" "<<r1<<" "<<r2<<" "<<suma<<endl;
	for (int i=0;i<q;i++) {
		ll a=X[i];
		ll ats=s(a,maz,did,suma,r1,r2);
		cout<<ats<<endl;
		}
    return 0;
}
