#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	vector<int> v;
	int n;
	cin>>n;
	int flag=0;
	while(n--)
	{
		int s,e;
		cin>>s>>e;
		if(flag==1)
			continue;
		if(v.size()==0)
		{
			v.push_back(s);
			v.push_back(e);
			continue;
		}
		sort(v.begin(),v.end());
		int l=v.size();
		if(s<v[l-1]&&e>=v[l-1])
			flag=1;
		else if(s<v[0]&&e>v[0])
			flag=1;
		else
		{
			v.push_back(s);
			v.push_back(e);
		}
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int tv[100000000];
int main()
{
	memset(tv,0,sizeof(tv));
	int n;
	cin>>n;
	int flag=0;
	while(n--)
	{
		int s,e;
		cin>>s>>e;
		if(flag==1)
			continue;
		for(int i=s;i<=e;i++)
		{
			if(tv[i]==1&&i!=s)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			for(int i=s;i<=e;i++)
				tv[i]=1;
		}
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct node
{
	int start;
	int end;
};
bool cmp(const node &n1,const node &n2)
{
	if(n1.start!=n2.start)
		return n1.start<n2.start;
	else
		return n1.end<n2.end;
}
bool isNotOverlapping(const node &n1,const node &n2)
{
	return n2.start > n1.end;
}
vector<node> v;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		node nn;
		cin>>nn.start>>nn.end;
		v.push_back(nn);
	}
	sort(v.begin(),v.end(),cmp);
	//for(int i=0;i<v.size();i++)
	//	cout<<v[i].start<<" "<<v[i].end<<endl;
	node lasttva,lasttvb;
	lasttva.start=lasttva.end=lasttvb.start=lasttvb.end=-1;
	for(int i=0;i<v.size();i++)
	{
		if(isNotOverlapping(lasttva, v[i]))
		{
			lasttva = v[i];
			continue;
		}
		if(isNotOverlapping(lasttvb, v[i]))
		{
			lasttvb = v[i];
			continue;
		}
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct node
{
	int start;
	int end;
};
bool cmp(const node &n1,const node &n2)
{
	return n1.start<n2.start;
}
vector<node> v;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		node nn;
		cin>>nn.start>>nn.end;
		v.push_back(nn);
	}
	sort(v.begin(),v.end(),cmp);
	int flag=0,last=-1;
	for(int i=1;i<v.size();i++)
	{
		if(v[i-1].end>last)
			last=v[i-1].end;
		if(last>v[i].start)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int tv1[100000001];
int tv2[100000001];
int main()
{
	memset(tv1,0,sizeof(tv1));
	memset(tv2,0,sizeof(tv2));
	int n;
	cin>>n;
	int flag=0;
	while(n--)
	{
		int s,e;
		int note1=0,note2=0,pos1,pos2;
		cin>>s>>e;
		for(int i=s;i<=e;i++)
		{
			if(tv1[i]==1)
			{
				note1=1;
				pos1=i;
			}
			if(tv2[i]==1)
			{
				note2=1;
				pos2=i;
			}
		}
		if(note1==0&&note2==0)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else if(note1==1&&note2==0&&pos1==s)
		{
			for(int i=s;i<=e;i++)
				tv2[i]=1;
		}
		else if(note1==0&&note2==1&&pos2==s)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else
			flag=1;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct node
{
	int start;
	int end;
};
bool cmp(const node &n1,const node &n2)
{
	return n1.start<n2.start;
}
vector<node> v;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		node nn;
		cin>>nn.start>>nn.end;
		v.push_back(nn);
	}
	sort(v.begin(),v.end(),cmp);
	int flag=0;
	for(int i=1;i<v.size();i++)
	{
		if(v[i-1].end>v[i].start)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int tv1[10000001];
int tv2[10000001];
int main()
{
	memset(tv1,0,sizeof(tv1));
	memset(tv2,0,sizeof(tv2));
	int n;
	cin>>n;
	int flag=0;
	while(n--)
	{
		int s,e;
		int note1=0,note2=0,pos1,pos2;
		cin>>s>>e;
		if(flag==1)
			continue;
		for(int i=s;i<=e;i++)
		{
			if(tv1[i]==1)
			{
				note1=1;
				pos1=i;
			}
			if(tv2[i]==1)
			{
				note2=1;
				pos2=i;
			}
			if(note1==1&&note2==2)
			{
				flag==1;
				break;
			}
			else if(note1==1&&note2==0&&pos1!=s)
			{
				flag==1;
				break;
			}
			else if(note1==0&&note2==1&&pos2!=s)
			{
				flag==1;
				break;
			}
		}
		if(note1==0&&note2==0)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else if(note1==1&&note2==0&&pos1==s)
		{
			for(int i=s;i<=e;i++)
				tv2[i]=1;
		}
		else if(note1==0&&note2==1&&pos2==s)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else
			flag=1;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long flag=0,max,min;
	for(int i=0;i<n;i++)
	{
		long long s,e;
		cin>>s>>e;
		if(flag==1)
			continue;
		if(i==0)
		{
			max=e;
			min=s;
			continue;
		}
		if(s<max&&e>=max)
			flag=1;
		else if(s<=min&&e>min)
			flag=1;
		else if(s>=min&&e<=max)
			flag=1;
		else if(s>=max)
			max=e;
		else if(e<=min)
			min=s;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct node
{
	int start;
	int end;
};
bool cmp(const node &n1,const node &n2)
{
	if(n1.start!=n2.start)
		return n1.start<n2.start;
	else
		return n1.end<n2.end;
}
bool isNotOverlapping(const node &n1,const node &n2)
{
	return n2.start > n1.end;
}
vector<node> v;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		node nn;
		cin>>nn.start>>nn.end;
		v.push_back(nn);
	}
	sort(v.begin(),v.end(),cmp);
	//for(int i=0;i<v.size();i++)
	//	cout<<v[i].start<<" "<<v[i].end<<endl;
	int flag=0,last=-1;
	node lasttva,lasttvb;
	lasttva.start=lasttva.end=lasttvb.start=lasttvb.end=-1;
	for(int i=1;i<v.size();i++)
	{
		if(isNotOverlapping(lasttva, v[i]))
		{
			lasttva = v[i];
			continue;
		}
		if(isNotOverlapping(lasttvb, v[i]))
		{
			lasttvb = v[i];
			continue;
		}
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int flag=0,max,min;
	for(int i=0;i<n;i++)
	{
		int s,e;
		cin>>s>>e;
		if(flag==1)
			continue;
		if(i==0)
		{
			max=e;
			min=s;
			continue;
		}
		if(s<max&&e>=max)
		{
			flag=1;
		}
		else if(s<min&&e>min)
			flag=1;
		else if(s>=max)
			max=e;
		else if(e<=min)
			min=s;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int tv1[99999999];
int tv2[99999999];
int main()
{
	memset(tv1,0,sizeof(tv1));
	memset(tv2,0,sizeof(tv2));
	int n;
	cin>>n;
	int flag=0;
	while(n--)
	{
		int s,e;
		int note1=0,note2=0,pos1,pos2;
		cin>>s>>e;
		if(flag==1)
			continue;
		for(int i=s;i<=e;i++)
		{
			if(tv1[i]==1)
			{
				note1=1;
				pos1=i;
			}
			if(tv2[i]==1)
			{
				note2=1;
				pos2=i;
			}
			if(note1==1&&note2==2)
			{
				flag==1;
				break;
			}
			else if(note1==1&&note2==0&&pos1!=s)
			{
				flag==1;
				break;
			}
			else if(note1==0&&note2==1&&pos2!=s)
			{
				flag==1;
				break;
			}
		}
		if(note1==0&&note2==0)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else if(note1==1&&note2==0&&pos1==s)
		{
			for(int i=s;i<=e;i++)
				tv2[i]=1;
		}
		else if(note1==0&&note2==1&&pos2==s)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else
			flag=1;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long flag=0,max,min;
	for(int i=0;i<n;i++)
	{
		long long s,e;
		cin>>s>>e;
		if(flag==1)
			continue;
		if(i==0)
		{
			max=e;
			min=s;
			continue;
		}
		if(s<max&&e>=max)
		{
			flag=1;
		}
		else if(s<min&&e>min)
			flag=1;
		else if(s>=max)
			max=e;
		else if(e<=min)
			min=s;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long flag=0,max,min;
	for(int i=0;i<n;i++)
	{
		long long s,e;
		cin>>s>>e;
		if(flag==1)
			continue;
		if(i==0)
		{
			max=e;
			min=s;
			continue;
		}
		if(s<max&&s>=min)
			flag=1;
		else if(e>min&&e<=max)
			flag=1;
		else if(s<=min&&e>=max)
			flag=1;
		else if(s>=max)
			max=e;
		else if(e<=min)
			min=s;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int tv1[10000001];
int tv2[10000001];
int main()
{
	memset(tv1,0,sizeof(tv1));
	memset(tv2,0,sizeof(tv2));
	int n;
	cin>>n;
	int flag=0;
	while(n--)
	{
		int s,e;
		int note1=0,note2=0,pos1,pos2;
		cin>>s>>e;
		for(int i=s;i<=e;i++)
		{
			if(tv1[i]==1)
			{
				note1=1;
				pos1=i;
			}
			if(tv2[i]==1)
			{
				note2=1;
				pos2=i;
			}
		}
		if(note1==0&&note2==0)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else if(note1==1&&note2==0&&pos1==s)
		{
			for(int i=s;i<=e;i++)
				tv2[i]=1;
		}
		else if(note1==0&&note2==1&&pos2==s)
		{
			for(int i=s;i<=e;i++)
				tv1[i]=1;
		}
		else
			flag=1;
	}
	if(flag==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
    int n;
    int a;
    bool dali=true;
    cin>>n;
    vector<pair<int, int> > vreme;
    vreme.clear();
    for(int j=0;j<n;j++)
        {
          pair<int, int>par;
          scanf ("%d",&a);
          par.first=a;
          scanf ("%d",&a);
          par.second=a;
          vreme.push_back(par);
        }
    sort(vreme.begin(),vreme.end());

    int edno= vreme[0].second;
    int vtoro;
    int k=1;
    int j1=1;
    while(dali && j1<n)
        {
            // cout<<"tuka "<<vreme[j].first<<" "<<vreme[j].second<<" j"<<j<<endl;
            if(k==1)
            {
                if(vreme[j1].first<=edno)
                {
                    k=2;
                    vtoro=max(vreme[j1].second,edno);
                    edno=min(vreme[j1].second,edno);
                }
                else
                {
                    edno= vreme[j1].second;
                }
            }
            else
            if(k==2)
            {
                if(vreme[j1].first<=edno)
                {
                    cout<<"NO";
                    dali=false;
                }
                else
                {
                   if(vreme[j1].first<=vtoro)
                    {
                        vtoro=max(vreme[j1].second,vtoro);
                        edno=min(vreme[j1].second,vtoro);
                    }
                    else
                    {
                        k=1;
                        edno= vreme[j1].second;
                    }
                }
             }
             j1++;
        }

       if(dali)cout<<"YES";

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
    int n;
    int a;
    bool dali=true;
    cin>>n;
    vector<pair<int, int> > vreme;
    vreme.clear();
    for(int j=0;j<n;j++)
        {
          pair<int, int>par;
          scanf ("%d",&a);
          par.first=a;
          scanf ("%d",&a);
          par.second=a;
          vreme.push_back(par);
        }
    sort(vreme.begin(),vreme.end());

    int edno= vreme[0].second;
    int vtoro;
    int k=1;
    int j1=1;
    while(dali && j1<n)
        {
            // cout<<"tuka "<<vreme[j].first<<" "<<vreme[j].second<<" j"<<j<<endl;
            if(k==1)
            {
                if(vreme[j1].first<=edno)
                {
                    k=2;
                    vtoro=max(vreme[j1].second,edno);
                    edno=min(vreme[j1].second,edno);
                }
                else
                {
                    edno= vreme[j1].second;
                }
            }
            else
            if(k==2)
            {
                if(vreme[j1].first<=edno)
                {
                    cout<<"NO";
                    dali=false;
                }
                else
                {
                   if(vreme[j1].first<=vtoro)
                    {
                        edno=min(vreme[j1].second,vtoro);
                        vtoro=max(vreme[j1].second,vtoro);
                    }
                    else
                    {
                        k=1;
                        edno= vreme[j1].second;
                    }
                }
             }
             j1++;
        }

       if(dali)cout<<"YES";

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
    int n;
    int a;
    bool dali=true;
    cin>>n;
    vector<pair<int, int> > vreme;
    vreme.clear();
    for(int j=0;j<n;j++)
        {
          pair<int, int>par;
          scanf ("%d",&a);
          par.first=a;
          scanf ("%d",&a);
          par.second=a;
          vreme.push_back(par);
        }
    sort(vreme.begin(),vreme.end());

    int edno= vreme[0].second;
    int vtoro;
    int k=1;
    int j1=0;
    while(dali && j1<n)
        {
            // cout<<"tuka "<<vreme[j].first<<" "<<vreme[j].second<<" j"<<j<<endl;
            if(k==1)
            {
                if(vreme[j1].first<=edno)
                {
                    k=2;
                    vtoro=max(vreme[j1].second,edno);
                    edno=min(vreme[j1].second,edno);
                }
                else
                {
                    edno= vreme[j1].second;
                }
            }
            else
            if(k==2)
            {
                if(vreme[j1].first<=edno)
                {
                    cout<<"NO";
                    dali=false;
                }
                else
                {
                   if(vreme[j1].first<=vtoro)
                    {
                        vtoro=max(vreme[j1].second,vtoro);
                        edno=min(vreme[j1].second,vtoro);
                    }
                    else
                    {
                        k=1;
                        edno= vreme[j1].second;
                    }
                }
             }
             j1++;
        }

       if(dali)cout<<"YES";

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
    int n;
    int a;
    bool dali=true;
    cin>>n;
    vector<pair<int, int> > vreme;
    vreme.clear();
    for(int j=0;j<n;j++)
        {
          pair<int, int>par;
          scanf ("%d",&a);
          par.first=a;
          scanf ("%d",&a);
          par.second=a;
          vreme.push_back(par);
        }
    sort(vreme.begin(),vreme.end());

    int edno= vreme[0].second;
    int vtoro;
    int k=1;
    for(int j=1;j<n;j++)
        {
           // cout<<"tuka "<<vreme[j].first<<" "<<vreme[j].second<<" j"<<j<<endl;
            if(k==1)
            {
                if(vreme[j].first<=edno)
                {
                    k=2;
                    vtoro=max(vreme[j].second,edno);
                    edno=min(vreme[j].second,edno);
                }
                else
                {
                    edno= vreme[j].second;
                }
            }
            else
            if(k==2)
            {
                if(vreme[j].first<=edno)
                {
                    cout<<"NO";
                    dali=false;
                    break;
                }
                else
                {
                   if(vreme[j].first<=vtoro)
                    {
                        vtoro=max(vreme[j].second,vtoro);
                        edno=min(vreme[j].second,vtoro);
                    }
                    else
                    {
                        k=1;
                        edno= vreme[j].second;
                    }
                }
             }
        }

       if(dali)  cout<<"YES";

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
    int n;
    int a;
    bool dali=true;
    cin>>n;
    vector<pair<int, int> > vreme;
    vreme.clear();
    for(int j=0;j<n;j++)
        {
          pair<int, int>par;
          scanf ("%d",&a);
          par.first=a;
          scanf ("%d",&a);
          par.second=a;
          vreme.push_back(par);
        }
    sort(vreme.begin(),vreme.end());

    int edno= vreme[0].second;
    int vtoro;
    int k=1;
    for(int j=1;j<n;j++)
        {
          // cout<<"tuka "<<vreme[j].first<<" "<<vreme[j].second<<" j"<<j<<endl;
            if(k==1)
            {
                if(vreme[j].first<=edno)
                {
                    k=2;
                    vtoro=max(vreme[j].second,edno);
                    edno=min(vreme[j].second,edno);
                }
                else
                {
                    edno= vreme[j].second;
                }
            }
            else
            if(k==2)
            {
                if(vreme[j].first<=edno)
                {
                    cout<<"NO";
                    dali=false;
                    //break;
                }
                else
                {
                   if(vreme[j].first<=vtoro)
                    {
                        vtoro=max(vreme[j].second,vtoro);
                        edno=min(vreme[j].second,vtoro);
                    }
                    else
                    {
                        k=1;
                        edno= vreme[j].second;
                    }
                }
             }
        }

       if(dali)  cout<<"YES";

    return 0;
}


#include <bits/stdC++.h>
#define ret return
using namespace std;
typedef pair<int,int> pi1;
const int MAX_N=2e5;
int n;
pi1 ara[MAX_N];
int bs(int ri,int end){
	int l=0,r=end-1,mid=(r+l)/2+(r+l)%2;
	while(r!=l){
		if(ri>=ara[mid].first)	l=mid;
		else		r=mid-1;
		mid=(r+l)/2+(r+l)%2;
	}
	ret r+1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		ara[i]=pi1(a,b);
	}
	sort(&ara[0],&ara[n]);
	for(int i=0;i<n;i++){
		int a=bs(ara[i].second,n);
		if(a-i>2){
			cout<<"NO";
			ret 0;
		}
	}
	cout<<"YES";
	ret 0;
}


#include <bits/stdC++.h>
#define ret return
using namespace std;
typedef pair<int,int> pi1;
const int MAX_N=2e5;
int n,k;
pi1 ara[MAX_N];
int bs(int ri,int end){
	int l=0,r=end-1,mid=(r+l)/2+(r+l)%2;
	while(r!=l){
		if(ri>=ara[mid].first)	l=mid;
		else		r=mid-1;
		mid=(r+l)/2+(r+l)%2;
	}
	ret r+1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		ara[i]=pi1(a,b);
	}
	sort(&ara[0],&ara[n]);
	for(int i=0;i<n;i++){
		int a=bs(ara[i].second,n);
		if(k>0){if(a-i>1){cout<<"NO";ret 0;}k--;}
		if(a-i>2){k=a-i-2;}
	}
	cout<<"YES";
	ret 0;
}


#include <bits/stdC++.h>
#define ret return
using namespace std;
typedef pair<int,int> pi1;
const int MAX_N=2e5;
int n,m,k;
pi1 ara[MAX_N];
int bs(int ri,int end){
	int l=0,r=end-1,mid=(r+l)/2+(r+l)%2;
	while(r!=l){
		if(ri>=ara[mid].first)	l=mid;
		else		r=mid-1;
		mid=(r+l)/2+(r+l)%2;
	}
	ret r+1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		ara[i]=pi1(a,b);
	}
	sort(&ara[0],&ara[n]);
	for(int i=0;i<n;i++){
		int a=bs(ara[i].second,n);
		if(k>0){if(a-i>1){cout<<"NO";ret 0;}k--;}
		if(a-i>2){m=a-i;k=a;}
	}
	cout<<"YES";
	ret 0;
}


#include <bits/stdC++.h>
#define ins insert
using namespace std;
typedef pair<int,int> pi1;
typedef pair<pi1,int> pi2;
set <pi2> s;
int n,c=0;
int can(int l1,int r1,int l2,int r2){
	if(r1>=l2)	return 0;
	return 1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		s.ins(pi2(pi1(a,b),i));
	}
	pi2 x11=*(s.begin());
	s.erase(x11);
	pi1 x21=x11.first;
	int r1=x21.second,l1=x21.first;
	c++;
	while(s.size()){
		pi2 x1=*(s.begin());
		s.erase(x1);
		pi1 x2=x1.first;
		int r2=x2.second,l2=x2.first;
		if(can(l1,r1,l2,r2)==0){
			if(c!=2)	c++;
			else{
				cout<<"NO";
				return 0;
			}
		}
		else c=1;
		r1=r2;
		l1=l2;
	}
	cout<<"YES";
	return 0;
}


#include <bits/stdC++.h>
#define ins insert
using namespace std;
typedef pair<int,int> pi1;
typedef pair<pi1,int> pi2;
set <pi2> s;
int n,c=0;
int can(int r1,int l2){
	if(r1>=l2)	return 0;
	return 1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		s.ins(pi2(pi1(a,b),i));
	}
	pi2 x11=*(s.begin());
	s.erase(x11);
	pi1 x21=x11.first;
	int r1=x21.second;
	c++;
	while(s.size()){
		pi2 x1=*(s.begin());
		s.erase(x1);
		pi1 x2=x1.first;
		int r2=x2.second,l2=x2.first;
		if(can(r1,l2)==0){
			if(c!=2)	c++;
			else{
				cout<<"NO";
				return 0;
			}
		}
		else c=1;
		r1=max(r2,r1);
	}
	cout<<"YES";
	return 0;
}


#include <bits/stdC++.h>
#define ret return
using namespace std;
typedef pair<int,int> pi1;
const int MAX_N=2e5;
int n;
pi1 ara[MAX_N];
int bs(int ri,int end){
	int l=0,r=end-1,mid=(r+l)/2+(r+l)%2;
	while(r!=l){
		if(ri>=ara[mid].first)	l=mid;
		else		r=mid-1;
		mid=(r+l)/2+(r+l)%2;
	}
	ret r+1;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		ara[i]=pi1(a,b);
	}
	sort(&ara[0],&ara[n]);
	for(int i=0;i<n;i++){
		int a=bs(ara[i].second,n);
		cout<<a-i<<'*'<<endl;
		if(a-i>2){
			cout<<"NO";
			ret 0;
		}
	}
	cout<<"YES";
	ret 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

int main() {
    int n,x,y,arr[mx*2] = {},temp=0;
    scd(n);
    while(n--) {
        scd(x);
        scd(y);
        arr[x]++;
        arr[y+1]--;
    }
    repi(1,200000,1) {
        temp += arr[i];
        if(temp > 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

int main() {
    int n,a,b,x=INT_MAX,y=0;
    scd(n);
    repi(0,n,1) {
        cin >> a >> b;
        x = min(x,b);
        y = max(y,a);
    }
    if(x < y) cout << "YES\n";
    else cout << "NO\n";
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

int main() {
    int n,x,y,arr[mx*2] = {},temp=0;
    scd(n);
    while(n--) {
        scd(x);
        scd(y);
        arr[x]++;
        arr[y+1]--;
    }
    repi(0,200000,1) {
        temp += arr[i];
        if(temp > 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


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

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 200100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

int main() {
    vector < pair<int,int> > arr;
    int n,x,y,p=0;
    scd(n);
    repi(0,n,1) {
        scanf("%d %d",&x,&y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    x = 0;
    repi(1,arr.size(),1) {
        if(arr[x].second < arr[i].first) {
            x++;
            p = 0;
            if(arr[x].first <= arr[x-1].second) p = 1;
        }
        //if(arr[x].second >= arr[i].first) p++;
        if(p >= 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

int main() {
    int n,a,b,x=INT_MAX,y=0;
    scd(n);
    repi(0,n,1) {
        cin >> a >> b;
        x = min(x,b);
        y = max(y,a);
    }
    if(y < x) cout << "YES\n";
    else cout << "NO\n";
}


//
//  main.cpp
//  CP
//
//  Created by Paprika on 08/05/18.
//  Copyright © 2018 CP. All rights reserved.
//

//#include "stdc++.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

bool compare(const pair<int,int>& a,const pair <int,int>& b) {
    return a.first > b.first || (a.first == b.first && a.second < b.second);
}

int main() {
    pair <int,int> a = mp(-1,-1),b = mp(-1,-1);
    int n;
    vector < pair<int,int> > arr;
    scd(n);
    while(n--) {
        int x,y;
        scanf("%d %d",&x,&y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    repi(0,arr.size(),1) {
        if(a.se < arr[i].fi) {
            a = arr[i];
        }
        else if(b.se < arr[i].fi) {
            b = arr[i];
        }
        else {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
}


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

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 200100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

int main() {
    vector < pair<int,int> > arr;
    int n,x,y,p=0;
    scd(n);
    repi(0,n,1) {
        scanf("%d %d",&x,&y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    x = 0;
    repi(1,arr.size(),1) {
        if(arr[x].second < arr[i].first) {
            x++;
            p = 0;
            if(arr[x].first <= arr[x-1].second) p = 1;
        }
        if(arr[x].second >= arr[i].first) p++;
        if(p >= 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

int main() {
    int n,a,b,x=INT_MAX,y=0;
    scd(n);
    repi(0,n,1) {
        cin >> a >> b;
        x = min(x,b);
        y = max(y,a);
    }
    if(n == 1) cout << "NO\n";
    else if(x < y) cout << "YES\n";
    else cout << "NO\n";
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

map <int,int> arr,visit;

int main() {
    int n,x,y,temp=0;
    vector <int> dis;
    scd(n);
    while(n--) {
        scd(x);
        scd(y);
        if(visit.count(x) == 0) dis.pb(x);
        if(visit.count(y) == 0) dis.pb(y);
        visit[x] = visit[y] = 1;
        arr[x]++;
        arr[y+1]--;
    }
    sort(dis.begin(),dis.end());
    repi(0,dis.size(),1) {
        temp += dis[i];
        if(temp > 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


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

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 200100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

int main() {
    vector < pair<int,int> > arr;
    int n,x,y,p=0;
    scd(n);
    repi(0,n,1) {
        scanf("%d %d",&x,&y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    x = 0;
    repi(1,arr.size(),1) {
        if(arr[x].second < arr[i].first) {
            x++;
            p = 0;
            //if(arr[x].first <= arr[x-1].second) p = 1;
        }
        if(arr[x].second >= arr[i].first) p++;
        if(p >= 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

double pitagoras(double x1,double y1,double x2,double y2) {return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));}

map <int,int> arr,visit;

int main() {
    int n,x,y,temp=0;
    vector <int> dis;
    scd(n);
    while(n--) {
        scd(x);
        scd(y);
        if(visit.count(x) == 0) dis.pb(x);
        if(visit.count(y) == 0) dis.pb(y);
        visit[x] = visit[y] = 1;
        arr[x]++;
        arr[y+1]--;
    }
    repi(0,dis.size(),1) {
        temp += dis[i];
        if(temp > 2) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


//
//  main.cpp
//  CP
//
//  Created by Paprika on 08/05/18.
//  Copyright © 2018 CP. All rights reserved.
//

//#include "stdc++.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

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

typedef pair<ll,ll> ii;
const int mx = 100100;
const int md = 1e9+7;
const double EULER = 2.71828182845904523536;

bool compare(const pair<int,int>& a,const pair <int,int>& b) {
    return a.first > b.first || (a.first == b.first && a.second < b.second);
}

int main() {
    pair <int,int> a = mp(0,0),b = mp(0,0);
    int n;
    vector < pair<int,int> > arr;
    scd(n);
    while(n--) {
        int x,y;
        scanf("%d %d",&x,&y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    repi(0,arr.size(),1) {
        if(a.se < arr[i].fi) {
            a = arr[i];
        }
        else if(b.se < arr[i].fi) {
            b = arr[i];
        }
        else {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio 	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;

int main(){

	fastio;

	pii f1={0,0},f2={0,0};

	int n; cin >> n;

	fr(i,n){
		int x,y;
		cin >> x >> y;

		if(x>=f1.snd)
			f1={x,y};

		else if(x>=f2.snd)
			f2={x,y};

		else{
			cout << "NO" << endl;
			return 0;
		}
	}

	puts("YES");

}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio 	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;

ll bit[800800];

void update(int ind, ll val){
	for(int i=ind;i<800800;i++)
		bit[i]+=val;
}

ll query(int ind){
	ll ans = 0;
	for(int i=ind;i>0;i-=i&-i)
		ans+=bit[i];
	return ans;
}

int main(){

	fastio;

	int n; cin >> n;

	vi coord;
	vii queries;

	fr(i,n){
		int x,y;
		cin >> x >> y;
		coord.pb(x);
		coord.pb(x-1);
		coord.pb(x+1);
		coord.pb(y);
		coord.pb(y-1);
		coord.pb(y+1);
		queries.pb({x,y});
	}

	sort(all(coord));

	map<int,int> id;
	int ini=1;

	for(auto x : coord)
		if(!id[x])
			id[x]=ini++;

	ini--;

	fr(i,n){
		queries[i].fst=id[queries[i].fst];
		queries[i].snd=id[queries[i].snd];
		update(queries[i].fst,1);
		update(queries[i].snd,-1);
	}

	bool flag=true;
	frr(i,ini)
		if(query(i)>2)
			flag=false;

	cout << (flag ? "YES" : "NO") << endl;

}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio 	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;

ll bit[800800];

void update(int ind, ll val){
	for(int i=ind;i<800800;i++)
		bit[i]+=val;
}

ll query(int ind){
	ll ans = 0;
	for(int i=ind;i>0;i-=i&-i)
		ans+=bit[i];
	return ans;
}

int main(){

	fastio;

	int n; cin >> n;

	vi coord;
	vii queries;

	fr(i,n){
		int x,y;
		cin >> x >> y;
		coord.pb(x);
		coord.pb(x+1);
		coord.pb(y);
		coord.pb(y+1);
		queries.pb({x,y});
	}

	sort(all(coord));

	map<int,int> id;
	int ini=1;

	for(auto x : coord)
		if(!id[x])
			id[x]=ini++;

	ini--;

	fr(i,ini){
		queries[i].fst=id[queries[i].fst];
		queries[i].snd=id[queries[i].snd];
		update(queries[i].fst,1);
		update(queries[i].snd,-1);
	}

	bool flag=true;
	for(int i=9;i<=ini;i++)
		if(query(i)>2)
			flag=false;

	cout << (flag ? "YES" : "NO") << endl;

}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio 	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;

ll aux[1200100];
ll v[1200100];

int main(){

	fastio;

	int n; cin >> n;

	vi coord;
	vii queries;

	fr(i,n){
		int x,y;
		cin >> x >> y;
		coord.pb(x);
		coord.pb(x+1);
		coord.pb(y);
		coord.pb(y+1);
		coord.pb(x-1);
		coord.pb(y-1);
		queries.pb({x,y});
	}

	sort(all(coord));

	map<int,int> id;
	int ini=1;

	for(auto x : coord)
		if(!id[x])
			id[x]=ini++;

	ini--;

	fr(i,n){
		queries[i].fst=id[queries[i].fst];
		queries[i].snd=id[queries[i].snd];
		int x=queries[i].fst;
		int y=queries[i].snd;
		aux[x]++;
		aux[y+1]--;
	}

	int adder=0;
	frr(i,ini){
		adder+=aux[i];
		v[i]+=adder;
	}

	bool flag=true;
	for(int i=1;i<=ini;i++)
		if(v[i]>2)
			flag=false;

	cout << (flag ? "YES" : "NO") << endl;

}


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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio 	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;

ll bit[800800];

void update(int ind, ll val){
	for(int i=ind;i<800800;i++)
		bit[i]+=val;
}

ll query(int ind){
	ll ans = 0;
	for(int i=ind;i>0;i-=i&-i)
		ans+=bit[i];
	return ans;
}

int main(){

	fastio;

	int n; cin >> n;

	vi coord;
	vii queries;

	fr(i,n){
		int x,y;
		cin >> x >> y;
		coord.pb(x);
		coord.pb(x-1);
		coord.pb(x+1);
		coord.pb(y);
		coord.pb(y-1);
		coord.pb(y+1);
		queries.pb({x,y});
	}

	sort(all(coord));

	map<int,int> id;
	int ini=10;

	for(auto x : coord)
		if(!id[x])
			id[x]=ini++;

	ini--;

	fr(i,n){
		queries[i].fst=id[queries[i].fst];
		queries[i].snd=id[queries[i].snd];
		update(queries[i].fst,1);
		update(queries[i].snd,-1);
	}

	bool flag=true;
	frr(i,ini)
		if(query(i)>2)
			flag=false;

	cout << (flag ? "YES" : "NO") << endl;

}


#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define ll long long
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define fs first
#define sc second
#define MAXN 100004

using namespace std;

pii v[MAXN];

bool cmp(pii a, pii b){
	if(a.fs != b.fs)
		return a.fs < b.fs;

	return a.sc > b.sc;
}

int main(){_
	int n;
	int getOut = 0;

	cin >> n;

	for(int i=0; i<n; ++i){
		cin >> v[i].fs >> v[i].sc;
	}

	sort(v, v+n, cmp);

	//for(int i=0; i<n; ++i)

	for(int i=0; i<n-3 && !getOut; ++i){
		getOut = (v[i+1].fs <= v[i].sc && v[i+2].fs <= v[i].sc);
	}

	if(getOut) cout << "NO";
	else cout << "YES";

	cout << endl;

	return 0;
}
// 1519501732819


#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define ll long long
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define fs first
#define sc second
#define MAXN 200004

using namespace std;

pii v[MAXN];

bool cmp(pii a, pii b){
	if(a.fs != b.fs)
		return a.fs < b.fs;

	return a.sc < b.sc;
}

int main(){_
	int n;
	int getOut = 0;

	cin >> n;

	for(int i=0; i<n; ++i){
		cin >> v[i].fs >> v[i].sc;
	}

	sort(v, v+n, cmp);

	//for(int i=0; i<n; ++i)

	for(int i=0; i<n-2 && !getOut; ++i){
		getOut = (v[i+1].fs <= v[i].sc) && (v[i+2].fs <= v[i].sc);
	}

	if(getOut) cout << "NO";
	else cout << "YES";

	cout << endl;

	return 0;
}
// 1519502434195


#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define ll long long
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define fs first
#define sc second
#define MAXN 200004

using namespace std;

pii v[MAXN];

bool cmp(pii a, pii b){
	if(a.fs != b.fs)
		return a.fs < b.fs;

	return a.sc > b.sc;
}

int main(){_
	int n;
	int getOut = 0;

	cin >> n;

	for(int i=0; i<n; ++i){
		cin >> v[i].fs >> v[i].sc;
	}

	sort(v, v+n, cmp);

	//for(int i=0; i<n; ++i)

	for(int i=0; i<n-2 && !getOut; ++i){
		getOut = (v[i+1].fs <= v[i].sc && v[i+2].fs <= v[i].sc);
	}

	if(getOut) cout << "NO";
	else cout << "YES";

	cout << endl;

	return 0;
}
// 1519501897226


#include <bits/stdc++.h>
#define ii pair<long long,long long>
using namespace std;

int main(){
	vector<ii> tv_um,tv_dois,entradas;

	long long n,l,r;
	cin >> n;
	while(n--){
		cin >> l >> r;
		entradas.emplace_back(ii(l,r));
	}

	sort(entradas.begin(),entradas.end());
	long long i;
	for( i =0; i < entradas.size();++i){
		if(tv_um.size() == 0){
			tv_um.emplace_back(entradas[i]);

		} else if(tv_um[tv_um.size()-1].second < entradas[i].first){
			 tv_um.emplace_back(entradas[i]);

		} else if(tv_dois.size() == 0){
			tv_dois.emplace_back(entradas[i]);

		} else if(tv_dois[tv_dois.size()-1].second < entradas[i].first){
			 tv_dois.emplace_back(entradas[i]);

		} else {
			break;
		}
	}
	if(  i == entradas.size() ) cout << "YES" <<endl;
	else cout << "NO" << endl;

	return 0;
}
// 1519503407186


#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f
#define maxn 1000010
#define ri register int
#define il inline
#define mod 1e9+9
#define db() cout << 1 << endl
#define eps 0.000001
using namespace std;
int n,m,a[maxn];
void dfs(int l,int r)
{
	if(l+1 >= r||m==1)
		return ;
	m-=2;
	int mid = l+r>>1;
	swap(a[mid-1],a[mid]);
	dfs(l,mid);
	dfs(mid,r);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin >>n >>m;
	if((m&1)==0)
	{
		cout << -1;
		return 0;
	}
	for(int i=0;i<n;i++)
		a[i] = i+1;
	dfs(0,n);
	if(m!=1)
		cout << -1;
	else
		for(int i=0;i<n;i++)
			cout << a[i] << " ";
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f
#define maxn 1000010
#define ri register int
#define il inline
#define mod 1e9+9
#define db() cout << 1 << endl
#define eps 0.000001
using namespace std;
int n,m,a[maxn];
void dfs(int l,int r)
{
	if(l >= r||m==1)
		return ;
	m-=2;
	int mid = l+r>>1;
	swap(a[mid-1],a[mid]);
	dfs(l,mid-1);
	dfs(mid,r);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin >>n >>m;
	if((m&1)==0)
	{
		cout << -1;
		return 0;
	}
	for(int i=1;i<=n;i++)
		a[i] = i;
	dfs(1,n);
	if(m!=1)
		cout << -1;
	else
		for(int i=1;i<=n;i++)
			cout << a[i] << " ";
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f
#define maxn 1000010
#define ri register int
#define il inline
#define mod 1e9+9
#define db() cout << 1 << endl
#define eps 0.000001
using namespace std;
int n,m,a[maxn];
void dfs(int l,int r)
{
	if(l+1 >= r||!m)
		return ;
	m-=2;
	int mid = l+r>>1;
	swap(a[mid-1],a[mid]);
	dfs(l,mid-1);
	dfs(mid,r);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin >>n >>m;
	if(m&1==0)
	{
		cout << 0;
		return 0;
	}
	for(int i=1;i<=n;i++)
		a[i] = i;
	dfs(1,n);
	if(m!=1)
		cout << -1;
	else
		for(int i=1;i<=n;i++)
			cout << a[i] << " ";
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f
#define maxn 1000010
#define ri register int
#define il inline
#define mod 1e9+9
#define db() cout << 1 << endl
#define eps 0.000001
using namespace std;
int n,m,a[maxn];
void dfs(int l,int r)
{
	if(l >= r||m==1)
		return ;
	m-=2;
	int mid = l+r>>1;
	swap(a[mid-1],a[mid]);
	dfs(l,mid-1);
	dfs(mid,r);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin >>n >>m;
	if(m&1==0)
	{
		cout << 0;
		return 0;
	}
	for(int i=1;i<=n;i++)
		a[i] = i;
	dfs(1,n);
	if(m!=1)
		cout << -1;
	else
		for(int i=1;i<=n;i++)
			cout << a[i] << " ";
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f
#define maxn 1000010
#define ri register int
#define il inline
#define mod 1e9+9
#define db() cout << 1 << endl
#define eps 0.000001
using namespace std;
int n,m,a[maxn];
void dfs(int l,int r)
{
	if(l >= r||m==1)
		return ;
	m-=2;
	int mid = l+r>>1;
	swap(a[mid-1],a[mid]);
	dfs(l,mid-1);
	dfs(mid,r);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin >>n >>m;
	if((m&1)==0)
	{
		cout << -1;
		return 0;
	}
	for(int i=0;i<n;i++)
		a[i] = i+1;
	dfs(0,n);
	if(m!=1)
		cout << -1;
	else
		for(int i=0;i<n;i++)
			cout << a[i] << " ";
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 100010;
int n,m,a[N],f[N<<2],cnt=1;
void solve(int l,int r,int x) {
    if(cnt<m&&l+2<r) {
        cnt+=2;f[x]=1;
    }
    // printf("l:%d r:%d x:%d f:%d\n",l,r,x,f[x]);
    if(l+2>=r) return ;
    int mid=(l+r)>>1;
    solve(l,mid,x<<1);
    solve(mid,r,x<<1|1);
}
void work(int l,int r,int x) {
    int mid=(l+r)>>1;
    // printf("l:%d r:%d mid:%d x:%d f:%d\n",l,r,mid,x,f[x]);
    bool fg=0;
    if(f[x<<1]) work(l,mid,x<<1),fg=1;
    if(f[x<<1|1]) work(mid,r,x<<1|1),fg=1;
    int t=r;
    if(!f[x<<1])
        for(int i=l;i<mid;i++) a[i]=i+1;
    if(!f[x<<1|1])
        for(int i=mid;i<r;i++) a[i]=t--;

}
int main() {
    scanf("%d%d",&n,&m);
    if(m%2==0) {
        printf("-1");
        return 0;
    }
    if(m==1) {
        for(int i=1;i<=n;i++) printf("%d%c",i,i==n?'\n':' ');
        return 0;
    }
    solve(0,n,1);
    if(cnt<m) {
        printf("-1");
        return 0;
    }
    cout<<n<<endl;
    work(0,n,1);
    for(int i=0;i<n;i++) {
        printf("%d%c",a[i],i==n?'\n':' ');
    }
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 100010;
int n,m,a[N],f[N<<2],cnt=1;
void solve(int l,int r,int x) {
    if(cnt<m&&l+1<r) {
        cnt+=2;f[x]=1;
    }
    // printf("l:%d r:%d x:%d f:%d\n",l,r,x,f[x]);
    if(l+1>=r) return ;
    int mid=l+r>>1;
    solve(l,mid,x<<1);
    solve(mid+1,r,x<<1|1);
}
void work(int l,int r,int x) {
    int mid=l+r>>1;
    bool fg=0;
    if(f[x<<1]) work(l,mid,x<<1),fg=1;
    if(f[x<<1|1]) work(mid+1,r,x<<1|1),fg=1;
    int t=mid;
    if(!f[x<<1])
        for(int i=l;i<=mid;i++) a[i]=t--;
    if(!f[x<<1|1])
        for(int i=mid+1;i<=r;i++) a[i]=i;

}
int main() {
    scanf("%d%d",&n,&m);
    if(m==1) {
        for(int i=1;i<=n;i++) printf("%d%c",i,i==n?'\n':' ');
        return 0;
    }
    solve(0,n-1,1);
    if(cnt!=m) {
        printf("-1");
        return 0;
    }
    // cout<<cnt<<endl;
    work(0,n-1,1);
    for(int i=0;i<n;i++) {
        printf("%d%c",a[i]+1,i==n?'\n':' ');
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n,p,a[N],cnt=1;
void solve(int l,int r,int st,int ed) {
    int m=l+r>>1,len=r-m;;
    if(cnt<p&&l+1<r) {
        cnt+=2;
        solve(l,m,st+len,ed);
        solve(m,r,st,st+len);
        return ;
    }
    int t=st;
    for(int i=l;i<=r;i++) a[i]=t++;
}
int main() {
    scanf("%d%d",&n,&p);
    if(p%2==0) {
        printf("-1");return 0;
    }
    for(int i=0;i<n;i++) a[i]=i+1;
    solve(0,n,1,n);
    if(cnt!=p) {
        printf("-1");return 0;
    }
    for(int i=0;i<n;i++) printf("%d ",a[i]);
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 200010;
int n,m,a[N],f[N<<2],cnt=1;
void solve(int l,int r,int x) {
    if(cnt<m&&l+1<r) {
        cnt+=2;f[x]=1;
    }
    // printf("l:%d r:%d x:%d f:%d\n",l,r,x,f[x]);
    if(l+1>=r) return ;
    int mid=l+r>>1;
    solve(l,mid,x<<1);
    solve(mid+1,r,x<<1|1);
}
void work(int l,int r,int x) {
    int mid=l+r>>1;
    bool fg=0;
    if(f[x<<1]) work(l,mid,x<<1),fg=1;
    if(f[x<<1|1]) work(mid+1,r,x<<1|1),fg=1;
    int t=mid;
    if(!f[x<<1])
        for(int i=l;i<=mid;i++) a[i]=t--;
    if(!f[x<<1|1])
        for(int i=mid+1;i<=r;i++) a[i]=i;

}
int main() {
    scanf("%d%d",&n,&m);
    if(m==1) {
        for(int i=1;i<=n;i++) printf("%d%c",i,i==n?'\n':' ');
        return 0;
    }
    solve(0,n-1,1);
    if(cnt!=m) {
        printf("-1");
    }
    // cout<<cnt<<endl;
    work(0,n-1,1);
    for(int i=0;i<n;i++) {
        printf("%d%c",a[i]+1,i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n,p,a[N],cnt=1;
void solve(int l,int r,int st,int ed) {
    int m=l+r>>1,len=r-m;;
    if(cnt<p&&l+1<r) {
        // cout<<"!"<<endl;
        cnt+=2;
        solve(l,m,st+len,ed);
        solve(m,r,st,st+len);
        return ;
    }
    int t=st;
    for(int i=l;i<=r;i++) a[i]=t++;
}
int main() {
    scanf("%d%d",&n,&p);
    if(p%2==0) {
        printf("-1");return 0;
    }
    for(int i=0;i<n;i++) a[i]=i+1;
    solve(0,n,1,n);
    if(cnt!=p) {
        printf("-1");return 0;
    }
    // cout<<n<<endl;
    for(int i=0;i<n;i++) printf("%d ",a[i]);
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 200010;
int n,m,a[N],f[N<<2],cnt=1;
void solve(int l,int r,int x) {
    if(cnt<m&&l+1<r) {
        cnt+=2;f[x]=1;
    }

    // printf("l:%d r:%d x:%d f:%d\n",l,r,x,f[x]);
    if(l+1>=r) return ;
    int mid=l+r>>1;
    solve(l,mid,x<<1);
    solve(mid+1,r,x<<1|1);
}
void work(int l,int r,int x) {
    int mid=l+r>>1;
    bool fg=0;
    if(f[x<<1]) work(l,mid,x<<1),fg=1;
    if(f[x<<1|1]) work(mid+1,r,x<<1|1),fg=1;
    int t=mid;
    if(!f[x<<1])
        for(int i=l;i<=mid;i++) a[i]=t--;
    if(!f[x<<1|1])
        for(int i=mid+1;i<=r;i++) a[i]=i;

}
int main() {
    scanf("%d%d",&n,&m);
    if(m==1) {
        for(int i=1;i<=n;i++) printf("%d%c",i,i==n?'\n':' ');
        return 0;
    }
    solve(0,n-1,1);
    if(cnt!=m) {
        printf("-1");
        return 0;
    }
    // cout<<cnt<<endl;

    work(0,n-1,1);
    cout<<n<<endl;
    for(int i=0;i<n;i++) {
        printf("%d%c",a[i]+1,i==n?'\n':' ');
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 100010;
int n,m,a[N],f[N<<2],cnt=1;
void solve(int l,int r,int x) {
    if(cnt<m&&l+2<r) {
        cnt+=2;f[x]=1;
    }
    // printf("l:%d r:%d x:%d f:%d\n",l,r,x,f[x]);
    if(l+2>=r) return ;
    int mid=(l+r)>>1;
    solve(l,mid,x<<1);
    solve(mid,r,x<<1|1);
}
void work(int l,int r,int x) {
    int mid=(l+r)>>1;
    // printf("l:%d r:%d mid:%d x:%d f:%d\n",l,r,mid,x,f[x]);
    bool fg=0;
    if(f[x<<1]) work(l,mid,x<<1),fg=1;
    if(f[x<<1|1]) work(mid,r,x<<1|1),fg=1;
    int t=r;
    if(!f[x<<1])
        for(int i=l;i<mid;i++) a[i]=i+1;
    if(!f[x<<1|1])
        for(int i=mid;i<r;i++) a[i]=t--;

}
int main() {
    scanf("%d%d",&n,&m);
    if(m%2==0) {
        printf("-1");
        return 0;
    }
    if(m==1) {
        for(int i=1;i<=n;i++) printf("%d%c",i,i==n?'\n':' ');
        return 0;
    }
    solve(0,n,1);
    if(cnt<m) {
        printf("-1");
        return 0;
    }
    // cout<<n<<endl;
    work(0,n,1);
    for(int i=0;i<n;i++) {
        printf("%d%c",a[i],i==n?'\n':' ');
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n,p,a[N],cnt=1;
void solve(int l,int r,int st,int ed) {
    int m=l+r>>1,len=r-m;;
    if(cnt<p&&l+1<r) {
        cnt+=2;
        solve(l,m,st+len,ed);
        solve(m+1,r,st,st+len);
        return ;
    }
    int t=st;
    for(int i=l;i<=r;i++) a[i]=t++;
}
int main() {
    scanf("%d%d",&n,&p);
    if(p%2==0) {
        printf("-1");return 0;
    }
    for(int i=0;i<n;i++) a[i]=i+1;
    solve(0,n-1,1,n);
    if(cnt!=p) {
        printf("-1");return 0;
    }
    for(int i=0;i<n;i++) printf("%d ",a[i]);
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 200010;
int n,m,a[N],f[N<<2],cnt=1;
void solve(int l,int r,int x) {
    if(cnt<m&&l+1<r) {
        cnt+=2;f[x]=1;
    }
    // printf("l:%d r:%d x:%d f:%d\n",l,r,x,f[x]);
    if(l+1>=r) return ;
    int mid=l+r>>1;
    solve(l,mid,x<<1);
    solve(mid+1,r,x<<1|1);
}
void work(int l,int r,int x) {
    int mid=l+r>>1;
    bool fg=0;
    if(f[x<<1]) work(l,mid,x<<1),fg=1;
    if(f[x<<1|1]) work(mid+1,r,x<<1|1),fg=1;
    int t=mid;
    if(!f[x<<1])
        for(int i=l;i<=mid;i++) a[i]=t--;
    if(!f[x<<1|1])
        for(int i=mid+1;i<=r;i++) a[i]=i;

}
int main() {
    scanf("%d%d",&n,&m);
    if(m==1) {
        for(int i=1;i<=n;i++) printf("%d%c",i,i==n?'\n':' ');
        return 0;
    }
    solve(0,n-1,1);
    if(cnt!=m) {
        printf("-1");
        return 0;
    }
    // cout<<cnt<<endl;

    work(0,n-1,1);
    for(int i=0;i<n;i++) {
        printf("%d%c",a[i]+1,i==n?'\n':' ');
    }
    return 0;
}


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=200003;
int n,k,a[N],tot;
void Divide_And_Conquer(int l,int r)
{
	if(l+1==r||tot==k)return;
	int M=l+r>>1;tot+=2;
	a[M-1]^=a[M]^=a[M-1]^=a[M];
	Divide_And_Conquer(l,M);
	Divide_And_Conquer(M,r);
}
int main()
{
	scanf("%d%d",&n,&k);k--;
	if(k&1){puts("-1");return 0;}
	go(i,0,n-1)a[i]=i+1;Divide_And_Conquer(0,n);
	if(tot<k){puts("-1");return 0;};
	go(i,0,n-1)printf("%d ",a[i]);return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=100003;
int n,k,a[N],ans[N];
void Divide_And_Conquer(int l,int r,int t)
{
	if(l==r&&t>0){puts("-1");exit(1);}
	if(t==0){go(i,l,r)ans[i]=a[i];return;}

	int tmp[N],M=l+r>>1;
	go(i,1,n)tmp[i]=a[i];
	go(i,l,M)a[i]=tmp[r-M+i];
	go(i,M+1,r)a[i]=tmp[i-M+l-1];t-=2;
	if(t<0){puts("-1");exit(1);}
	Divide_And_Conquer(l,M,(t+1)/2);
	Divide_And_Conquer(M+1,r,t-(t+1)/2);
	go(i,1,n)a[i]=tmp[i];
}
int main()
{

	scanf("%d%d",&n,&k);
	go(i,1,n)a[i]=i;
	Divide_And_Conquer(1,n,k-1);
	go(i,1,n)printf("%d ",ans[i]);
	return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=100003;
int n,k,a[N],ans[N];
void Divide_And_Conquer(int l,int r,int t)
{
	if(l==r&&t>0){puts("-1");exit(1);}
	if(t<=0){go(i,l,r)ans[i]=a[i];return;}

	int tmp[N],M=l+r>>1;
	go(i,1,n)tmp[i]=a[i];
	go(i,l,M)a[i]=tmp[r-M+i];
	go(i,M+1,r)a[i]=tmp[i-M+l-1];t--;
	Divide_And_Conquer(l,M,(t+1)/2);
	Divide_And_Conquer(M+1,r,t-(t+1)/2);
	go(i,1,n)a[i]=tmp[i];
}
int main()
{
	scanf("%d%d",&n,&k);
	go(i,1,n)a[i]=i;
	Divide_And_Conquer(1,n,k-1);
	go(i,1,n)printf("%d ",ans[i]);
	return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=100003;
int n,k,a[N],ans[N];
void Divide_And_Conquer(int l,int r,int t)
{
	if(l+1==r&&t>0){puts("-1");exit(1);}
	if(t==0){go(i,l,r)ans[i]=a[i];return;}

	t-=2;
	int tmp[N],M=l+r>>1;
	go(i,0,n-1)tmp[i]=a[i];
	go(i,l,M-1)a[i]=tmp[i+r-M];
	go(i,M,r-1)a[i]=tmp[i-M+l];
	Divide_And_Conquer(l,M,t-(t/2+1)/2*2);
	Divide_And_Conquer(M,r,(t/2+1)/2*2);
	go(i,0,n-1)a[i]=tmp[i];
}
int main()
{
	scanf("%d%d",&n,&k);
	go(i,0,n-1)a[i]=i+1;
	if(!(k&1)){puts("-1");exit(1);}
	Divide_And_Conquer(0,n,k-1);
	go(i,0,n-1)printf("%d ",ans[i]);
	return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=100003;
int n,k,a[N],ans[N],bad;
void Divide_And_Conquer(int l,int r,int t)
{
	if(l+1==r&&t>0){bad=1;return;}
	if(t==0){go(i,l,r)ans[i]=a[i];return;}

	t-=2;
	int tmp[N],M=l+r>>1;
	go(i,0,n-1)tmp[i]=a[i];
	go(i,l,M-1)a[i]=tmp[i+r-M];
	go(i,M,r-1)a[i]=tmp[i-M+l];
	Divide_And_Conquer(l,M,t-(t/2+1)/2*2);if(bad)return;
	Divide_And_Conquer(M,r,(t/2+1)/2*2);if(bad)return;
	go(i,0,n-1)a[i]=tmp[i];
}
int main()
{
	scanf("%d%d",&n,&k);
	go(i,0,n-1)a[i]=i+1;
	if(!(k&1)){puts("-1");exit(1);}
	Divide_And_Conquer(0,n,k-1);
	go(i,0,n-1)printf("%d ",ans[i]);
	return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=200003;
int n,k,a[N],tot;
void Divide_And_Conquer(int l,int r)
{
	if(l+1==r||tot==k)return;
	int M=l+r>>1;tot+=k;
	a[M-1]^=a[M]^=a[M-1]^=a[M];
	Divide_And_Conquer(l,M);
	Divide_And_Conquer(M,r);
}
int main()
{
	scanf("%d%d",&n,&k);
	if(!(k&1)){puts("-1");return 0;}
	go(i,0,n-1)a[i]=i+1;Divide_And_Conquer(0,n);
	if(tot<k){puts("-1");return 0;};
	go(i,0,n-1)printf("%d ",a[i]);return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=100003;
int n,k,a[N],ans[N];
void Divide_And_Conquer(int l,int r,int t)
{
	if(l+1==r&&t>0){puts("-1");exit(0);}
	if(t==0){go(i,l,r)ans[i]=a[i];return;}

	t-=2;
	int tmp[N],M=l+r>>1;
	go(i,0,n-1)tmp[i]=a[i];
	go(i,l,M-1)a[i]=tmp[i+r-M];
	go(i,M,r-1)a[i]=tmp[i-M+l];
	Divide_And_Conquer(l,M,t-(t/2+1)/2*2);
	Divide_And_Conquer(M,r,(t/2+1)/2*2);
	go(i,0,n-1)a[i]=tmp[i];
}
int main()
{
	scanf("%d%d",&n,&k);
	go(i,0,n-1)a[i]=i+1;
	if(!(k&1)){puts("-1");exit(1);}
	Divide_And_Conquer(0,n,k-1);
	go(i,0,n-1)printf("%d ",ans[i]);
	return 0;
}//Paul_Guderian


#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=100003;
int n,k,a[N],ans[N],bad;
void Divide_And_Conquer(int l,int r,int t)
{
	if(l+1==r&&t>0){bad=1;return;}
	if(t==0){go(i,l,r)ans[i]=a[i];return;}

	t-=2;
	int tmp[N],M=l+r>>1;
	go(i,0,n-1)tmp[i]=a[i];
	go(i,l,M-1)a[i]=tmp[i+r-M];
	go(i,M,r-1)a[i]=tmp[i-M+l];
	Divide_And_Conquer(l,M,t-(t/2+1)/2*2);if(bad)return;
	Divide_And_Conquer(M,r,(t/2+1)/2*2);if(bad)return;
	go(i,0,n-1)a[i]=tmp[i];
}
int main()
{
	scanf("%d%d",&n,&k);
	go(i,0,n-1)a[i]=i+1;
	if(!(k&1)){puts("-1");return 0;}
	Divide_And_Conquer(0,n,k-1);
	go(i,0,n-1)printf("%d ",ans[i]);
	return 0;
}//Paul_Guderian


#include<bits/stdc++.h>

const int N = 100010;

int a[N];
int n, k;

void solve(int l, int r){
	if (l == r - 1) return;
	if (k <= 0) return;
	k -= 2;
	int mid = l + r >> 1;
	solve(l, mid);
	solve(mid, r);
	if (!k || l == r - 2){
		for (int i = l; i < mid; ++ i){
			std::swap(a[i], a[i + mid - l]);
		}
		if (!k) k -= 2;
	}
}

int main(){
	scanf("%d%d", &n, &k);
	if (2 * n + 1 < k || k % 2 == 0){
		return printf("-1\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		a[i] = i + 1;
	}
	-- k;
	solve(0, n);
	for (int i = 0; i < n; ++ i){
		printf("%d%c", a[i], " \n"[i == n - 1]);
	}
	return 0;
}


#include<bits/stdc++.h>

const int N = 100010;

int a[N];
int n, k;

void solve(int l, int r){
	if (l == r - 1) return;
	if (!k) return;
	k -= 2;
	int mid = l + r >> 1;
	solve(l, mid);
	solve(mid, r);
	int x = r - mid != mid - l;
	for (int i = l; i < mid; ++ i){
		std::swap(a[i], a[i + mid - l + x]);
	}
}

int main(){
	scanf("%d%d", &n, &k);
	if (2 * n + 1 < k || k % 2 == 0){
		return printf("-1\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		a[i] = i + 1;
	}
	-- k;
	solve(0, n);
	for (int i = 0; i < n; ++ i){
		printf("%d%c", a[i], " \n"[i == n - 1]);
	}
	return 0;
}


#include<bits/stdc++.h>

const int N = 100010;

int a[N];
int n, k;

void solve(int l, int r){
	if (!k) return;
	k -= 2;
	int mid = l + r >> 1;
	solve(l, mid);
	solve(mid, r);
	for (int i = l; i < mid; ++ i){
		std::swap(a[i], a[i + mid - l]);
	}
}

int main(){
	scanf("%d%d", &n, &k);
	if (2 * n + 1 < k || k % 2 == 0){
		return printf("-1\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		a[i] = i + 1;
	}
	-- k;
	solve(0, n);
	for (int i = 0; i < n; ++ i){
		printf("%d%c", a[i], " \n"[i == n - 1]);
	}
	return 0;
}


#include<bits/stdc++.h>

const int N = 100010;

int a[N];
int n, k;

void solve(int l, int r){
	if (l == r - 1) return;
	if (k <= 0) return;
	k -= 2;
	int mid = l + r >> 1;
	solve(l, mid);
	solve(mid, r);
	if (!k || l == r - 2){
		for (int i = l; i < mid; ++ i){
			std::swap(a[i], a[i + mid - l]);
		}
		if (!k) k -= 2;
	}
}

int main(){
	scanf("%d%d", &n, &k);
	if (2 * n - 1 < k || k % 2 == 0){
		return printf("-1\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		a[i] = i + 1;
	}
	-- k;
	solve(0, n);
	for (int i = 0; i < n; ++ i){
		printf("%d%c", a[i], " \n"[i == n - 1]);
	}
	return 0;
}


#include<bits/stdc++.h>

const int N = 100010;

int a[N];
int n, k;

void solve(int l, int r){
	if (!k) return;
	if (l == r - 1) return;
	k -= 2;
	int mid = l + r >> 1;
	solve(l, mid);
	solve(mid, r);
	for (int i = l; i < mid; ++ i){
		std::swap(a[i], a[i + mid - l]);
	}
}

int main(){
	scanf("%d%d", &n, &k);
	if (2 * n + 1 < k || k % 2 == 0){
		return printf("-1\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		a[i] = i + 1;
	}
	-- k;
	solve(0, n);
	for (int i = 0; i < n; ++ i){
		printf("%d%c", a[i], " \n"[i == n - 1]);
	}
	return 0;
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	k--;
	f(l, m);
	k--;
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--;
	f(0, n);
	if (k)exit(puts("-1"));
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	k--;
	f(l, m);
	if (!k)return;
	k--;
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--;
	f(0, n);
	if (k)exit(puts("-1"));
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	k--;
	f(l, m);
	k--;
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--;
	f(0, n);
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <bits/stdc++.h>
using namespace std;
int n,k,p[100001];
void find(int l,int r,int k){
	//cout<<l<<' '<<r<<endl;
	if(l>=r)
		return;
	if(k>0)swap(p[l],p[l+1]);
	int m=l+r>>1;
	find(l,m,k-2);
	find(m+1,r,k-2);
}
int main(){
	cin>>n>>k;
	if(k%2==0)puts("-1");
	for(int i=0;i<n;i++)
		p[i]=i+1;
	find(0,n,k-1);
	for(int i=0;i<n;i++)
		cout<<p[i]<<' ';
	puts("");
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	printf("%d %d\n", l, r);
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	k--;
	f(l, m);
	k--;
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--;
	f(0, n);
	if (k)exit(puts("-1"));
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	if (k<2||r-l<2)return;
	k -= 2;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	f(l, m);
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--; f(0, n);
	if (k)exit(puts("-1"));
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r, int k) {
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	f(0, n, k - 1);
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	if (!k||r-l<3)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	k--;
	f(l, m);
	if (!k)return;
	k--;
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--;
	f(0, n);
	if (k)exit(puts("-1"));
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	if (!k||r-1<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	k--;
	f(l, m);
	k--;
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	k--;
	f(0, n);
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r) {
	k--;
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	f(l, m);
	f(m, r);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	f(0, n);
	if (k)exit(puts("-1"));
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
using namespace std;
int n, k,a[100001];
void f(int l, int r, int k) {
	if (!k||r-l<2)return;
	int m = (l + r) / 2;
	swap(a[m], a[m - 1]);
	f(l, m, k - 1);
	f(m, r, k - 1);
}
int main() {
	cin >> n >> k;
	if (k % 2 == 0)exit(puts("-1"));
	for (int i = 0; i < n; i++)a[i] = i + 1;
	f(0, n, k - 1);
	for (int i = 0; i < n; i++)cout << a[i] << ' ';
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r)
{
    if (l == r - 1) return;
    if (!k) return;
    k -= 2;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid);
    UnMerge (mid, r);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (~k & 1 || k > 2 * n - 1) EXIT_NO_SUCCESS;

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

    UnMerge (0, n);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (mov == k) return;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid, ++mov);
    UnMerge (mid, r, ++mov);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (!(k & 1)) EXIT_NO_SUCCESS;

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

    int m = 0;
    UnMerge (0, n, ++m);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (mov == k) return;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid, ++mov);
    UnMerge (mid, r, ++mov);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (~k & 1 || k > 2 * n - 1) EXIT_NO_SUCCESS;

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

    int m = 0;
    UnMerge (0, n, ++m);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (!k) return;
    k -= 2;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid);
    UnMerge (mid, r);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (~k & 1 || k > 2 * n - 1) EXIT_NO_SUCCESS;

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

    UnMerge (0, n);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r)
{
    if (!k) return;
    if (l == r - 1) return;
    k -= 2;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid);
    UnMerge (mid, r);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (~k & 1 || k > 2 * n - 1) EXIT_NO_SUCCESS;

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

    k--;
    UnMerge (0, n);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (mov == k) return;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid, ++mov);
    UnMerge (mid, r, ++mov);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (k & 1 == 0) EXIT_NO_SUCCESS;

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

    int m = 0;
    UnMerge (0, n, ++m);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (mov == k) return;

    int mid = (l + r) >> 1;

    swap(a[mid - 1], a[mid]);
    UnMerge (l, mid, ++mov);
    UnMerge (mid, r, ++mov);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (~k & 1 || m > 2 * n - 1) EXIT_NO_SUCCESS;

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

    int m = 0;
    UnMerge (0, n, ++m);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (mov == k) return;

    int mid = (l + r) >> 1;

    swap(a[mid], a[mid + 1]);
    UnMerge (l, mid, ++mov);
    UnMerge (mid, r, ++mov);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (k & 1 == 0) EXIT_NO_SUCCESS;

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

    int m = 0;
    UnMerge (0, n, ++m);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <stack>
#include <time.h>
#define x first
#define y second
#define EXIT_NO_SUCCESS { puts("-1"); return 0; }

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 1e5 + 10;
const int Mod = 1e9 + 7;

char* _c = new char[Maxn];
string GetString ()
{
    scanf("%s", _c);
    return string(_c);
}

int n, k;
int a[Maxn];

void UnMerge (int l, int r, int& mov)
{
    if (l == r - 1) return;
    if (mov == k) return;

    swap(a[l], a[r - 1]);
    int mid = (l + r) >> 1;
    UnMerge (l, mid, ++mov);
    UnMerge (mid, r, ++mov);
}

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    scanf("%d%d", &n, &k);
    if (k & 1 == 0) EXIT_NO_SUCCESS;

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

    int m = 0;
    UnMerge (0, n, ++m);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    k-=2;
    if(k==0 || r<=l+1) return;
    int mid=l+r>>1;
    dfs(l, mid);
    dfs(mid, r);
    swap(a[mid-1],a[mid]);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    if(k<=1 || r<=l+1) return;
    k-=2;
    int mid=l+r>>1;
    dfs(l, mid);
    dfs(mid, r);
    swap(a[mid-1],a[mid]);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    k-=2;
    if(k==0 || r<=l+1) return;
    int mid=l+r>>1;
    swap(a[mid-1],a[mid]);
    dfs(l, mid);
    dfs(mid, r);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    if(k<=0 || r<=l+1) return;
    k-=2;
    int mid=l+r>>1;
    dfs(l, mid);
    dfs(mid, r);
    swap(a[mid-1],a[mid]);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    if(k>2)dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    k--;
    if(k==0 || r<=l+1) return;
    int mid=l+r>>1;
    dfs(l, mid-1);
    dfs(mid, r);
    if(r-l==1) swap(a[l],a[r]), f[l]=1, f[r]=1;
    if(f[mid-1]==0 && f[mid]==0) swap(a[mid-1],a[mid]), f[mid-1]=f[mid]=1;
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}

/*
int M[105][105],n,m,k,ans,mi;
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1; i<=n; ++i){
        for(int j=1; j<=m; ++j){
            cin>>M[i][j];
        }
    }
    for(int j=1; j<=m; ++j){
        int x=0, v=0, q=0;
        for(int i=1; i<=n; ++i){
            if(M[i][j]==1){
                int u=0;
                for(int t=i; t<=n && t<i+k; ++t){
                    if(M[t][j]==1) u++;
                }
                if(u>x){
                    x=u,  q=v;
                }
                v++;
            }
        }
        ans+=x, mi+=q;
    }
    cout<<ans<<" "<<mi<<endl;
    return 0;
}
*/

/*
int n,ans,a[N],sum[N];
map<int,int> f;
char s[N];

int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>s;
    for(int i=0; i<n; ++i){
        if(s[i]=='0') a[i+1]=-1;
        else a[i+1]=1;
    }
    f[0]=0;
    for(int i=1; i<=n; ++i){
        sum[i]=sum[i-1]+a[i];
        if(sum[i]==0) ans=max(ans, i);
        if(f[sum[i]]==0) f[sum[i]]=i;
        else{
            ans=max(ans, i-f[sum[i]]);
        }
    }
    cout<<ans<<endl;
    return 0;
}
*/

/*
int n,k,x,a[N],ans;
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>k>>x;
    for(int i=1; i<=n; ++i){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1; i<=n-k; ++i){
        ans+=a[i];
    }
    ans+=k*x;
    cout<<ans<<endl;
    return 0;
}
*/


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    k--;
    if(k==0 || r<=l+1) return;
    int mid=l+r>>1;
    dfs(l, mid);
    dfs(mid, r);
    if(r-l==2) swap(a[l],a[r-1]), f[l]=1, f[r-1]=1;
    if(f[mid-1]==0 && f[mid]==0) swap(a[mid-1],a[mid]), f[mid-1]=f[mid]=1;
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    if(k<=0 || r<=l+1) return;
    k-=2;
    int mid=l+r>>1;
    dfs(l, mid);
    dfs(mid, r);
    swap(a[mid-1],a[mid]);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include "iostream"
#include "iomanip"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define step(x) fixed<< setprecision(x)<<
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ll long long
#define endl ("\n")
#define ft first
#define sd second
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const ll mod=1e9+7;
const ll INF = 1e18+1LL;
const int inf = 1e9+1e8;
const double PI=acos(-1.0);
const int N=1e5+100;

int n,k,a[N],f[N];

void dfs(int l, int r){
    if(k<=1 || r<=l+1) return;
    k-=2;
    int mid=l+r>>1;
    swap(a[mid-1],a[mid]);
    dfs(l, mid);
    dfs(mid, r);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    if((k&1)==0 || k>=2*n){
        cout<<-1;
        return 0;
    }
    int d=log2(n)+1;
    for(int i=1; i<=n; ++i) a[i]=i;
    dfs(1, n+1);
    for(int i=1; i<=n; ++i) cout<<a[i]<<" ";
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n, K;
int getnum(int l, int r)
{
	if (r <= l)
	{
		puts("miaomiaomiao?");
		while (1);
	}
	if (r - l == 1)return 1;
	int mid = (l + r) / 2;
	return getnum(l, mid) + getnum(mid, r) + 1;
}
int a[N];
bool flag;
void solve(int l, int r)
{
	if (r - l == 1)return;
	if (K == 0)
	{
		sort(a + l, a + r);
		return;
	}
	if (K >= 2)
	{
		K -= 2;
		int mid = (l + r) / 2;
		if(a[l] < a[mid])swap(a[l], a[mid]);
		solve(l, mid);
		solve(mid, r);
	}
	else flag = 0;
}
int main()
{
	while (~scanf("%d%d", &n, &K))
	{
		/*
		int totnum = getnum(0, n);
		//printf("totnum = %d\n", totnum);
		if (K > totnum)
		{
			puts("-1");
			continue;
		}
		*/
		for (int i = 0; i < n; ++i)a[i] = i + 1;
		flag = 1;
		--K;
		solve(0, n);
		if (!flag || K)
		{
			puts("-1");
			continue;
		}
		for (int i = 0; i < n; ++i)
		{
			printf("%d ", a[i]);
		}puts("");
	}
	return 0;
}
/*
【trick&&吐槽】

【题意】
ms(0, n)

mid = (l + r) / 2
len = r - l

【分析】

【时间复杂度&&优化】

【数据】

*/


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n, K;
int getnum(int l, int r)
{
	if (r <= l)
	{
		puts("miaomiaomiao?");
		while (1);
	}
	if (r - l == 1)return 1;
	int mid = (l + r) / 2;
	return getnum(l, mid) + getnum(mid, r) + 1;
}
int a[N];
bool flag;
void solve(int l, int r)
{
	if (r - l == 1)return;
	if (K == 0)
	{
		sort(a + l, a + r);
		return;
	}
	if (K >= 2)
	{
		K -= 2;
		int mid = (l + r) / 2;
		if(a[0] < a[mid])swap(a[0], a[mid]);
		solve(l, mid);
		solve(mid, r);
	}
	else flag = 0;
}
int main()
{
	while (~scanf("%d%d", &n, &K))
	{
		/*
		int totnum = getnum(0, n);
		//printf("totnum = %d\n", totnum);
		if (K > totnum)
		{
			puts("-1");
			continue;
		}
		*/
		for (int i = 0; i < n; ++i)a[i] = i + 1;
		flag = 1;
		--K;
		solve(0, n);
		if (!flag || K)
		{
			puts("-1");
			continue;
		}
		for (int i = 0; i < n; ++i)
		{
			printf("%d ", a[i]);
		}puts("");
	}
	return 0;
}
/*
【trick&&吐槽】

【题意】
ms(0, n)

mid = (l + r) / 2
len = r - l

【分析】

【时间复杂度&&优化】

【数据】

*/


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n, K;
int getnum(int l, int r)
{
	if (r <= l)
	{
		puts("miaomiaomiao?");
		while (1);
	}
	if (r - l == 1)return 1;
	int mid = (l + r) / 2;
	return getnum(l, mid) + getnum(mid, r) + 1;
}
int a[N];
bool flag;
void solve(int l, int r)
{
	--K;
	if (r - l == 1)return;
	if (K == 0)
	{
		sort(a + l, a + r);
		return;
	}
	if (K >= 2)
	{
		int mid = (l + r) / 2;
		if(a[0] < a[mid])swap(a[0], a[mid]);
		solve(l, mid);
		solve(mid, r);
	}
	else flag = 0;
}
int main()
{
	while (~scanf("%d%d", &n, &K))
	{
		int totnum = getnum(0, n);
		//printf("totnum = %d\n", totnum);
		if (K > totnum)
		{
			puts("-1");
			continue;
		}
		for (int i = 0; i < n; ++i)
		{
			a[i] = i + 1;
		}
		flag = 1;
		solve(0, n);
		if (!flag)
		{
			puts("-1");
			continue;
		}
		for (int i = 0; i < n; ++i)
		{
			printf("%d ", a[i]);
		}puts("");
	}
	return 0;
}
/*
【trick&&吐槽】

【题意】
ms(0, n)

mid = (l + r) / 2
len = r - l

【分析】

【时间复杂度&&优化】

【数据】

*/