semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{


	int n,i;
	double k;
   int a[500];
   int b[500];
   int s,e;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
	   scanf("%d",&a[i]);
	   scanf("%d",&b[i]);
   }
   s=a[0];
   e=b[0];
    for(i=0;i<n;i++)
   {
	   if(a[i]<s)
	   {
	       s=a[i];
	   }
	   else if(b[i]>e)
	   {
		   e=b[i];
	   }
   }
	for(k=s;k<=e;k+=0.5)
	{
		for(i=0;i<n;i++)
		{
			if(k>=a[i]&&b[i]>=k)
			{
				
				break;
			}
			else if(i==n-1)
			{
				printf("no");
				return 0;
			}

		}
		if(k==e){printf("%d %d",s,e);}
	}
	
	
	return 0;

}
int main(){
    int i,j,n;
	scanf("%d",&n);
	int x[n];
	int y[n];
	for(i=0;i<n;i++){
       scanf("%d %d",&(x[i]),&(y[i]));
    }
	int min,max;
	for(j=0;j<n;j++){
	for(i=0;i<n-j;i++){
		if(x[i]>x[i+1]){min=x[i];
		                x[i]=x[i+1];
		                x[i+1]=min;
						max=y[i];
						y[i]=y[i+1];
						y[i+1]=max;
		}
	}}
	int e=x[0];
	int f=y[0];
    for(i=1;i<n;i++){
		if(x[i]<e){e=x[i];}
		if(y[i]>f){f=y[i];}
	}
	int arc=y[0];
	int m=0;
	for(i=0;i<n-1;i++){
		if(arc<x[i+1]){printf("no"); 
		               break;
		}
		else{if(arc<y[i+1]){arc=y[i+1];}
		   m++;
		}
		if(m==n-1){printf("%d %d",e,f);}
	}
return 0;
}
int main(){
  int n,a[10000],b[10000],i,k,num[50000],t=0,min,r,max,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  for(i=0;i<n;i++){
    for(k=a[i];k<=b[i];k++){
      num[t]=k;
      t++;
    }
   }
  min=a[1];
  max=a[1];
  for(r=0;r<t;r++){
    if(num[r]<min){
      min=num[r];
    }
   }
  for(r=0;r<t;r++){
    if(num[r]>max){
      max=num[r];
    }
   }
  for(r=min;r<=max;r++){
    for(i=0;i<t;i++){
      if(num[i]==r){
        c=1;
        break;
      }else{
        c=0;
      }
     }
     if(c==1)
      continue;
     else
      break;
    }
   if(c==1){
    for(r=min;r<max;r++){
    for(i=0;i<t;i++){
      if((r>=a[i])&&(r+1<=b[i])){
       c=1;
       break;
      }else{
       c=0;
      }
     }
     if(c==1)
     continue;
     else
     break;
    }
}
     
   if(c==0)
     printf("no");
   else
     printf("%d %d",min,max);
   return 0;
  }
int main(){
	int n,min,max,k;
	int sz[50000][2];
	int gh[10000];
	int i=0,j=0,r=0,o=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d %d",&sz[i][0],&sz[i][1]);
	for(i=1;i<n;i++)
		if(sz[i][0]<sz[j][0])
			j=i;
	min=sz[j][0];
	j=0;
	for(i=1;i<n;i++)
		if(sz[i][1]>sz[j][1])
			j=i;
	max=sz[j][1];
	for(k=min;(k+0.5)<=max;k=k++){
		gh[k]=0;
		for(i=0;i<n;i++)
			if((k+0.5)>=sz[i][0]&&(k+0.5)<=sz[i][1])
				gh[k]=1;
	}
	for(k=min;(k+0.5)<=max;k=k++){
		if(gh[k]==0)
			o=1;
		if(gh[k]==1)
			r++;
	}
	if(r==max-min)
		printf("%d %d",min,max);
	if(o==1)
		printf("no");
	return 0;
}
int main(){
	int n,q=0;
	int i,j;

	struct qujian{
	int begin;
	int end;
	}qujian[50000];
    
	int a[100000]={0},first,last,A=0;
	
	scanf("%d",&n);
    for(i=0;i<n;i++){
		scanf("%d%d",&qujian[i].begin,&qujian[i].end);
	}
	
	first=qujian[0].begin;
    for(i=0;i<n-1;i++){
			
		if(first>qujian[i+1].begin){
			  first=qujian[i+1].begin;
			
		}
	}
	
	last=qujian[n-1].end;
	for(i=0;i<n-1;i++){
			if(qujian[i].end>last){
			  last=qujian[i].end;
			
			}
	}
	for(i=0;i<n;i++){
		for(j=qujian[i].begin*10;j<=qujian[i].end*10;j++){
		a[j]--;
		}
	}
	
	first=first*10;
	last=last*10;
	for(i=first;i<=last;i++){
		if(a[i]==0){
		
		A=9;
		break;
		}
	
	}
	if(A==9){
	   printf("no");
	}else{
	   printf("%d %d",first/10,last/10);
	}
	return 0;
}
int n,a[50000],b[50000],c[50000]={0};
int main(){
    int n,i,j,e,max,min,l,m=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
        for(j=a[i];j<b[i];j++){
            c[j]=1;
        }
    }
for(j=1;j<=n;j++){
    for(i=0;i<n-j;i++){
        if(a[i]>a[i+1]){
            e=a[i+1];
            a[i+1]=a[i];
            a[i]=e;
        }
    }
}
for(j=1;j<=n;j++){
    for(i=0;i<n-j;i++){
        if(b[i]>b[i+1]){
            e=b[i+1];
            b[i+1]=b[i];
            b[i]=e;
        }
    }
}
max=b[n-1];
min=a[0];
l=max-min;
for(i=min;i<=max;i++){
    m=m+c[i];
    
}
if(m==l){
    printf("%d %d",min,max);
    
}
else{
    printf("no");
}
return 0;
}
int main()
{
	int n,i,input[50000][2],j,a,k,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<2;j++)
		{
			scanf("%d",&input[i][j]);
		}
	}
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(input[j][0]>input[j+1][0])
			{
				for(k=0;k<2;k++)
				{
					a=input[j][k];
					input[j][k]=input[j+1][k];
					input[j+1][k]=a;
				}
			}
		}
	}
	a=input[0][0];
	b=input[0][1];
	for(i=0;i<n-1;i++)
	{
		if(input[i+1][0]>=a&&input[i+1][0]<=b)
		{
			if(b<input[i+1][1])
				b=input[i+1][1];
		}
		else break;
	}
	if(i<n-1)
		printf("no");
	else printf("%d %d",a,b);
	return 0;
}
int main(){
  int zuo[50000],you[50000],n,i,j,a,b;
  double q;
  scanf("%d",&n);
  scanf("%d%d",&zuo[0],&you[0]); 
  a=zuo[0];
  b=you[0];
  for(i=1;i<n;i++){
       scanf("%d%d",&zuo[i],&you[i]);
       if(a>zuo[i])a=zuo[i];
       if(b<you[i])b=you[i];
   }
   for(q=a+0.1;q<b;q++){
      for(j=0;j<n;j++){
    if(zuo[j]<q&&you[j]>q)break;
}
if(j==n){printf("no");return 0;}
}
     printf("%d %d",a,b);
   return 0;
}
int main(){
int a[50000],b[50000],n,zuo,you,y,x=0,c=1,d=0;
double z;
scanf("%d",&n);
for(int i=0;i<n;i++)
{scanf("%d%d",&a[i],&b[i]);}
zuo=a[1];you=b[1];
for(int j=0;j<n;j++)
{if(a[j]<zuo)zuo=a[j];
 if(b[j]>you)you=b[j];}
z=zuo;
y=you;
for(z;z<=y;z+=0.5){
for(int k=0;k<n;k++)
{if((z<=b[k])&&(z>=a[k])){x=1;}}
     c*=x;d++;x=0;
}
if(c==0){printf("no");}
else{printf("%d %d",zuo,you);}
                     

return 0;
}
int main(){
	struct qujian{
		int a,b;
	}qj[50001];
	int n,i,k,e,f,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&qj[i].a,&qj[i].b);
	}
    for( k=1;k<=n;k++){
	    for(i=0;i<n-k;i++){
			if(qj[i].a > qj[i+1].a){
					e=qj[i+1].a;
					qj[i+1].a = qj[i].a;
					qj[i].a = e;
			}
			if(qj[i].b>qj[i+1].b){
				f=qj[i+1].b;
				qj[i+1].b=qj[i].b;
				qj[i].b=f;
 
			}
		}
	}
	for(i=0;i<n;i++){
		if(qj[i].b<qj[i+1].a){
			j=0;
			break;
		}	
	}
	if(j==0){
		printf("no");
	}
    if(j!=0){
		printf("%d %d",qj[0].a,qj[n-1].b);	
	
	}
}
int main(){
  int n,i,j,e,k,m,d,x;
   scanf("%d", &n);
  int a[n],b[n];
  double s;
 for(i=0;i<n;i++){
  scanf("%d %d", &a[i],&b[i]);
   }
 x=a[0];d=b[0];
  for(i=0;i<n;i++){
          if(a[i]<x){
            x=a[i];
           }
          if(b[i]>d){
            d=b[i];
           }
       }
  for(s=(x+0.5);s<d;s++){
        k=0;
     for(m=0;m<n;m++){
        if(s<=b[m]&&s>=a[m]){
           k=1;
           }
        else{
           k=k;
           }
        }
   if(k==0){
         printf("no");
           break;
        }
}
    if(k!=0)
    {
        printf("%d %d",x,d);
    }
 return 0;
}
int main(){
	int a[50000],b[50000],n,m,i,t,j;
	scanf("%d",&n);
	for(i=0;i<n;i++) 
		scanf("%d %d",&a[i],&b[i]);
    m=0;
		for(i=n-1;i>0;i--){
			for(j=0;j<i;j++){
			if(a[j]>a[j+1]){
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
				t=b[j];
                b[j]=b[j+1];
				b[j+1]=t;
			}
		}
		}
	for(i=0;i<n-1;i++){
        if(b[i]>=a[i+1]){
			if(b[i]>b[i+1])
				b[i+1]=b[i];
				if(i+2==n){
				m=1;
				}
		}
		if(b[i]<a[i+1]) break;
	}
		if(m!=1) printf("no");
		else printf("%d %d",a[0],b[i]);
        return 0;
}
int main()
{
    int n,tmp,i,j,s,t;
    int a[50001][3];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d %d",&a[i][0],&a[i][1]);
    
    for(j=1;j<=n;j++)
    {
        for(i=0;i<n-j;i++){
            if(a[i][0]>a[i+1][0]){
            tmp=a[i][0];
            a[i][0]=a[i+1][0];
            a[i+1][0]=tmp;
            s=a[i][1];
            a[i][1]=a[i+1][1];
            a[i+1][1]=s;
        }
    }}
    t=1;
    tmp=a[0][1];
    for(i=1;i<n;i++)
    {
        if(a[i][0]>tmp) t=0;
        else if(a[i][1]>tmp) tmp=a[i][1];
    }
    
    if(t==1){printf("%d %d",a[0][0],tmp);}
    else{
         printf("no");}

    return 0;
}
int main() {
	int n;
	scanf("%d", &n);
	int first[NUMBER];
	int second[NUMBER];
	int i=0;
	int j,k;
	int x,p;
	int y,q;
	while(i<n){
		scanf("%d %d", &first[i],&second[i]);
		i++;
	}
	for(j=(n-1);j>0;j--){
		for(k=0;k<j;k++){
			if(first[k]>first[k+1]){
				int tmpfirst;
				int tmpsecond;
				tmpfirst=first[k];
				tmpsecond=second[k];
				first[k]=first[k+1];
				second[k]=second[k+1];
				first[k+1]=tmpfirst;
				second[k+1]=tmpsecond;

			}
		}
	}
	i=0;
	while(i<n){
		p=0;
        x=second[0];
		while(p<=i){
			
			if(second[p]>=x){
				x=second[p];
				p++;
		}
			else{
				p++;
			}
		}
		if(first[i+1]<=x){
			i++;
			continue;
			
		}
		else{
			break;
		}
	}
	q=0;
	y=second[0];
	while(q<n){
           if(second[q]>=x){
				y=second[q];
				q++;
		}
			else{
				q++;
			}

	}
	if(i==n){
		printf("%d %d", first[0], y);
	}
	else{
		printf("no");
	}
		return 0;
	}
int main()
{
    int i,j,a[50000],b[50000],x[10000],A,B,n,s=0,k=0,trigger,max;
    
    scanf("%d\n",&n);
    
    for(i=0;i<10000;i++)
        x[i]=0;
    
    for(i=0;i<n;i++)
        scanf("%d%d",&a[i],&b[i]);

    
    for(j=0;j<n;j++)
    {
        
        for(i=a[j];i<b[j];i++)
            x[i]=1;
        
    }
    
    for(i=0;x[i]==0;i++)
        A=i+1;
        
    for(i=9999;x[i]==0;i--)
        B=i;

    for(i=A;i<B;i++)
    {
        
        if(x[i]==0)
        {
            
            printf("no");
            return 0;
                
        }
    
    }
    
    printf("%d %d",A,B);
    
    return 0;
}
int main()
{  

    int n;  
    int a[50000], b[50000], c[20000]={0};  
    int i, j, x=0, y=0, k=0; 


	scanf("%d",&n);  
	for(i=0;i<n;i++)
		scanf("%d %d",&a[i],&b[i]); 
	
	for(i=0; i<n; i++) { 
		for(j=0; j<20000; j++){
			if(j%2==0){
				if(j/2>=a[i]&&j/2<=b[i])
					c[j]=1;
			}else{
				if((j-1)/2>=a[i]&&(j+1)/2<=b[i])
				    c[j]=1;
			}
		}
	}

		

	for(i=0; i<=20000; i++){
		if(c[i]==1){
			x=i;
			break;
		}
	}

	for(i=20000; i>=x; i--){
		if(c[i]==1){
			y=i;
			break;
		}
	}

	for(i=x; i<=y; i++){
		if(c[i]==0){
			printf("no\n");
			break;
		}
		else {
			k++;
			continue;
		}
	}
	if(k==y-x+1)
		printf("%d %d", x/2, y/2);

	return 0;
}
int main()
{   
    int i,n,j,l=0,min=50000,max=0;
	int sz[60000],szz[60000],szzz[60000]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&sz[i],&szz[i]);
	}
	for(i=0;i<n;i++)
	{
		if(min>sz[i])min=sz[i];
		if(max<sz[i])max=sz[i];
		if(min>szz[i])min=szz[i];
		if(max<szz[i])max=szz[i];
	}
	float x[60000];
    for(i=0;i<n;i++)
	{
		for(j=sz[i],x[i]=sz[i]+0.5;j<szz[i];j++)
	   {
       if(x[i]<szz[i])
	   {szzz[j]++;}
	   x[i]++;
	   }
	}
	for(j=min;j<max;j++)
	{
		if( szzz[j]==0)
		{
			printf("no");
			return 0;
		}
	}
	printf("%d %d",min,max);
	return 0;
}
int main(){
    int q[10000];
    int m[10000];
	int i,h,a,b=0,p,s=0;
	double l;
	scanf("%d",&h);
	for (i=0;i<h;i++){
	scanf("%d%d",&q[i],&m[i]);
	}
    a=q[0];
	for(i=0;i<h;i++){
 		if (q[i]<a){
 			a=q[i];
 		}
 		}
 	for(i=0;i<h;i++){
 		if (m[i]>b){
 			b=m[i];
 		}
 		}
 	for(l=a+0.5;l<b;l++){
 		p=0;
 		for(i=0;i<h;i++){
 			if((l>=q[i])&&(l<=m[i])){
 				p++;
 			}
 		}
 		if(p>0)
 		s++;
 	}
    if(s==b-a){
 		printf("%d %d\n",a,b);
 	}else{
 	printf("no");
 	}
    return 0;
}
int main()
{
    int n,a[50000][2],b[50000][2],i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
     scanf("%d %d",&a[i][0],&a[i][1]);
                    }
    int min,max;              
    int p,q;
    for (q=1;q<=n;q++)
    {
        for(i=0;i<(n-q);i++)
        {
        if (a[i][1]>a[i+1][1])
        {
            p=a[i+1][1];
            a[i+1][1]=a[i][1];
            a[i][1]=p;            
                        }
            }
        }
        max=a[n-1][1]; 
    int e,f,s;
    for (f=1;f<=n;f++)
    {
        for (i=0;i<(n-f);i++)
        {
        if (a[i][0]>a[i+1][0])
        {
            e=a[i+1][0];
            a[i+1][0]=a[i][0];
            a[i][0]=e;            
                        }
            }
        }
        min=a[0][0];
    for (s=1;s<=n;s++)
    {
        for (i=0;i<n-s;i++)
        {
        if (a[i][0]>a[i+1][0])
        {
            e=a[i+1][0];
            f=a[i+1][1];
            a[i+1][0]=a[i][0];
            a[i+1][1]=a[i][1];
            
            a[i][0]=e;
            a[i][1]=f;            
                        }
            }
        }
    int t;
    for(i=0;i<n;i++){
			 		 if((a[0][1])>=(a[i+1][0])&&(a[i+1][1])>(a[0][1]))
			 		 {
	   				 a[0][1]=a[i+1][1];
	   				 continue;
					 }
					 if ((a[0][0]==min)&&(a[0][1]==max))
					 {
					  				    printf("%d %d",min,max);			  				 
									    break;}
                    }
     if (a[i][1]==max)
     i=1;
     else
     printf("no");
    return 0;
    }
int main(){
	int n,i,j,max,min;
	int a[MAX],b[MAX];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		if(i==0){
			min=a[i];
			max=b[i];
		}
		else{
			if(a[i]<min)
				min=a[i];
			if(b[i]>max)
				max=b[i];
		}
	}
	for(j=min;j<max;j++){
		for(i=0;i<n;i++){
			if(j+0.5>a[i]&&j+0.5<b[i])
				break;
		}
		if(i==n){
			printf("no");
			break;
		}
	}
	if(j==max)
		printf("%d %d",min,max);

}
int main()
{
	int i,j,n,a[1000],b[1000],emp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
	}
	
	for(i=n-1;i>0;i--)
	{
		for(j=i-1;j>=0;j--)
			if(a[i]<a[j])
			{
				emp=a[j];a[j]=a[i];a[i]=emp;
				emp=b[j];b[j]=b[i];b[i]=emp;
			}
	}
	
	for(i=0;i<n-1;i++)
	{
		if(b[i]<a[i+1])
		{
			printf("no");
			return 0;
		}
		else 
		{
			if(b[i]<b[i+1])
			{
				emp=a[i+1];a[i+1]=a[i];a[i]=a[i+1];
			}
			else 
			{
				emp=a[i+1];a[i+1]=a[i];a[i]=a[i+1];
				emp=b[i+1];b[i+1]=b[i];b[i]=b[i+1];
			}
		}
	}
	printf("%d %d",a[n-1],b[n-1]);
	return 0;
}
int main(){
    int i,j,a[50001],b[50001],count=0,qj[10001];
	int n,amin,bmax=0;
	scanf("%d",&n);
	for(i=0;i<10001;i++)
		qj[i]=0;
	for(i=0;i<n;i++){
	scanf("%d %d",&a[i],&b[i]);
	for(j=a[i];j<b[i];j++)
		qj[j]=1;
	}
	amin=a[0];
	for(i=0;i<n;i++){
	if(amin>a[i])
	amin=a[i];
	}
	for(i=0;i<n;i++){
	if(bmax<b[i])
	bmax=b[i];
	}
	for(i=amin;i<bmax;i++){
	if(qj[i]==0)
	count=1;
	}
	if(count==0)
		printf("%d %d\n",amin,bmax);
	else
		printf("no\n");
	return 0;
   

}
int main(){
    int n;
    scanf("%d",&n);
    int min[n],max[n];
    for (int i=0;i<n;i++)
    {
        scanf("%d %d\n",&min[i],&max[i]);
    }
    int e;
    for(int k = 1 ; k <= n ; k++){
       for(int i = 0; i < n - k; i++){
    		if(min[i] > min[i+1]){
					e = min[i+1];
					min[i+1] = min[i];
					min[i] = e;
                    e = max[i+1];
    				max[i+1] = max[i];
					max[i] = e;
			}
	   }
    }
    for(int i=0;i<n-1;i++)
    {
        if(max[i]<min[i+1]){
           printf("no");
           break;}
        else if((max[i]>max[i+1])&&(i!=n-1))
     {
	   e=max[i];
	   max[i]=max[i+1];
	   max[i+1]=e;
	 }

        if(i+1==n-1)
        printf("%d %d",min[0],max[n-1]);
    }
 return 0;
}
int main(){
	int n;
	int a[10000],b[10000];
	int i,k,e,t,min,max,s=1;

	scanf("%d",&n);
	for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
	}

	for(k=1;k<=n;k++){
		for(i=0;i<n-k;i++){
			if(a[i]>a[i+1]){
				e=a[i+1];
				a[i+1]=a[i];
				a[i]=e;
			}
			if(b[i]>b[i+1]){
				t=b[i+1];
				b[i+1]=b[i];
				b[i]=t;
			}
		}
	}
	min=a[0];
	max=b[n-1];

	for(i=0;i<n;i++){
		if(b[i]<a[i+1]){
			s=0;
			printf("no");
			break;
		}
	}
	if(s!=0){
		printf("%d %d",min,max);
	}

	return 0;
}
int main(){
	int n,i,e,h,k,m;
	struct qujian{
		int ai,bi;
	}qj[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&qj[i].ai,&qj[i].bi);
	}
	for(k=1;k<=n;k++){
	for(i=0;i<n-k;i++){
			if(qj[i].ai>qj[i+1].ai){
					e=qj[i+1].ai;
					h=qj[i+1].bi;
					qj[i+1].ai=qj[i].ai;
					qj[i+1].bi=qj[i].bi;
					qj[i].ai=e;
					qj[i].bi=h;
			}
	}
	}
	m=qj[0].bi;
	for(i=1;i<n;i++){
		if(m>=qj[i].ai){
			if(m<qj[i].bi){
				m=qj[i].bi;
		}
		}
		else {
			printf("no");
			return 0;
		}
	}
	printf("%d %d",qj[0].ai,m);
	return 0;
}
int main(){
  int n,m,i,j,a,b,len;
  int sz[6000][2];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&(sz[i][0]),&(sz[i][1]));
  }
  a=sz[0][0];b=sz[0][1];
  for(i=0;i<n;i++){
    if(a>=sz[i][0]){a=sz[i][0];}
    if(b<=sz[i][1]){b=sz[i][1];}
  }
  len=b-a;
  for(j=0;j<len;j++){
    if(m==0){break;}
    m=0;
    for(i=0;i<n;i++){
      if(sz[i][0]<sz[i][1]){
        if(sz[i][0]<=a+j&&a+j+1<=sz[i][1]){m++;}
      }
    }}
  if(m==0){printf("no");}
  else {printf("%d %d",a,b);}
  return 0;
}
int main(){
    int a[49998][2],n,i,j;
    scanf("%d",&n);
    for (i=0;i<n;i++){
       for(j=0;j<2;j++){
          scanf("%d",&a[i][j]);
       }
    }
    for (j=0;j<n;j++){
       for (i=1;i<n;i++){
          if((a[0][0]<=a[i][1]&&a[0][1]>=a[i][0])||(a[0][0]>=a[i][1]&&a[0][1]<=a[i][0])){
                    a[0][0]=(a[0][0]>a[i][0])?a[i][0]:a[0][0];
                    a[0][1]=(a[0][1]>a[i][1])?a[0][1]:a[i][1];
            }
       }
    }
    for (i=1;i<n;i++){
          if((a[0][0]>a[i][0])||(a[0][1])<a[i][1]){     
                    printf("no"); 
                    break;
          }
    }
    if (i==n){ 
          printf("%d %d",a[0][0],a[0][1]);
    }
    return 0;
}
int main(){
    int n,i,e,m,j,k,b,c;
    struct a{
        int x,y;
    }sz[50000];
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d%d\n",&sz[i].x,&sz[i].y);
    }
    for(k=1;k<n;k++){
        for(i=0;i<n-k;i++){
            if(sz[i].x>sz[i+1].x){
                e=sz[i+1].x;
                m=sz[i+1].y;
                sz[i+1].x=sz[i].x;
                sz[i+1].y=sz[i].y;
                sz[i].x=e;
                sz[i].y=m;
            }
        }
    }
    b=sz[0].y;
    c=sz[0].y;
    j=0;
    for(i=0;i<n;i++){
        if(b<sz[i].y){
            b=sz[i].y;
        }
    }
    for(i=0;i<n-1;i++){
        if(c<sz[i].y){c=sz[i].y;}
        if(sz[i].y<sz[i+1].x&&sz[i+1].x>c){
            printf("no");
            j=1;
            break;
            }
    }
    if(j==0){
        printf("%d %d",sz[0].x,b);
    }
     return 0;
}
int main()
{
int n,i,k,q,l;
scanf("%d",&n);
struct qujian{
int x,y;
}asd[50001];
for(i=0;i<n;i++)
{scanf("%d %d",&(asd[i].x),&(asd[i].y));
}
for(i=0;i<n;i++)
{for(l=0;l<n-1;l++)
{if(asd[l].x>asd[l+1].x)
{k=asd[l].x;
asd[l].x=asd[l+1].x;
asd[l+1].x=k;
}
if(asd[l].y>asd[l+1].y)
{k=asd[l].y;
asd[l].y=asd[l+1].y;
asd[l+1].y=k;
}
}
}
q=1;

for(i=asd[0].x;i<=asd[n-1].y;i++)
{for(l=0;l<n;l++)
{if(asd[l+1].x>asd[l].y)
{
if((i<=asd[l+1].x)&&(i>=asd[l].y))
{q=0;}
}
}
}
if(q==1)
{printf("%d %d",asd[0].x,asd[n-1].y);}

else if(q==0)
{printf("no");}

return 0;
}
int main()
{
  int i,j,a,b,c[50000],n,m[50000],x,y;
  a=0;
  b=0;
  x=0;
  y=10000;
   scanf("%d",&n);
  for(i=0;i<n;i++)
  {
	  scanf("%d ",&c[i]);
   scanf("%d",&m[i]);
  }
  for(i=0;i<n;i++)
  {
	  if(c[i]<=y){
     y=c[i];
	  }
	  if(m[i]>=x) {
		  x=m[i];
	  }
   }
  for(i=y;i<x;i++)
  { 
	  for(j=0;j<n;j++){
		  if(i+0.5>=c[j]&&i+0.5<=m[j]){
      break;
      }
	  }if(j==n) {
		  break;
	  }
  }
	  if(i==x)  {
		  printf("%d %d",y,x);
	  }
	  else {
		  printf("no");
	  }
return 0;
}
int main(){
int n,a[50001],b[50001],c[50001],x,d;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
x=a[0];
d=b[0];
for(int i=0;i<n;i++){
if(a[i]<x){x=a[i];}
if(b[i]>d){d=b[i];}
}
for(int i=x;i<d;i++){
c[i]=1;
}
for(int i=0;i<n;i++){
for(int k=a[i];k<b[i];k++){
c[k]=0;
}
}
int s=0;
for(int i=x;i<d;i++){
s+=c[i];
}
if(s==0){
printf("%d %d",x,d);
}else{
printf("no");
}
return 0;
}
int main()
{
	struct a{
		int x,y;
	}
	a[5000];
	int n,i,c,d,j,h,x,y,r[5000],t[5000];
	double f;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		a[i].x=x;
		a[i].y=y;
	
	r[i]=a[i].x;
	t[i]=a[i].y;}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[j].x<a[i].x){
				c=a[i].x;
				a[i].x=a[j].x;
				a[j].x=c;
			}
			if(a[j].y>a[i].y){
				d=a[i].y;
				a[i].y=a[j].y;
				a[j].y=d;
			}
		}
	}
	for(i=a[0].x;i<a[0].y;i++){
	f=i*1.0+0.1;h=0;
		for(j=0;j<n;j++){
			if(f<r[j]||f>t[j]){
              h++;
			 }
		}
		if(h==n){
			
			printf("no");
			return 0;
		}
		
	}
	if(i==a[0].y){
		printf("%d %d",a[0].x,a[0].y);
	}
	
	return 0;
	

}
int main(){
 int n,a[50000],b[50000],i,j,t1,t2,c,d,k;
 char e='x';
 scanf("%d",&n);
 d=0;
 i=0;
 while(i<n){
  scanf("%d%d",&a[i],&b[i]);
  i=i+1;
 }
 for(j=0;j<n-1;j=j+1){
                       for(i=0;i<n-1-j;i=i+1){
                                            if(a[i]>a[i+1]){
                                                            t1=a[i];
                                                            t2=b[i];
                                                            a[i]=a[i+1];
                                                            b[i]=b[i+1];
                                                            a[i+1]=t1;
                                                            b[i+1]=t2;
                                            }
                       }
    }
    i=0;
    while(i<n-1){
               if(b[i]<a[i+1]){
                               e='y';
                               break;
                               }
               else if(b[i]>b[i+1]){
                    b[i+1]=b[i];
                      }
               i=i+1;
    }
    if(e=='y'){
                        printf("no");
    }
    if(e=='x'){ 
     printf("%d %d",a[0],b[n-1]);
    }
 return 0;
}
int main(){
    int n,start[10000],end[10000],e,f,s;
    scanf("%d",&n);
    for (int i=0;i<n;i++){
        scanf("%d %d",&start[i],&end[i]);
    }
    int max=end[0];
    for(int i=1;i<n;i++){
        if(end[i]>max){
            max=end[i];}}
    for(int k=1;k<=n;k++){
        for(int i=0;i<n-k;i++){
            if(start[i]>start[i+1]){
                e=start[i+1];        f=end[i+1];
                start[i+1]=start[i]; end[i+1]=end[i];
                start[i]=e;          end[i]=f;
            }}}
    int min=start[0];
    for(int i=1;i<n;i++){
        if(start[i]<=end[i-1]){
            if(end[i]<end[i-1]){end[i]=end[i-1];};
        }else{s=0;break;}
        if(i==n-1){s=1;}
        }
    if(s==0){printf("no");}
    if(s==1){printf("%d %d",min,max);}
}
int main(){
int n,k,i,e1,e2,t,max;
struct{
	int a;int b;
	}p[60000];
scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%d %d",&p[i].a,&p[i].b);
	}
for(k=1;k<=n;k++){
	for(i=0;i<n-k;i++){
		if(p[i].a>p[i+1].a){
			e1=p[i+1].a;
			p[i+1].a=p[i].a;
			p[i].a=e1;
			e2=p[i+1].b;
			p[i+1].b=p[i].b;
			p[i].b=e2;
			}
		}
	}
for(i=1;i<n;i++){
	for(t=0;t<i;t++){
		if(p[i].a<=p[t].b)
			break;
		while(t==i-1){
			if(p[i].a>p[t].b){
				printf("no");
				return 0;
				}
			}
		}
	}
max=0;
for(i=0;i<n;i++){
if(p[i].b>max)
max=p[i].b;
}
printf("%d %d",p[0].a,max);
return 0;
}
int main(){
	int n,i,k,m,y;
	int a[50005],b[50005],c[50005],d[50005];
	double x;
	int f,g=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		c[i]=a[i];
		d[i]=b[i];
	}
	for(i=1;i<n;i++){
		for(k=1;k<=n-i;k++){
			if(c[k+1]<c[k]){
				m=c[k];
				c[k]=c[k+1];
				c[k+1]=m;
			}
			if(d[k+1]<d[k]){
				y=d[k];
				d[k]=d[k+1];
				d[k+1]=y;
			}
		}
	}
	for(x=c[1];x<=d[n];x+=0.5){
		f=0;
		for(i=1;i<=n;i++){		
			if(x>=a[i]&&x<=b[i]){
				f++;
			}
		}
		if(f!=0){
			g++;
		}
	}
	if(g==(d[n]-c[1])*2+1){
		printf("%d %d",c[1],d[n]);
	}else{
		printf("no");
	}	
	return 0;
}
struct Interval {
	int a, b;
} interval[MAXLEN], output[MAXLEN];

int cmp(const void *__a, const void *__b)
{
    struct Interval *_a = (struct Interval *) __a;
    struct Interval *_b = (struct Interval *) __b;
    if (_a -> a == _b -> a)
        return _a -> b - _b -> b;
    return _a -> a - _b -> a;
}

int main()
{
	int cases, left, right, cnt, i;
	scanf("%d", &cases);
	for (i = 0; i < cases; i ++)
	{
		scanf("%d %d", &interval[i].a, &interval[i].b);
	}
	qsort(interval, cases, sizeof(struct Interval), cmp);

	left = interval[0].a;
	right = interval[0].b;
	cnt = 0;
	for (i = 1; i < cases; i ++)
	{
		if (interval[i].a > right)
		{
            printf("no\n");
            return 0;
		}
		else
		{
			right = MAX(right, interval[i].b);
		}
	}
    printf("%d %d\n", left, right);
	return 0;
}
int main(){
	struct qj{
		int lp;
		int rp;
	}qj[50000];
	int n,i,j,maxr,minl,sig;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&qj[i].lp,&qj[i].rp);
	}
	minl=qj[0].lp;
	maxr=qj[0].rp;
	for(i=0;i<n;i++){
		if(minl>qj[i].lp){
			minl=qj[i].lp;
		}
		if(maxr<qj[i].rp){
			maxr=qj[i].rp;
		}
	}
	sig=1;
	int sign[50000]={0};
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(j!=i){
			if(qj[i].lp==minl) sign[i]=1;
			if(qj[i].lp<=qj[j].rp&&qj[i].lp>=qj[j].lp){
				sign[i]=1;
			}}
		}
	}
	for(i=0;i<n;i++){
		if(sign[i]==0){
			sig=0;
		}
	}
	if(sig==0){
		printf("no");
	}
	else{
	
	printf("%d %d",minl,maxr);
	}
	return 0;
}