#include <iostream>
using namespace std;
int ic,end2=0;
int fun (int n,int A[100][2],int b[100])
{
int min1=999;
for(int i=1;i<=n;i++)
{
if(A[i][1]<min1&&b[i]==0)
{
min1=A[i][1];
ic=i;
}
}
b[ic]=1;
return ic;
}
int main()
{
int n,begin1,end1;
cout<<"please cout n"<<endl;
cin>>n;
cout<<"please cout begin and end"<<endl;
cin>>begin1>>end1;
int A[100][2];
int b[100];
for(int i=1;i<=n;i++)
{
b[i]=0;
cout<<"please cout "<<i<<" begin and end"<<endl;
cin>>A[i][0]>>A[i][1];
}
int s=fun(n,A,b);
while(end2!=end1)
{
if(A[s][0]>=end2)
{
cout<<s<<"and"<<A[s][0]<<"and"<<A[s][1]<<endl;
b[s]=1;
end2=A[s][1];
}
s=fun(n,A,b);
}
//cout << s<< endl;
return 0;
}