#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define mod 100000000
//7914,10014,4015

/*int findpos(int start,int high){
	int mid=0;
    while(start<=high){

    	mid=start+(high-start)/2;

    	 if(v[mid]<v[mid-1]&&v[mid]<v[mid=1])return mid;
    	else if(v[mid]>v[high])low=mid+1;
    	else high=mid-1;

    }
    return mid;
}*/
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  long  long n,k;
  cin>>n>>k;
  int a[n],peak[n]={0};
  map<int,pair<int,int>>mp;
  for(int i=0;i<n;i++)cin>>a[i];
  int i=0;
  long long pr,start=0 ;
  peak[0]=n;
  while(i<n-1){
  	start=i;
  	while(i!=n-1&&a[i]<=a[i+1])i++;

  	peak[i]=i;
  	pr=i;
  	//cout<<pr<<endl;
  	while(i!=n-1&&a[i]>=a[i+1])i++;

  	mp[pr]=make_pair(start,i);

  }

  if(peak[n-1]!=n-1)peak[n-1]=n;
  for(int i=n-2;i>=0;i--){
  	if(peak[i]!=i)peak[i]=peak[i+1];

  }
 // cout<<14<<endl;
  //for(int i=0;i<n;i++)cout<<peak[i]<<endl;
  //cout<<14<<endl;
  int x,y,fx,fy;
  for(int i=0;i<k;i++){
  	cin>>x>>y;
  	x--;y--;
  //	cout<<peak[x]<<" "<<mp[peak[x]].first<<" "<<mp[peak[x]].second<<endl;
  //	cout<<peak[x]<<" "<<mp[peak[x]]<<endl;
  if(x==y){cout<<"Yes"<<endl;
  		continue;}

  	if(peak[x]==peak[y]){
  		if(mp[peak[x]].first>=y)
  		cout<<"Yes"<<endl;
  		else if(mp[peak[x]].first<=x)cout<<"Yes"<<endl;
  		else if(mp[peak[x]].first==x)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

  		continue;
  	}

  	if(mp[peak[x]].second>=y&&mp[peak[x]].first<=x){
cout<<"Yes"<<endl;
  		continue;

  	}
  	else cout<<"No"<<endl;

  }

 	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define mod 100000000
//7914,10014,4015

/*int findpos(int start,int high){
	int mid=0;
    while(start<=high){

    	mid=start+(high-start)/2;

    	 if(v[mid]<v[mid-1]&&v[mid]<v[mid=1])return mid;
    	else if(v[mid]>v[high])low=mid+1;
    	else high=mid-1;

    }
    return mid;
}*/
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  long  long n,k;
  cin>>n>>k;
  int a[n],peak[n]={0};
  map<int,pair<int,int>>mp;
  for(int i=0;i<n;i++)cin>>a[i];
  int i=0;
  long long pr,start=0 ;
  peak[0]=n;
  while(i<n-1){
  	start=i;
  	while(i!=n-1&&a[i]<=a[i+1])i++;
  	if(i==n-2)i++;
  	peak[i]=i;
  	pr=i;
  	//cout<<pr<<endl;
  	while(i!=n-1&&a[i]>=a[i+1])i++;
  	if(i==n-2&&a[i]>=a[i+1]){i++;}
  	mp[pr]=make_pair(start,i);

  }

  if(peak[n-1]!=n-1)peak[n-1]=n;
  for(int i=n-2;i>=0;i--){
  	if(peak[i]!=i)peak[i]=peak[i+1];

  }
 // cout<<14<<endl;
  for(int i=0;i<n;i++)cout<<peak[i]<<endl;
  //cout<<14<<endl;
  int x,y,fx,fy;
  for(int i=0;i<k;i++){
  	cin>>x>>y;
  	x--;y--;
  //	cout<<peak[x]<<" "<<mp[peak[x]].first<<" "<<mp[peak[x]].second<<endl;
  //	cout<<peak[x]<<" "<<mp[peak[x]]<<endl;
  if(x==y){cout<<"Yes"<<endl;
  		continue;}

  	if(peak[x]>y){
  		if(mp[peak[x]].first>=y)
  		cout<<"Yes"<<endl;
  		else cout<<"No"<<endl;

  		continue;
  	}
  	if(mp[peak[x]].second>=y&&mp[peak[x]].first<=x){
cout<<"Yes"<<endl;
  		continue;

  	}
  	else cout<<"No"<<endl;

  }

 	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define mod 100000000
//7914,10014,4015

/*int findpos(int start,int high){
	int mid=0;
    while(start<=high){

    	mid=start+(high-start)/2;

    	 if(v[mid]<v[mid-1]&&v[mid]<v[mid=1])return mid;
    	else if(v[mid]>v[high])low=mid+1;
    	else high=mid-1;

    }
    return mid;
}*/
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  long  long n,k;
  cin>>n>>k;
  int a[n],peak[n]={0};
  map<int,pair<int,int>>mp;
  for(int i=0;i<n;i++)cin>>a[i];
  int i=0;
  long long pr,start=0 ;
  peak[0]=n;
  while(i<n-1){
  	start=i;
  	while(i!=n-1&&a[i]<=a[i+1])i++;

  	peak[i]=i;
  	pr=i;
  	//cout<<pr<<endl;
  	while(i!=n-1&&a[i]>=a[i+1])i++;

  	mp[pr]=make_pair(start,i);

  }

  if(peak[n-1]!=n-1)peak[n-1]=n;
  for(int i=n-2;i>=0;i--){
  	if(peak[i]!=i)peak[i]=peak[i+1];

  }
 // cout<<14<<endl;
  //for(int i=0;i<n;i++)cout<<peak[i]<<endl;
  //cout<<14<<endl;
  int x,y,fx,fy;
  for(int i=0;i<k;i++){
  	cin>>x>>y;
  	x--;y--;
  //	cout<<peak[x]<<" "<<mp[peak[x]].first<<" "<<mp[peak[x]].second<<endl;
  //	cout<<peak[x]<<" "<<mp[peak[x]]<<endl;
  if(x==y){cout<<"Yes"<<endl;
  		continue;}

  	if(peak[x]==peak[y]){
  		if(mp[peak[x]].first>=y)
  		cout<<"Yes"<<endl;
  		else if(mp[peak[x]].first<=x)cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;

  		continue;
  	}

  	if(mp[peak[x]].second>=y&&mp[peak[x]].first<=x){
cout<<"Yes"<<endl;
  		continue;

  	}
  	else cout<<"No"<<endl;

  }

 	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define mod 100000000
//7914,10014,4015

/*int findpos(int start,int high){
	int mid=0;
    while(start<=high){

    	mid=start+(high-start)/2;

    	 if(v[mid]<v[mid-1]&&v[mid]<v[mid=1])return mid;
    	else if(v[mid]>v[high])low=mid+1;
    	else high=mid-1;

    }
    return mid;
}*/
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  long  long n,k;
  cin>>n>>k;
  int a[n],peak[n]={0};

  for(int i=0;i<n;i++)cin>>a[i];

  int last=n;

  for(int i=n-1;i>=0;i--){
  	if(i!=0&&i!=n-1){
  		if(a[i-1]<=a[i]&&a[i+1]<=a[i])
  			peak[i]=i;
  			else peak[i]=last;
  		if(a[i-1]==a[i+1]&&a[i]==a[i+1])peak[i]=last;

  	}
  	if(i==0){
  	if(i+1<n&&a[i+1]<a[i])peak[0]=0;
  	else peak[0]=last;
  	}
  	if(i==n-1&&i!=0){
  	if(a[i-1]<a[i])peak[n-1]=i;
  	else peak[n-1]=last;
  	}
  	last=peak[i];
  //	cout<<peak[i]<<endl;
  }
  int x,y,fx,fy;
  for(int i=0;i<k;i++){
  	cin>>x>>y;
  	x--;y--;
  	fx=peak[x];
  	if(fx==y+1){
  			cout<<"Yes"<<endl;
  		continue;
  	}
  		int z,zz;

  	if(fx==x){
  	if(x<y){
  		z=peak[x+1];
  		if(z<y+1){
  			cout<<"No"<<endl;
  	}
  	else cout<<"Yes"<<endl;

  	}
  	else cout<<"Yes"<<endl;
  	continue;
  	}
  	fy=peak[fx];
  	if(fy<y){

  			zz=peak[fy+1];
  			if(zz<y+1){
  				cout<<"No"<<endl;

  			}
  			else cout<<"Yes"<<endl;
  			continue;
  		}
  	else{
  	 cout<<"Yes"<<endl;

  	}

  }

 	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;
    loop(i,3,N){
        if(a[i]<=a[i-1] && a[i-2]<a[i-1])
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if(a[i]>=a[i-1] && a[i-2]>a[i-1])
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else if(a[N]>a[N-1]) UP[1]=UP[N-1]+1;
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;
    loop(i,3,N){
        if(a[i]<=a[i-1] && a[i-2]<a[i-1])
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if(a[i]>a[i-1] && a[i-2]>=a[i-1])
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else if(a[N]>a[N-1]) UP[1]=UP[N-1]+1;
    else {
        UP[N]=UP[N-1];
        DOWN[N]=DOWN[N-1];
    }
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;
    loop(i,3,N){
        if(a[i]<=a[i-1] && a[i-2]<a[i-1])
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if(a[i]>=a[i-1] && a[i-2]>a[i-1])
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else if(a[N]>a[N-1]) UP[1]=UP[N-1]+1;
    loop(i,1,N)
        cout<<UP[i]<<" ";
    cout<<endl;
    loop(i,1,N)
        cout<<DOWN[i]<<" ";
    cout<<endl;
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], INC[100009], DEC[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];

    INC[N]=DEC[N]=N;

    bloop(i,1,N-1){
        if(a[i]>a[i+1]) {
            DEC[i]=DEC[i+1];
            INC[i]=i;
        }
        else if(a[i]<a[i+1]){
            DEC[i]=i;
            INC[i]=INC[i+1];
        } else {
            INC[i]=INC[i+1];
            DEC[i]=DEC[i+1];
        }
    }

    loop(i,1,M){
        cin>>l>>r;
        if(r<=INC[l] || r<=DEC[l] || r<=DEC[INC[l]]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];

    loop(i,3,N){
        if((a[i]<a[i-1] && a[i-2]<a[i-1]))
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if((a[i]>a[i-1] && a[i-2]>a[i-1]))
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }

    loop(i,1,N)
        cout<<UP[i]<<" ";
    cout<<endl;
    loop(i,1,N)
        cout<<DOWN[i]<<" ";
        cout<<endl;

    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], INC[100009], DEC[100009];

// Let there be two arrays. INC[i] stores the maximum index>=i such that a[i..ind]
// is increasing. DEC[i] stores the maximum index>=i such that a[i..ind] is decreasing.
// Now there are 3 cases when the answer can be Yes:
// 1. If query(l, r) lies only in the increasing part. (r<=INC[l])
// 2. If query(l, r) lies only in the decreasing part. (r<=DEC[l])
// 3. If query(l, r) lies in the increasing and then the decreasing part. (r<=DEC[INC[l]])

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];

    INC[N]=DEC[N]=N;

    bloop(i,1,N-1){
        if(a[i]>a[i+1]) {
            DEC[i]=DEC[i+1];
            INC[i]=i;
        }
        else if(a[i]<a[i+1]){
            DEC[i]=i;
            INC[i]=INC[i+1];
        } else {
            INC[i]=INC[i+1];
            DEC[i]=DEC[i+1];
        }
    }

    loop(i,1,M){
        cin>>l>>r;
        if(r<=INC[l] || r<=DEC[l] || r<=DEC[INC[l]]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;
    loop(i,3,N){
        if((a[i]<=a[i-1] && a[i-2]<a[i-1])  || (a[i]<a[i-1] && a[i-2]<=a[i-1]))
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if((a[i]>a[i-1] && a[i-2]>=a[i-1]) || (a[i]>=a[i-1] && a[i-2]>a[i-1]))
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else if(a[N]>a[N-1]) UP[1]=UP[N-1]+1;
    else {
        UP[N]=UP[N-1];
        DOWN[N]=DOWN[N-1];
    }
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;
    else {
        UP[N]=UP[N-1];
        DOWN[N]=DOWN[N-1];
    }
    loop(i,3,N){
        if(a[i]<=a[i-1] && a[i-2]<a[i-1])
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if(a[i]>=a[i-1] && a[i-2]>a[i-1])
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else if(a[N]>a[N-1]) UP[1]=UP[N-1]+1;
    else {
        UP[N]=UP[N-1];
        DOWN[N]=DOWN[N-1];
    }
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;

    loop(i,3,N){
        if((a[i]<a[i-1] && a[i-2]<a[i-1]))
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if((a[i]>a[i-1] && a[i-2]>a[i-1]))
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else DOWN[N]=DOWN[N-1];
    if(a[N]>a[N-1]) UP[N]=UP[N-1]+1;
    else UP[N]=UP[N-1];
    /*loop(i,1,N)
        cout<<UP[i]<<" ";
    cout<<endl;
    loop(i,1,N)
        cout<<DOWN[i]<<" ";
        cout<<endl;*/
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];

    loop(i,3,N){
        if((a[i]<a[i-1] && a[i-2]<a[i-1]))
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if((a[i]>a[i-1] && a[i-2]>a[i-1]))
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    /*
    loop(i,1,N)
        cout<<UP[i]<<" ";
    cout<<endl;
    loop(i,1,N)
        cout<<DOWN[i]<<" ";
        cout<<endl;
    */
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;

#define INF 1e18
#define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define bloop(i,a,b) for(ll i=(ll)b;i>=(ll)a;i--)
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mem(a, v) memset(a, v, sizeof a)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
#define EPS 1e-9

int T;
int N, M, l, r;
ll a[100009], UP[100009], DOWN[100009];

void solve(){
	cin>>N>>M;
    loop(i,1,N)
        cin>>a[i];
    if(a[2]>a[1]) DOWN[1]=1;
    else if(a[1]>a[2]) UP[1]=1;
    loop(i,3,N){
        if((a[i]<a[i-1] && a[i-2]<a[i-1]))
            UP[i-1]=UP[i-2]+1;
        else UP[i-1]=UP[i-2];
        if((a[i]>a[i-1] && a[i-2]>a[i-1]))
            DOWN[i-1]=DOWN[i-2]+1;
        else DOWN[i-1]=DOWN[i-2];
    }
    if(a[N-1]>a[N]) DOWN[N]=DOWN[N-1]+1;
    else if(a[N]>a[N-1]) UP[1]=UP[N-1]+1;
    else {
        UP[N]=UP[N-1];
        DOWN[N]=DOWN[N-1];
    }
    loop(i,1,M){
        cin>>l>>r;
        if(l==r) cout<<"Yes"<<endl;
        else if(DOWN[r-1]-DOWN[l]==0 && UP[r-1]-UP[l]<=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

int main(){
    //clock_t start_s=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  		freopen("/home/snehil/Desktop/input.txt","r",stdin);
    	freopen("/home/snehil/Desktop/output.txt","w",stdout);
    #endif
    //cin>>T;
    T=1;
    while(T--){
    	solve();
    }
    //clock_t stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=l[i-1]+1;
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n-1;i>0;i--)
	{
	 if(a[i]<=a[i+1])
	 r[i]=r[i+1]+1;
	 else
	 r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]-1>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=1+l[i-1];
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n;i>0;i--)
	{
	if(a[i]<=a[i+1])
	r[i]=r[i+1];
	else
	r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=0;
	 else
	 l[i]=1+l[i-1];
	}
	r[n]=0;
	for(int i=n;i>0;i--)
	{
	if(a[i]<=a[i+1])
	r[i]=0;
	else
	r[i]=r[i+1]+1;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=l[i-1]+1;
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n-1;i>0;i--)
	{
	 if(a[i]<=a[i+1])
	 r[i]=r[i+1]+1;
	 else
	 r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[b]+r[c]-1>c-b+1)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=1+l[i-1]
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n;i>0;i--)
	{
	if(a[i]<=a[i+1])
	r[i]=r[i+1]
	else
	r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=1+l[i-1];
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n;i>0;i--)
	{
	if(a[i]<=a[i+1])
	r[i]=r[i+1]+1;
	else
	r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=1+l[i-1];
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n;i>0;i--)
	{
	if(a[i]<=a[i+1])
	r[i]=1+r[i+1];
	else
	r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=1;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=l[i-1]+1;
	 else
	 l[i]=1;
	}
	r[n]=1;
	for(int i=n-1;i>0;i--)
	{
	 if(a[i]<=a[i+1])
	 r[i]=r[i+1]+1;
	 else
	 r[i]=1;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[b]+r[c]-1>c-b+1)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
	 if(a[i]<=a[i-1])
	 l[i]=l[i-1]+1;
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n-1;i>0;i--)
	{
	 if(a[i]<=a[i+1])
	 r[i]=r[i+1]+1;
	 else
	 r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
	cin>>n>>m;
	int a[100000],l[100000],r[100000];
		l[1]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=2;i<=n;i++)
	{
      if(a[i]<=a[i-1])
	 l[i]=l[i-1]+1;
	 else
	 l[i]=0;
	}
	r[n]=0;
	for(int i=n-1;i>0;i--)
	{
	 if(a[i]<=a[i+1])
	 r[i]=r[i+1]+1;
	 else
	 r[i]=0;
	}
	while(m--)
	{
	    int b,c;
		cin>>b>>c;
		if(l[c]+r[b]>c-b+1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];
int in[100005];
int dc[100005];

int main(){
	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	in[n - 1] = n - 1, dc[0] = 0;
	for(int i = n - 2; i >= 0; i--){
		if(a[i] <= a[i + 1]){
			in[i] = in[i + 1];
		}
		else in[i] = i;
	}

	for(int i = 1; i < n; i++){
		if(a[i] <= a[i - 1])
			dc[i] = dc[i - 1];
		else
			dc[i] = i;
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		--l, --r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		cout << (in[l] == dc[r] || dc[r] <= l ? "Yes\n" : "No\n");
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(c[r - 1] - c[l] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];
int in[100005];
int dc[100005];

int main(){
	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}

	in[n - 1] = n - 1, dc[0] = 0;
	for(int i = n - 2; i >= 0; i--){
		if(a[i] < a[i + 1]){
			in[i] = in[i + 1];
		}
		else in[i] = i;
	}

	for(int i = 1; i < n; i++){
		if(a[i] < a[i - 1])
			dc[i] = dc[i - 1];
		else
			dc[i] = i;
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		--l, --r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}

		cout << (in[l] >= dc[r] ? "Yes\n" : "No\n");
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e5, 0});

	int c[100005];
	int idx = 0;
	for(auto x : vs){
		c[x - 1] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(l == r){
			cout << "Yes\n";
			continue;
		}

		auto up = *vs.upper_bound(l - 1);
		auto lw = *vs.lower_bound(r - 1);
		if(bs.size() > lw && bs[lw].second == 2){
			cout << "No\n";
			continue;
		}
		if(up == lw && c[r - 2] - c[l - 1] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(c[r - 1] - c[l + 1] >= 0 && !(r - 1 == l + 1 && c[r - 1] < 0)){

			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];
int in[100005];
int dc[100005];

int main(){
	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	in[n - 1] = n - 1, dc[0] = 0;
	for(int i = n - 2; i >= 0; i--){
		if(a[i] <= a[i + 1]){
			in[i] = in[i + 1];
		}
		else in[i] = i;
	}

	for(int i = 1; i < n; i++){
		if(a[i] <= a[i - 1])
			dc[i] = dc[i - 1];
		else
			dc[i] = i;
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		--l, --r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		cout << (in[l] == dc[r] || dc[r] == l ? "Yes\n" : "No\n");
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e5, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		if(c[r - 1] - c[l] == 0){

			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e5, 0});

	int c[100005];
	int idx = 0;
	for(auto x : vs){
		c[x - 1] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(l == r){
			cout << "Yes\n";
			continue;
		}

		auto up = *vs.upper_bound(l - 1);
		auto lw = *vs.lower_bound(r - 1);
		if(bs.size() > lw && bs[lw].second == 2){
			cout << "No\n";
			continue;
		}
		if(up == lw || c[r - 2] - c[l - 1] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		if(c[r - 1] - c[l + 1] >= 0 && !(r - 1 == l + 1 && c[r - 1] < 0)){

			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		if(c[r - 1] - c[l] == 0){

			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(c[r - 1] - c[l - 1] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e5, 0});

	int c[100005];
	int idx = 0;
	for(auto x : vs){
		c[x - 1] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(l == r){
			cout << "Yes\n";
			continue;
		}

		auto up = *vs.upper_bound(l - 1);
		auto lw = *vs.lower_bound(r - 1);
		if(bs.size() > lw && bs[lw].second == 2){
			cout << "No\n";
			continue;
		}
		if(c[r - 2] - c[l - 1] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e5, 0});

	int c[100005];
	int idx = 0;
	for(auto x : vs){
		c[x - 1] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(l == r){
			cout << "Yes\n";
			continue;
		}

		auto up = *vs.upper_bound(l - 1);
		auto lw = *vs.lower_bound(r - 1);
		if(bs.size() > lw && bs[lw].second == 2){
			cout << "No\n";
			continue;
		}
		if(up == lw || c[r - 1] - c[l - 1] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];
	int idx = 0;
	for(auto x : vs){
		c[x - 1] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(c[r - 2] - c[l - 2] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];
	c[-1] = 0;
	int idx = 0;
	for(auto x : vs){
		c[x - 1] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(c[r - 2] - c[l - 2] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e5, 0});

	int c[100005];
	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i < n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(l == r){
			cout << "Yes\n";
			continue;
		}

		auto up = *vs.upper_bound(l - 1);
		auto lw = *vs.lower_bound(r - 1);
		if(bs.size() > lw && bs[lw].second == 2){
			cout << "No\n";
			continue;
		}
		if(up == lw || c[r - 1] - c[l - 2] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	set<int> vs;
	vector<pair<int, int>> bs;
	//bs.push_back({})
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] <= a[i] && a[i + 1] < a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] < a[i] && a[i + 1] == a[i])
			vs.insert(i + 1), bs.push_back({1, 1});
		else if(a[i - 1] == a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({1, 2});
		else if(a[i - 1] > a[i] && a[i + 1] > a[i])
			vs.insert(i + 1), bs.push_back({-1e6, 0});

	int c[100005];

	int idx = 0;
	for(auto x : vs){
		c[x] = bs[idx++].first;
	}

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;

		if(c[r - 1] - c[l + 1] >= 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	int c[100005] = {0};
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] > a[i] && a[i + 1] > a[i])
			c[i + 1] = 1;

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		if(c[r - 1] - c[l] == 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include "bits/stdc++.h"
using namespace std;
int a[100005];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	int c[100005] = {0};
	for(int i = 1; i < n - 1; i++)
		if(a[i - 1] > a[i] && a[i + 1] > a[i])
			c[i + 1] = -1;

	for(int i = 1; i <= n; i++){
		c[i] += c[i - 1];
	}

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		if(l == r){
			cout << "Yes\n";
			continue;
		}
		if(c[r - 1] - c[l] == 0){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<=n;i++)
        cin>>a[i];
      for(int i=2;i<=n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(maxima,i,1);
                Ma[i]=1;
            }

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(minima,i,1);
                ma[i]=1;
            }

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<=n;i++)
        cin>>a[i];
      for(int i=2;i<n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(maxima,i,1);
                Ma[i]=1;
            }

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(minima,i,1);
                ma[i]=1;
            }

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
ll up[100005];
ll down[100005];
int main(){
     ll n,m;
     cin>>n>>m;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     down[n]=up[n]=n;
     for(int i=n-1;i>0;i--){
        if(a[i]<=a[i+1])
            up[i]=up[i+1];
        else
            up[i]=i;
        if(a[i]>=a[i+1])
             down[i]=down[i+1];
        else
             down[i]=i;
     }
     for(int i=0;i<m;i++){
        ll l,r;
        cin>>l>>r;
        ll u = up[l];
        if(u>=r){
            cout<<"Yes"<<endl;
            continue;
        }
        ll d = down[u];
        if(d>=r){
             cout<<"Yes"<<endl;
             continue;
        }
        cout<<"No"<<endl;
     }

}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<n;i++)
        cin>>a[i];
      for(int i=2;i<=n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(maxima,i,1);
                Ma[i]=1;
            }

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(minima,i,1);
                ma[i]=1;
            }

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(l==r){
            cout<<"Yes"<<endl;
            continue;
         }
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<=n;i++)
        cin>>a[i];
      for(int i=2;i<=n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(maxima,i,1);
                Ma[i]=1;
            }

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(minima,i,1);
                ma[i]=1;
            }

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"YES"<<endl;
         else if(Max==0 && Min==0)
             cout<<"YES"<<endl;
         else cout<<"NO"<<endl;
      }
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<=n;i++)
        cin>>a[i];
      for(int i=2;i<n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(maxima,i,1);
                Ma[i]=1;
            }

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(minima,i,1);
                ma[i]=1;
            }

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         if(l==r){
            cout<<"Yes"<<endl;
            continue;
         }
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<=n;i++)
        cin>>a[i];
      for(int i=2;i<n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
               update(maxima,i,1);
                Ma[i]=1;

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){

                update(minima,i,1);
                ma[i]=1;

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         if(l==r){
            cout<<"Yes"<<endl;
            continue;
         }
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<=n;i++)
        cin>>a[i];
      for(int i=2;i<n;i++){
        if(a[i]>a[i-1] && a[i]>a[i+1]){
               update(maxima,i,1);
                Ma[i]=1;

        }
        if(a[i]<a[i-1] && a[i]<a[i+1]){

                update(minima,i,1);
                ma[i]=1;

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         if(l==r){
            cout<<"Yes"<<endl;
            continue;
         }
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int n;
ll a[100005];
ll maxima[100005];
ll minima[100005];
ll Ma[100005];
ll ma[100005];
void update(ll *tree,int x,int del){
   for(;x<=n;x+=x&(-x))
       tree[x]+=del;
}
int query(ll *tree,int x){
    int ans=0;
   for(;x>0;x-=x&(-x))
       ans+=tree[x];
    return ans;
}
int main(){
      int m;
      cin>>n>>m;
      for(int i=1;i<n;i++)
        cin>>a[i];
      for(int i=2;i<=n;i++){
        if(a[i]>=a[i-1] && a[i]>=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(maxima,i,1);
                Ma[i]=1;
            }

        }
        if(a[i]<=a[i-1] && a[i]<=a[i+1]){
            if(a[i]!=a[i-1] || a[i]!=a[i+1]){
                update(minima,i,1);
                ma[i]=1;
            }

        }
      }
      while(m--){
         int l,r;
         cin>>l>>r;
         int Max=query(maxima,r)-query(maxima,l-1);
         int Min=query(minima,r)-query(minima,l-1);
         if(Ma[l]==1) Max--;
         if(Ma[r]==1) Max--;
         if(ma[l]==1) Min--;
         if(ma[r]==1) Min--;
         if(Max==1 && Min==0)
             cout<<"Yes"<<endl;
         else if(Max==0 && Min==0)
             cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
      }
}


/*
ID: xildar91
PROG: humble
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
int inf_int=2e9;
ll inf_ll=2e18;
typedef pair<int,int> pii;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz size()
template<typename T>
void prin(vector<T>& a)
{
    for(int i=0;i<a.size();i++)
    {
        cout << a[i];
        if(i<a.size()-1)
            cout<<" ";
        else
            cout <<"\n";
    }
}
template<typename T>
void prin(set<T>& a)
{
    for(auto it=a.begin();it!=a.end();it++)
    {
        cout << *it<<" ";
    }
}
template<typename T>
void prin_new_line(vector<T>& a)
{
    for(int i=0;i<a.size();i++)
    {
        cout << a[i]<<"\n";
    }
}
template<typename T,typename T1>
void prin_new_line(vector<pair<T,T1> >& a)
{
    for(int i=0;i<a.size();i++)
    {
        cout << a[i].fi<<" "<<a[i].se<<"\n";
    }
}

int sum_vec(vector<int>& a)
{
    int s=0;
    for(int i=0;i<a.size();i++)
    {
        s+=a[i];
    }
    return s;
}
template<typename T>
T max(vector<T>& a)
{
    T ans=a[0];
    for(int i=1;i<a.size();i++)
    {
        ans=max(ans,a[i]);
    }
    return ans;
}
template<typename T>
T min(vector<T>& a)
{
    T ans=a[0];
    for(int i=1;i<a.size();i++)
    {
        ans=min(ans,a[i]);
    }
    return ans;
}
template<typename T>
T min(T a,T b,T c)
{
    return min(a,min(b,c));
}
template<typename T>
T max(T a,T b,T c)
{
    return max(a,max(b,c));
}

double s_triangle(double x1,double y1,double x2,double y2,double x3,double y3)
{
    return abs(((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2);
}
bool overflow(ll a,ll b)
{
    if(a*b/b!=a)
        return true;
    return false;
}
#define x1 gfgs
#define y1 asd
bool debug=1;
const int maxn=1e7+20;
ll mod=1e9+7;
int cnt_a[maxn],cnt_b[maxn];
void solve()
{
    int n;
    cin >> n;
    int x;
    cin >> x;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin >> b[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    sort(b,b+n);
    int l=0;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int e=l;e<n;e++)
        {
            if(a[i]+b[e]>=x)
            {
                l=e+1;
                cnt++;
                break;
            }
        }
    }
    cout << 1<<" " <<cnt;

}
#define FILE "humble"
int main()
{

       // freopen("laundro_matt.txt","r",stdin);
      //  freopen("output.txt","w",stdout);

       //  freopen(FILE".in","r",stdin);
      //  freopen(FILE".out","w",stdout);
       if(!debug)
       {
            ios_base::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
       }
        int t=1;
        while(t--)
            solve();
        return 0;
}


#include <stdio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cassert>

using namespace std;

typedef long long ll;
typedef double real;
typedef pair<int, int> ii;

template <typename T>
string toString(T x) {
	if (x == 0) return "0";
	bool negative = x < 0;
	string res;
	while (x) {
		res.push_back('0' + x % 10);
		x /= 10;
	}
	if (negative) res.push_back('-');
	reverse(res.begin(), res.end());
	return res;
}

void ioFromFile(string inputFileName, string outputFileName) {
	ifstream fin(inputFileName);
	ofstream fout(outputFileName);
	cin.rdbuf(fin.rdbuf());
	cout.rdbuf(fout.rdbuf());
}

int read() { int res; scanf("%d", &res); return res; }
void write(int x) { printf("%d ", x); }

template <typename T>
T gcd(T a, T b) { return a == 0 ? b : gcd(b % a, a); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
//---------------------------------------------------

int main()
{
	int n = read();
	int k = read();
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		a[i] = read();
	}
	sort(a.begin(), a.end());
	vector<int> b(n);
	for (int i = 0; i < n; i++){
		b[i] = read();
	}
	sort(b.begin(), b.end());

	int res = 0;
	int ai = n - 1;
	int bi = 0;
	while (bi < n)
	{
		if (a[ai] + b[bi] >= k)
		{
			res++;
			ai--;
		}
		bi++;
	}

	cout << "1 " << res;

	return 0;
}

/*

5 99
aaaaa
2 .
4 .
3 .

*/


#include <stdio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cassert>

using namespace std;

typedef long long ll;
typedef double real;
typedef pair<int, int> ii;

template <typename T>
string toString(T x) {
	if (x == 0) return "0";
	bool negative = x < 0;
	string res;
	while (x) {
		res.push_back('0' + x % 10);
		x /= 10;
	}
	if (negative) res.push_back('-');
	reverse(res.begin(), res.end());
	return res;
}

void ioFromFile(string inputFileName, string outputFileName) {
	ifstream fin(inputFileName);
	ofstream fout(outputFileName);
	cin.rdbuf(fin.rdbuf());
	cout.rdbuf(fout.rdbuf());
}

int read() { int res; scanf("%d", &res); return res; }
void write(int x) { printf("%d ", x); }

template <typename T>
T gcd(T a, T b) { return a == 0 ? b : gcd(b % a, a); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
//---------------------------------------------------

int main()
{
	int n = read();
	int k = read();
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		a[i] = read();
	}
	sort(a.begin(), a.end());
	vector<int> b(n);
	for (int i = 0; i < n; i++){
		b[i] = read();
	}
	sort(b.begin(), b.end());

	int res = 0;
	int ai = n - 1;
	int bi = 0;
	while (ai >= 0)
	{
		if (a[ai] + b[bi] >= k)
		{
			res++;
			bi++;
		}
		ai--;
	}

	cout << "1 " << res;

	return 0;
}

/*

5 99
aaaaa
2 .
4 .
3 .

*/


#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<int,int> ii;

#define F        first
#define S        second
#define pnl      printf("\n")
#define sz(x)    (int)x.size()
#define sf(x)    scanf("%d",&x)
#define pf(x)    printf("%d\n",x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()
#define FOR(a,b) for(int i = a; i < b; ++i)

const db eps = 1e-12;
const db pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = inf * 2LL * inf;
const int mod = 1000 * 1000 * 1000 + 7;

int n, x;
int a[100005];
int b[100005];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &x);
    FOR(0, n) sf(a[i]);
    FOR(0, n) sf(b[i]);
    sort(a, a + n, greater<int>());
    sort(b, b + n);
    int mx = 0;
    int j = n - 1;
    for(int i = 0; i < n; ++i){
        while(j - 1 >= 0 && a[i] + b[j - 1] >= x)
            --j;
        mx = max(mx, min(n - i, n - j));
    }
    printf("%d %d\n", 1, mx);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<int,int> ii;

#define F        first
#define S        second
#define pnl      printf("\n")
#define sz(x)    (int)x.size()
#define sf(x)    scanf("%d",&x)
#define pf(x)    printf("%d\n",x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()
#define FOR(a,b) for(int i = a; i < b; ++i)

const db eps = 1e-12;
const db pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = inf * 2LL * inf;
const int mod = 1000 * 1000 * 1000 + 7;

int n, x;
int a[100005];
int b[100005];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &x);
    FOR(0, n) sf(a[i]);
    FOR(0, n) sf(b[i]);
    sort(a, a + n, greater<int>());
    sort(b, b + n);
    int mx = 0;
    int j = 0;
    for(int i = 0; i < n; ++i){
        while(j < n && a[i] + b[j] < x)
            ++j;
        if(a[i] + b[j] >= x)
            mx = max(mx, min(i + 1, n - j));
    }
    printf("%d %d\n", 1, mx);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<int,int> ii;

#define F        first
#define S        second
#define pnl      printf("\n")
#define sz(x)    (int)x.size()
#define sf(x)    scanf("%d",&x)
#define pf(x)    printf("%d\n",x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()
#define FOR(a,b) for(int i = a; i < b; ++i)

const db eps = 1e-12;
const db pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = inf * 2LL * inf;
const int mod = 1000 * 1000 * 1000 + 7;

int n, x;
int a[100005];
int b[100005];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &x);
    FOR(0, n) sf(a[i]);
    FOR(0, n) sf(b[i]);
    sort(a, a + n, greater<int>());
    sort(b, b + n);
    int mx = 0;
    int j = 0;
    for(int i = 0; i < n; ++i){
        while(j < n - 1 && a[i] + b[j] < x)
            ++j;
        if(a[i] + b[j] >= x)
            ++mx, ++j;
    }
    printf("%d %d\n", 1, mx);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<int,int> ii;

#define F        first
#define S        second
#define pnl      printf("\n")
#define sz(x)    (int)x.size()
#define sf(x)    scanf("%d",&x)
#define pf(x)    printf("%d\n",x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()
#define FOR(a,b) for(int i = a; i < b; ++i)

const db eps = 1e-12;
const db pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = inf * 2LL * inf;
const int mod = 1000 * 1000 * 1000 + 7;

int n, x;
int a[100005];
int b[100005];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &x);
    FOR(0, n) sf(a[i]);
    FOR(0, n) sf(b[i]);
    sort(a, a + n);
    sort(b, b + n);
    int mx = 0;
    int j = n - 1;
    for(int i = 0; i < n; ++i){
        while(j - 1 >= 0 && a[i] + b[j - 1] >= x)
            --j;
        mx = max(mx, min(n - i, n - j));
    }
    printf("%d %d\n", 1, mx);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
multiset< int> ma,mb;
vector<int> a,b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,x;
    cin>>n>>x;
    int i;
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        a.push_back(y);
    }
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        b.push_back(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(int y:a)
        ma.insert(y);
    for(int y:b)
        mb.insert(y);
    cout<<1<<" ";
    int f=a[0],s=b[0];
    for(int y:a)
    {
        int tf = x-y;
        auto it = lower_bound(b.begin(),b.end(),tf);
        if( abs(*it+ y-x) < abs(f+s-x) )
            f = y,s = *it;
        if(it!=b.begin())
        {
            it--;
            if( abs(*it+ y-x) < abs(f+s-x) )
                f = y,s = *it;
        }
    }
    auto it = ma.find(f);
    ma.erase(it);
    it = mb.find(s);
    mb.erase(it);

    int ans=1;
    while(true)
    {
        if(ma.size()==0)
            break;
        int val = *ma.rbegin();
        auto it = mb.lower_bound(x-val);
        int tem = *it;
        if(it==mb.end())
            break ;
        ans++;
        ma.erase(--ma.end());
        mb.erase(it);
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
multiset< int> ma,mb;
vector<int> a,b;
int main()
{
    int n,x;
    cin>>n>>x;
    int i;
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        a.push_back(y);
    }
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        b.push_back(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(int y:a)
        ma.insert(y);
    for(int y:b)
        mb.insert(y);
    cout<<1<<" ";
    int f=a[0],s=a[0];
    for(int y:a)
    {
        int tf = x-y;
        auto it = lower_bound(b.begin(),b.end(),tf);
        if( abs(*it+ y-x) < abs(f+s-x) )
            f = y,s = *it;
        if(it!=b.begin())
        {
            it--;
            if( abs(*it+ y-x) < abs(f+s-x) )
                f = y,s = *it;
        }
    }
    auto it = ma.find(f);
    ma.erase(it);
    it = mb.find(s);
    mb.erase(it);

    int ans=1;
    while(true)
    {
        if(ma.size()==0)
            break;
        int val = *ma.rbegin();
        auto it = mb.lower_bound(x-val);
        int tem = *it;
        if(it==mb.end())
            break ;
        ans++;
        ma.erase(--ma.end());
        mb.erase(it);
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
multiset< int> ma,mb;
vector<int> a,b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,x;
    cin>>n>>x;
    int i;
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        a.push_back(y);
    }
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        b.push_back(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(int y:a)
        ma.insert(y);
    for(int y:b)
        mb.insert(y);
    cout<<1<<" ";
    int f=a.back(),s=b.back();
    for(int y:a)
    {
        int tf = x-y;
        auto it = lower_bound(b.begin(),b.end(),tf);
        int tem  = *it;
        if( abs(*it+ y-x) < abs(f+s-x) )
            f = y,s = *it;
        if(it!=b.begin())
        {
            it--;
            if( abs(*it+ y-x) < abs(f+s-x)  && *it + y >=x)
                f = y,s = *it;
        }
    }
    auto it = ma.find(f);
    ma.erase(it);
    it = mb.find(s);
    mb.erase(it);

    int ans=1;
    while(true)
    {
        if(ma.size()==0)
            break;
        int val = *ma.rbegin();
        auto it = mb.lower_bound(x-val);
        int tem = *it;
        if(it==mb.end())
            break ;
        ans++;
        ma.erase(--ma.end());
        mb.erase(it);
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
multiset< int> ma,mb;
vector<int> a,b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,x;
    cin>>n>>x;
    int i;
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        a.push_back(y);
    }
    for(i=0;i<n;i++)
    {
        int y;
        cin>>y;
        b.push_back(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(int y:a)
        ma.insert(y);
    for(int y:b)
        mb.insert(y);
    cout<<1<<" ";
    int f=a[0],s=a[0];
    for(int y:a)
    {
        int tf = x-y;
        auto it = lower_bound(b.begin(),b.end(),tf);
        if( abs(*it+ y-x) < abs(f+s-x) )
            f = y,s = *it;
        if(it!=b.begin())
        {
            it--;
            if( abs(*it+ y-x) < abs(f+s-x) )
                f = y,s = *it;
        }
    }
    auto it = ma.find(f);
    ma.erase(it);
    it = mb.find(s);
    mb.erase(it);

    int ans=1;
    while(true)
    {
        if(ma.size()==0)
            break;
        int val = *ma.rbegin();
        auto it = mb.lower_bound(x-val);
        int tem = *it;
        if(it==mb.end())
            break ;
        ans++;
        ma.erase(--ma.end());
        mb.erase(it);
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#define ll  long long
#define ull unsigned long long
#define mpa make_pair
#define pb push_back
#define ff first
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("input.in","r",stdin),freopen("output.txt","w",stdout)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x)
#define gc getchar
using namespace std;
template<class T> inline void umax(T &a,T b) {
	if(a<b) a = b ;
}
template<class T> inline void umin(T &a,T b) {
	if(a>b) a = b ;
}
template<class T> inline T abs(T a) {
	return a>0 ? a : -a;
}
template<class T> inline T gcd(T a,T b) {
	return __gcd(a, b);
}
template<class T> inline T lcm(T a,T b) {
	return a/gcd(a,b)*b;
}
ll modpow(ll a,ll n,ll temp) {
	ll res=1,y=a;
	while(n>0) {
		if(n&1)res=(res*y)%temp;
		y=(y*y)%temp;
		n/=2;
	}
	return res%temp;
}
ll getbit(ll j,ll i){
	return ((i>>(j-1ll))&1ll);
}
//ll a[100005],n,dp[1000005]={0},b[1000005],c[100005],dp1[1000005],bit[100005];
//ll vis[100005];
//vector<ll> adj[100005];

#define sz(x) x.size()
ll ison(ll mask,ll pos) {
	return (mask&(1<<pos));
}
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
ll cbit(ll n) {
	ll k=0;
	while(n) n&=(n-1),k++;
	return k;
}
ll nbit(ll n) {
	ll k=0;
	while(n) n/=2,k++;
	return k;
}
ll mod=1e9+7;
int sgn(ll x) {
	return x < 0 ? -1 : !!x;
}
const double eps = 1e-7;
const double pi = acos(-1.0);
inline void inc(ll &x, ll y){
	x+=y;
	if(x>=mod)x-=mod;
}
inline void dec(ll &x, ll y){
	x-=y;
	if(x<0) x+=mod;
}
inline void chmax(ll &x,ll y){
	if(y>x) x=y;
}

inline void mulm(ll &x,ll y){
	x*=y;
	if(x>=mod) x-=mod;
}

//pair<ll,ll> a[1000005];
/*
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}*/

//ll tree[500005];

//vector<ll,pair<ll,ll> > b;
//vector<ll> adj[100005];

/*Tarjan incomplette
void dfs(ll s){
	vis[s]=1;
	for(ll i=0;i<adj[s].size();i++) if(!vis[adj[s][i]]) dfs(adj[s][i]);
    ofvs.pb(s);
}
void dfs2(ll s){
	vis[s]=1;
	if(wt[s]<optc){optn=0,optc=wt[s];}
	if(optc==wt[s]) optn++;
	for(ll i=0;i<rdj[s].size();i++) if(!vis[rdj[s][i]]) dfs2(rdj[s][i]);
}
*/
typedef pair<ll,pair<ll,ll> >ver;
//string s;
/*ll tree[200005];
ll a[100005];
void build(ll node,ll ss,ll se)
{
	if(ss==se) tree[node]=a[ss];
	else
	{
		ll mid=(ss+se)/2;
		build(2*node,ss,mid);
		build(2*node+1,mid+1,se);
        tree[node]=tree[2*node]&tree[2*node+1];
	}
}*/
/*void upd(ll node,ll ss,ll se,ll idx,ll val)
{
	if(ss==se)
	a[idx]=val,tree[node]=a[idx];
	else
	{
		ll mid=(ss+se)/2;
		if(ss<=idx && idx<=mid)
		upd(2*node,ss,mid,idx,val);
		else
		upd(2*node+1,mid+1,se,idx,val);
	    tree[node]=tree[node*2]+tree[node*2+1];
	}
}*/
/*ll query(ll node,ll ss,ll se,ll l,ll r)
{
	if(r<ss || se<l)
	return 0;
	if(l<=ss && se<=r)
	return tree[node];
	ll mid=(ss+se)/2;
	ll q1=query(node*2,ss,mid,l,r);
	ll q2=query(node*2+1,mid+1,se,l,r);
	return q1&q2;
}*/
/*ll pow(ll n){
	ll t=1,i=1;
	while(i<=n) t*=10;
	return t;
}*/
//stack<ll> help;
//ll dp[1ll<<11];

//ll csum[100005],b[100005],help[100005];
//vector<ll> adj[1005];
//vector<ll> ans;
/*ll kmp[1000005];
ll zee[1000005];
void kmpm(string p){
	ll i,j,k=0,l;
	kmp[0]=0;
	j=0;
	for(i=1;i<p.size();i++){
		while(k && p[i]!=p[k]) k=kmp[k-1];
		if(p[i]==p[k]) k++;
		kmp[i]=k;
	}
}
ll isp(ll n){
	ll f=1,i;
	for(i=2;i<=sqrt(n);i++) if(!(n%i)) return 0;
	return 1;
}*/
/*vector<ll> zFunction(vector<ll> &s) {
    int n = (ll) s.size();
    vector<ll> z (n);
    for (int i=1, l=0, r=0; i<n; ++i) {
        if (i <= r)
            z[i] = min (r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if (i+z[i]-1 > r)
            l = i,  r = i+z[i]-1;
    }
    return z;
}*/
//map<ll,ll> help;
/*ll chk(ll val,ll n,ll m){
	ll t=0,i;
	val--;
	for(i=1;i<=n;i++) t+=min(m,val/i);
	return t;
}*/

/*ll size[100005];
void init(ll n)
{for(int i=1;i<=n;i++) a[i]=i;}
ll root(ll x)
{
	while(a[x]!=x)
	{
		a[x]=a[a[x]];
		x=a[x];
	}
	return x;
}
ll u1(ll x,ll y)
{
	int p=root(x);
	int q=root(y);
	a[p]=a[q];
}
*/
/*ll tree[100005];
void update(ll idx, ll val){
	while(idx < 100005){
		tree[idx] = max(tree[idx], val);
		idx += (idx & (-idx));
	}
}
ll query(ll idx){
	ll ret = 0;
	while(idx > 0){
		ret = max(ret, tree[idx]);
		idx -= (idx & (-idx));
	}
	return ret;
}*/
//pair<char ,pair<ll,ll> >p[5005];[10004]
/*
//(topsort)
vector<ll> adj[100005];
vector<ll> fino;
ll vis[100005];
void dfs(ll v){
vis[v]=1;
for(ll i=0;i<adj[v].size();i++) if(!vis[adj[v][i]])dfs(adj[v][i]);
fino.pb(v);
}
*/

ll xo(ll i) {
	if ((i&3)==0) return i;
	if ((i&3)==1) return 1;
	if ((i&3)==2) return i+1;
	return 0;
}
//pair<ll,ll> p[10005];
/*ll a[100005];
ll bit[100005];
ll lmr[1000005];
ll pi[1000005];
ll ans[1000005];
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}
pair<pair<ll,ll>,ll> >query[1000005];
*/

//pair<ll,ll> a[1000005];
/*
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}*/

//ll tree[500005];

//vector<ll,pair<ll,ll> > b;
//vector<ll> adj[100005];

/*Tarjan incomplette
void dfs(ll s){
	vis[s]=1;
	for(ll i=0;i<adj[s].size();i++) if(!vis[adj[s][i]]) dfs(adj[s][i]);
    ofvs.pb(s);
}
void dfs2(ll s){
	vis[s]=1;
	if(wt[s]<optc){optn=0,optc=wt[s];}
	if(optc==wt[s]) optn++;
	for(ll i=0;i<rdj[s].size();i++) if(!vis[rdj[s][i]]) dfs2(rdj[s][i]);
}
*/
typedef pair<ll,pair<ll,ll> >ver;
//string s;
/*ll tree[200005];
ll a[100005];
void build(ll node,ll ss,ll se)
{
	if(ss==se) tree[node]=a[ss];
	else
	{
		ll mid=(ss+se)/2;
		build(2*node,ss,mid);
		build(2*node+1,mid+1,se);
        tree[node]=tree[2*node]&tree[2*node+1];
	}
}*/
/*void upd(ll node,ll ss,ll se,ll idx,ll val)
{
	if(ss==se)
	a[idx]=val,tree[node]=a[idx];
	else
	{
		ll mid=(ss+se)/2;
		if(ss<=idx && idx<=mid)
		upd(2*node,ss,mid,idx,val);
		else
		upd(2*node+1,mid+1,se,idx,val);
	    tree[node]=tree[node*2]+tree[node*2+1];
	}
}*/
/*ll query(ll node,ll ss,ll se,ll l,ll r)
{
	if(r<ss || se<l)
	return 0;
	if(l<=ss && se<=r)
	return tree[node];
	ll mid=(ss+se)/2;
	ll q1=query(node*2,ss,mid,l,r);
	ll q2=query(node*2+1,mid+1,se,l,r);
	return q1&q2;
}*/
/*void update(ll node,ll s,ll e,ll idx,ll val){
	if(s==e){
		tree[node]=val;
		return;
	}
	else{
		ll mid=(s+e)/2;
		if(s<=idx && idx<=mid) update(node*2,s,mid,idx,val);
		else update(node*2+1,mid+1,e,idx,val);
		tree[node]=max(tree[2*node],tree[2*node+1]);
		return ;
	}
}*/
/*ll pow(ll n){
	ll t=1,i=1;
	while(i<=n) t*=10;
	return t;
}*/
//stack<ll> help;
//ll dp[1ll<<11];

//ll csum[100005],b[100005],help[100005];
//vector<ll> adj[1005];
//vector<ll> ans;
/*ll kmp[1000005];
ll zee[1000005];
void kmpm(string p){
	ll i,j,k=0,l;
	kmp[0]=0;
	j=0;
	for(i=1;i<p.size();i++){
		while(k && p[i]!=p[k]) k=kmp[k-1];
		if(p[i]==p[k]) k++;
		kmp[i]=k;
	}
}
ll isp(ll n){
	ll f=1,i;
	for(i=2;i<=sqrt(n);i++) if(!(n%i)) return 0;
	return 1;
}*/
/*vector<ll> zFunction(vector<ll> &s) {
    int n = (ll) s.size();
    vector<ll> z (n);
    for (int i=1, l=0, r=0; i<n; ++i) {
        if (i <= r)
            z[i] = min (r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if (i+z[i]-1 > r)
            l = i,  r = i+z[i]-1;
    }
    return z;
}*/
//map<ll,ll> help;
/*ll chk(ll val,ll n,ll m){
	ll t=0,i;
	val--;
	for(i=1;i<=n;i++) t+=min(m,val/i);
	return t;
}*/

/*ll size[100005];
void init(ll n)
{for(int i=1;i<=n;i++) a[i]=i;}
ll root(ll x)
{
	while(a[x]!=x)
	{
		a[x]=a[a[x]];
		x=a[x];
	}
	return x;
}
ll u1(ll x,ll y)
{
	int p=root(x);
	int q=root(y);
	a[p]=a[q];
}
*/
/*ll tree[100005];
void update(ll idx, ll val){
	while(idx < 100005){
		tree[idx] = max(tree[idx], val);
		idx += (idx & (-idx));
	}
}
ll query(ll idx){
	ll ret = 0;
	while(idx > 0){
		ret = max(ret, tree[idx]);
		idx -= (idx & (-idx));
	}
	return ret;
}*/
//pair<char ,pair<ll,ll> >p[5005];[10004]
/*
//(topsort)
vector<ll> adj[100005];
vector<ll> fino;
ll vis[100005];
void dfs(ll v){
vis[v]=1;
for(ll i=0;i<adj[v].size();i++) if(!vis[adj[v][i]])dfs(adj[v][i]);
fino.pb(v);
}
*/
/*ll anc[20][100005];
ll d[100005];
vector<ll> adj[100005];
void dfs(ll v,ll p){
    for(ll i=0;i<adj[v].size();i++){
        if(adj[v][i]!=p){
            d[adj[v][i]]=d[v]+1;
            anc[0][adj[v][i]]=v;
            dfs(adj[v][i],v);
        }
    }
}

ll lca(ll a,ll b){
    if(d[a]>d[b])swap(a,b);
    ll diff=d[b]-d[a];
    for(ll i=0;i<20;i++)if(diff&(1<<i))b=anc[i][b];
    for(ll i=19;i>=0;i--){
        if(anc[i][a]!=anc[i][b]) a=anc[i][a],b=anc[i][b];
    }
    if(a==b)return a;
    return anc[0][a];
}
ll dist(ll a,ll b){
    ll l=lca(a,b);
    return d[a]+d[b]-2*d[l];
}*/
//pair<ll,ll> p[10005];
/*ll a[100005];
ll bit[100005];
ll lmr[1000005];
ll pi[1000005];
ll ans[1000005];
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}
pair<pair<ll,ll>,ll> >query[1000005];
*/

//pair<ll,ll> a[205];
//template for #trie
//vector<ll> adj[100005],adjr[100005];
//ll a[100005],dp[100005];
/*
ll block;
ll gb(ll pos) {
	return (pos-1)/block;
}
bool comp(pair<pii,ll> a, pair<pii,ll> b){
    ll b1 = gb(a.ff.ff);
    ll b2 = gb(b.ff.ss);
    if(b1 != b2)   return b1 < b2;
    return a.ss < b.ss;
}*/
ll a[100005],b[100005];
multiset<ll> x;
int main(){
  ll v,n,k,t,q,p,d,r,m,i,j;
  cin>>n>>v;
  for(ll i=1;i<=n;i++)cin>>a[i];
  sort(a+1,a+n+1);
  for(ll i=1;i<=n;i++){
  	cin>>b[i];
  	x.insert(b[i]);
  }
  cout<<1<<" ";
  ll cnt=0;
  for(ll i=n;i>=1;i--){
  	multiset<ll>::iterator it=x.lower_bound(v-a[i]);
  	if(it==x.end()) continue;
  	x.erase(it);
  	cnt++;
  }
  cout<<cnt;
}


#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#define ll  long long
#define ull unsigned long long
#define mpa make_pair
#define pb push_back
#define ff first
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("input.in","r",stdin),freopen("output.txt","w",stdout)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x)
#define gc getchar
using namespace std;
template<class T> inline void umax(T &a,T b) {
	if(a<b) a = b ;
}
template<class T> inline void umin(T &a,T b) {
	if(a>b) a = b ;
}
template<class T> inline T abs(T a) {
	return a>0 ? a : -a;
}
template<class T> inline T gcd(T a,T b) {
	return __gcd(a, b);
}
template<class T> inline T lcm(T a,T b) {
	return a/gcd(a,b)*b;
}
ll modpow(ll a,ll n,ll temp) {
	ll res=1,y=a;
	while(n>0) {
		if(n&1)res=(res*y)%temp;
		y=(y*y)%temp;
		n/=2;
	}
	return res%temp;
}
ll getbit(ll j,ll i){
	return ((i>>(j-1ll))&1ll);
}
//ll a[100005],n,dp[1000005]={0},b[1000005],c[100005],dp1[1000005],bit[100005];
//ll vis[100005];
//vector<ll> adj[100005];

#define sz(x) x.size()
ll ison(ll mask,ll pos) {
	return (mask&(1<<pos));
}
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
ll cbit(ll n) {
	ll k=0;
	while(n) n&=(n-1),k++;
	return k;
}
ll nbit(ll n) {
	ll k=0;
	while(n) n/=2,k++;
	return k;
}
ll mod=1e9+7;
int sgn(ll x) {
	return x < 0 ? -1 : !!x;
}
const double eps = 1e-7;
const double pi = acos(-1.0);
inline void inc(ll &x, ll y){
	x+=y;
	if(x>=mod)x-=mod;
}
inline void dec(ll &x, ll y){
	x-=y;
	if(x<0) x+=mod;
}
inline void chmax(ll &x,ll y){
	if(y>x) x=y;
}

inline void mulm(ll &x,ll y){
	x*=y;
	if(x>=mod) x-=mod;
}

//pair<ll,ll> a[1000005];
/*
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}*/

//ll tree[500005];

//vector<ll,pair<ll,ll> > b;
//vector<ll> adj[100005];

/*Tarjan incomplette
void dfs(ll s){
	vis[s]=1;
	for(ll i=0;i<adj[s].size();i++) if(!vis[adj[s][i]]) dfs(adj[s][i]);
    ofvs.pb(s);
}
void dfs2(ll s){
	vis[s]=1;
	if(wt[s]<optc){optn=0,optc=wt[s];}
	if(optc==wt[s]) optn++;
	for(ll i=0;i<rdj[s].size();i++) if(!vis[rdj[s][i]]) dfs2(rdj[s][i]);
}
*/
typedef pair<ll,pair<ll,ll> >ver;
//string s;
/*ll tree[200005];
ll a[100005];
void build(ll node,ll ss,ll se)
{
	if(ss==se) tree[node]=a[ss];
	else
	{
		ll mid=(ss+se)/2;
		build(2*node,ss,mid);
		build(2*node+1,mid+1,se);
        tree[node]=tree[2*node]&tree[2*node+1];
	}
}*/
/*void upd(ll node,ll ss,ll se,ll idx,ll val)
{
	if(ss==se)
	a[idx]=val,tree[node]=a[idx];
	else
	{
		ll mid=(ss+se)/2;
		if(ss<=idx && idx<=mid)
		upd(2*node,ss,mid,idx,val);
		else
		upd(2*node+1,mid+1,se,idx,val);
	    tree[node]=tree[node*2]+tree[node*2+1];
	}
}*/
/*ll query(ll node,ll ss,ll se,ll l,ll r)
{
	if(r<ss || se<l)
	return 0;
	if(l<=ss && se<=r)
	return tree[node];
	ll mid=(ss+se)/2;
	ll q1=query(node*2,ss,mid,l,r);
	ll q2=query(node*2+1,mid+1,se,l,r);
	return q1&q2;
}*/
/*ll pow(ll n){
	ll t=1,i=1;
	while(i<=n) t*=10;
	return t;
}*/
//stack<ll> help;
//ll dp[1ll<<11];

//ll csum[100005],b[100005],help[100005];
//vector<ll> adj[1005];
//vector<ll> ans;
/*ll kmp[1000005];
ll zee[1000005];
void kmpm(string p){
	ll i,j,k=0,l;
	kmp[0]=0;
	j=0;
	for(i=1;i<p.size();i++){
		while(k && p[i]!=p[k]) k=kmp[k-1];
		if(p[i]==p[k]) k++;
		kmp[i]=k;
	}
}
ll isp(ll n){
	ll f=1,i;
	for(i=2;i<=sqrt(n);i++) if(!(n%i)) return 0;
	return 1;
}*/
/*vector<ll> zFunction(vector<ll> &s) {
    int n = (ll) s.size();
    vector<ll> z (n);
    for (int i=1, l=0, r=0; i<n; ++i) {
        if (i <= r)
            z[i] = min (r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if (i+z[i]-1 > r)
            l = i,  r = i+z[i]-1;
    }
    return z;
}*/
//map<ll,ll> help;
/*ll chk(ll val,ll n,ll m){
	ll t=0,i;
	val--;
	for(i=1;i<=n;i++) t+=min(m,val/i);
	return t;
}*/

/*ll size[100005];
void init(ll n)
{for(int i=1;i<=n;i++) a[i]=i;}
ll root(ll x)
{
	while(a[x]!=x)
	{
		a[x]=a[a[x]];
		x=a[x];
	}
	return x;
}
ll u1(ll x,ll y)
{
	int p=root(x);
	int q=root(y);
	a[p]=a[q];
}
*/
/*ll tree[100005];
void update(ll idx, ll val){
	while(idx < 100005){
		tree[idx] = max(tree[idx], val);
		idx += (idx & (-idx));
	}
}
ll query(ll idx){
	ll ret = 0;
	while(idx > 0){
		ret = max(ret, tree[idx]);
		idx -= (idx & (-idx));
	}
	return ret;
}*/
//pair<char ,pair<ll,ll> >p[5005];[10004]
/*
//(topsort)
vector<ll> adj[100005];
vector<ll> fino;
ll vis[100005];
void dfs(ll v){
vis[v]=1;
for(ll i=0;i<adj[v].size();i++) if(!vis[adj[v][i]])dfs(adj[v][i]);
fino.pb(v);
}
*/

ll xo(ll i) {
	if ((i&3)==0) return i;
	if ((i&3)==1) return 1;
	if ((i&3)==2) return i+1;
	return 0;
}
//pair<ll,ll> p[10005];
/*ll a[100005];
ll bit[100005];
ll lmr[1000005];
ll pi[1000005];
ll ans[1000005];
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}
pair<pair<ll,ll>,ll> >query[1000005];
*/

//pair<ll,ll> a[1000005];
/*
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}*/

//ll tree[500005];

//vector<ll,pair<ll,ll> > b;
//vector<ll> adj[100005];

/*Tarjan incomplette
void dfs(ll s){
	vis[s]=1;
	for(ll i=0;i<adj[s].size();i++) if(!vis[adj[s][i]]) dfs(adj[s][i]);
    ofvs.pb(s);
}
void dfs2(ll s){
	vis[s]=1;
	if(wt[s]<optc){optn=0,optc=wt[s];}
	if(optc==wt[s]) optn++;
	for(ll i=0;i<rdj[s].size();i++) if(!vis[rdj[s][i]]) dfs2(rdj[s][i]);
}
*/
typedef pair<ll,pair<ll,ll> >ver;
//string s;
/*ll tree[200005];
ll a[100005];
void build(ll node,ll ss,ll se)
{
	if(ss==se) tree[node]=a[ss];
	else
	{
		ll mid=(ss+se)/2;
		build(2*node,ss,mid);
		build(2*node+1,mid+1,se);
        tree[node]=tree[2*node]&tree[2*node+1];
	}
}*/
/*void upd(ll node,ll ss,ll se,ll idx,ll val)
{
	if(ss==se)
	a[idx]=val,tree[node]=a[idx];
	else
	{
		ll mid=(ss+se)/2;
		if(ss<=idx && idx<=mid)
		upd(2*node,ss,mid,idx,val);
		else
		upd(2*node+1,mid+1,se,idx,val);
	    tree[node]=tree[node*2]+tree[node*2+1];
	}
}*/
/*ll query(ll node,ll ss,ll se,ll l,ll r)
{
	if(r<ss || se<l)
	return 0;
	if(l<=ss && se<=r)
	return tree[node];
	ll mid=(ss+se)/2;
	ll q1=query(node*2,ss,mid,l,r);
	ll q2=query(node*2+1,mid+1,se,l,r);
	return q1&q2;
}*/
/*void update(ll node,ll s,ll e,ll idx,ll val){
	if(s==e){
		tree[node]=val;
		return;
	}
	else{
		ll mid=(s+e)/2;
		if(s<=idx && idx<=mid) update(node*2,s,mid,idx,val);
		else update(node*2+1,mid+1,e,idx,val);
		tree[node]=max(tree[2*node],tree[2*node+1]);
		return ;
	}
}*/
/*ll pow(ll n){
	ll t=1,i=1;
	while(i<=n) t*=10;
	return t;
}*/
//stack<ll> help;
//ll dp[1ll<<11];

//ll csum[100005],b[100005],help[100005];
//vector<ll> adj[1005];
//vector<ll> ans;
/*ll kmp[1000005];
ll zee[1000005];
void kmpm(string p){
	ll i,j,k=0,l;
	kmp[0]=0;
	j=0;
	for(i=1;i<p.size();i++){
		while(k && p[i]!=p[k]) k=kmp[k-1];
		if(p[i]==p[k]) k++;
		kmp[i]=k;
	}
}
ll isp(ll n){
	ll f=1,i;
	for(i=2;i<=sqrt(n);i++) if(!(n%i)) return 0;
	return 1;
}*/
/*vector<ll> zFunction(vector<ll> &s) {
    int n = (ll) s.size();
    vector<ll> z (n);
    for (int i=1, l=0, r=0; i<n; ++i) {
        if (i <= r)
            z[i] = min (r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if (i+z[i]-1 > r)
            l = i,  r = i+z[i]-1;
    }
    return z;
}*/
//map<ll,ll> help;
/*ll chk(ll val,ll n,ll m){
	ll t=0,i;
	val--;
	for(i=1;i<=n;i++) t+=min(m,val/i);
	return t;
}*/

/*ll size[100005];
void init(ll n)
{for(int i=1;i<=n;i++) a[i]=i;}
ll root(ll x)
{
	while(a[x]!=x)
	{
		a[x]=a[a[x]];
		x=a[x];
	}
	return x;
}
ll u1(ll x,ll y)
{
	int p=root(x);
	int q=root(y);
	a[p]=a[q];
}
*/
/*ll tree[100005];
void update(ll idx, ll val){
	while(idx < 100005){
		tree[idx] = max(tree[idx], val);
		idx += (idx & (-idx));
	}
}
ll query(ll idx){
	ll ret = 0;
	while(idx > 0){
		ret = max(ret, tree[idx]);
		idx -= (idx & (-idx));
	}
	return ret;
}*/
//pair<char ,pair<ll,ll> >p[5005];[10004]
/*
//(topsort)
vector<ll> adj[100005];
vector<ll> fino;
ll vis[100005];
void dfs(ll v){
vis[v]=1;
for(ll i=0;i<adj[v].size();i++) if(!vis[adj[v][i]])dfs(adj[v][i]);
fino.pb(v);
}
*/
/*ll anc[20][100005];
ll d[100005];
vector<ll> adj[100005];
void dfs(ll v,ll p){
    for(ll i=0;i<adj[v].size();i++){
        if(adj[v][i]!=p){
            d[adj[v][i]]=d[v]+1;
            anc[0][adj[v][i]]=v;
            dfs(adj[v][i],v);
        }
    }
}

ll lca(ll a,ll b){
    if(d[a]>d[b])swap(a,b);
    ll diff=d[b]-d[a];
    for(ll i=0;i<20;i++)if(diff&(1<<i))b=anc[i][b];
    for(ll i=19;i>=0;i--){
        if(anc[i][a]!=anc[i][b]) a=anc[i][a],b=anc[i][b];
    }
    if(a==b)return a;
    return anc[0][a];
}
ll dist(ll a,ll b){
    ll l=lca(a,b);
    return d[a]+d[b]-2*d[l];
}*/
//pair<ll,ll> p[10005];
/*ll a[100005];
ll bit[100005];
ll lmr[1000005];
ll pi[1000005];
ll ans[1000005];
void upd(ll ind,ll val){
    if(ind==0) return;
    while(ind<=n){
        bit[ind]+=val;
        ind+=(ind&-ind);
    }
}
ll qu(ll ind){
  ll k=0; while(ind>0){
    k+=bit[ind];
    ind-=(ind&-ind);
  }
    return k;
}
pair<pair<ll,ll>,ll> >query[1000005];
*/

//pair<ll,ll> a[205];
//template for #trie
//vector<ll> adj[100005],adjr[100005];
//ll a[100005],dp[100005];
/*
ll block;
ll gb(ll pos) {
	return (pos-1)/block;
}
bool comp(pair<pii,ll> a, pair<pii,ll> b){
    ll b1 = gb(a.ff.ff);
    ll b2 = gb(b.ff.ss);
    if(b1 != b2)   return b1 < b2;
    return a.ss < b.ss;
}*/
ll a[100005],b[100005];
int main(){
  ll x,n,k,t,q,p,d,r,m,i,j;
  cin>>n>>x;
  ll mi=mod;
  for(ll i=1;i<=n;i++)cin>>a[i];
  for(ll i=1;i<=n;i++)cin>>b[i];
  cout<<1<<" ";
  sort(a+1,a+n+1);
  sort(b+1,b+n+1);
  for(ll i=1;i<=n;i++){
  	ll ind=lower_bound(b+1,b+n+1,x-a[i])-b;
  	if(ind<=n) mi=min(mi,a[i]+b[ind]);
  }
  for(ll i=1;i<=n;i++){
  	ll ind=lower_bound(b+1,b+n+1,mi-a[i])-b;
  	if(ind<=n){
  	if(a[i]+b[ind]==mi){
	  	a[i]=-1;
	  	b[ind]=-1;
	  	break;
	  }
	}
  }

  sort(a+1,a+n+1);
  sort(b+1,b+n+1);

  vector<ll> h;
  for(ll i=1;i<=n;i++) if(a[i]+b[i]>=0) h.pb(a[i]+b[i]);
  sort(all(h));
  ll ans=0;
  for(i=0;i<h.size();i++)ans+=(h[i]>=mi);
  cout<<ans+1ll;
}


#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()

int main(){
    int n, x, best = 1, worst = 0;
    cin >> n >> x;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    sort(ALL(a));
    reverse(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    int i = 0, j = n-1;
    while (j - i >= 1){
        while (a[i] + b[j] < x)
            j -= 1;
        worst += 1;
        i += 1;
    }
    cout << best << " " << worst + 1 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()

int main(){
    int n, x, best = 1, worst = 0;
    cin >> n >> x;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    sort(ALL(a));
    reverse(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    int i = 0, j = n-1;
    while (j - i >= 0){
        while (a[i] + b[j] < x && j >= i)
            j -= 1;
        worst += 1;
        i += 1;
    }
    cout << best << " " << worst << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()

int main(){
    int n, x, best = 1, worst = 0;
    cin >> n >> x;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    sort(ALL(a));
    reverse(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    int i = 0, j = n-1;
    while (j - i >= 1){
        while (a[i] + b[j] < x)
            j -= 1;
        worst += 1;
        i += 1;
    }
    if (a[i] + b[j] >= x)
        worst += 1;
    cout << best << " " << worst << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define say		cout,

int main(){
    int n, x, best = 1, worst = 0;
    cin >> n >> x;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    sort(ALL(a));
    reverse(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));

    /*for (int i = 0; i < n; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < n; i++){
        cout << b[i] << " ";
    }
    cout << endl;*/
    int i = 0, j = n-1;
    while (i < n && j >= 0){
        while (a[i] + b[j] < x && j >= 0)
            j -= 1;
        if (a[i] + b[j] >= x)
            worst += 1;
        i += 1;
    }
    cout << best << " " << worst << endl;
    say best, worst;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()

int main(){
    cin.tie(null);
    ios_base::sync_with_stdio(false);
    int n, x, best = 1, worst = 0;
    cin >> n >> x;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    multiset <int> s;
    for (int i = 0; i < n; i++){
        s.insert(b[i]);
    }

    for (int i = 0; i < n; i++){
        int y = a[i];
        auto it = s.lower_bound(x - y);
        if (it != s.end()){
            worst += 1;
            s.erase(it);
        }
    }
    cout << best << " " << worst << endl;
    return 0;
}