semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main( ){
    int i,n,j,m,k=0,sum=0,result;
    int x[10000],y[10000],z[50000];
    for(i=0;i<50000;i++){
    z[i]=0;
    }
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
    scanf("%d %d\n",&(x[i]),&(y[i]));
    }
 for(i=0;i<n;i++){
 for(j=x[i];j<y[i];j++){
      z[j]=1;
}
}
 while(k<=n){
      for(i=0;i<n-1;i++){
      m=i+1;
      if(x[i]>x[m]){
          j=x[i];
          x[i]=x[m];
          x[m]=j;
      }
      }
     k++;
    }
    k=0;
while(k<=n){
      for(i=0;i<n;i++){
      m=i+1;
      if(y[i]<y[m]){
          j=y[i];
          y[i]=y[m];
          y[m]=j;
      }
      }
     k++;
    }
    result=y[0]-x[0];
for(i=x[0];i<=y[0];i++){
    sum+=z[i];
}
 if(result==sum){
        printf("%d %d",x[0],y[0]);
    }else{
        printf("no");
    }
    return 0;
}
int main()
{
	int a[50001],b[50001],n,i,m,f,s;
	double e;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	s=a[0];
	for(i=0;i<n;i++)
	{
		if(s>a[i])
		{
			s=a[i];
		}
	}
	m=b[0];
	for(i=0;i<n;i++)
	{
		if(m<b[i])
		{
			m=b[i];
		}
	}
    
    for(e=s+0.5;e<m;e++)
	{
		for(i=0,f=0;i<n;i++)
		{
			if(a[i]<e&&b[i]>e)
			{
				f=1;
			}
		}
        if(f==0)
		{
			break;
		}
	}
	if(f==1)
	{
		printf("%d %d",s, m);
	}else {
	printf("no");
	}
    return 0;
}
int main()
{
    int n,k,e,f,a[max],b[max];
    scanf("%d",&n);
    int i;
    for(i=1;i<=n;i++){
        scanf("%d %d\n",&(a[i]),&(b[i]));
    }
    for(k=1;k<=n;k++){
        for(i=1;i<=n-k;i++){
            if(a[i]>a[i+1]){
                e=a[i];
                a[i]=a[i+1];
                a[i+1]=e;
            }
            if(b[i]>b[i+1]){
                f=b[i];
                b[i]=b[i+1];
                b[i+1]=f;
            }
        }
    }
    int h;
    h=1;
    for(i=1;i<n;i++){
        if(b[i]<a[i+1]){
            h=0;
        }
    }
    if(h==1){
                printf("%d %d",a[1],b[n]);
    }else{
            printf("no");
    }
    return 0;
}
int main()
{
	int n,i;
	int a[50000][2];
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i][0],&a[i][1]);
	}
    int t;
	for(int k=1;k<=n;k++){
			for(int x=0;x<n-k;x++){
				if(a[x][0]>a[x+1][0]){
					t=a[x][0];
					a[x][0]=a[x+1][0];
					a[x+1][0]=t;
					
					t=a[x][1];
					a[x][1]=a[x+1][1];
					a[x+1][1]=t;

				}
			}
	}
int bi=0;
int max=a[0][1];
for(i=1;i<n;i++){
	if(a[i][0]>max){
		printf("no");
        bi=1;
		break;
	}else{
		if(a[i][1]>max)
			max=a[i][1];
	}
}
if(bi==0)
    printf("%d %d",a[0][0],max);
return 0;
}
int main()
{
	int n,a,b,p,q,s,e,f;
	int m=0;
	int sz[50000][2];
    scanf("%d",&n);
	for(b=0;b<n;b++)
    {
		for(a=0;a<2;a++)
        {
			scanf("%d",&sz[b][a]);
		}
	}
	
	
	for(s=1;s<=n;s++)
	{
		for(b=0;b<n-s;b++)
		{
		if(sz[b][0]>sz[b+1][0])
		{
		e=sz[b+1][0];f=sz[b+1][1];
        sz[b+1][0]=sz[b][0];sz[b+1][1]=sz[b][1];
		sz[b][0]=e;sz[b][1]=f;
		}
		}
	}

     
    
	p=sz[0][0];
     q=sz[0][1];
	     for(b=1;b<n;b++)
    {
	
			
			 if((p<=sz[b][0])&&(q>=sz[b][0])&&(q<=sz[b][1]))
			{

			q=sz[b][1];
			m++;
			}
            
           else if((p<=sz[b][0])&&(q>=sz[b][1]))
			{
			p=p;
			q=q;
			m++;
			}
           
            else  
			{   m=0;
				printf("no");
			    break;
			}

	}
     
	if(m!=0) 
		printf("%d %d",p,q);
return 0;
}
int main(){
    int n,i,j,A[50000][2],a,b,c=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&A[i][0],&A[i][1]);
    }
    a=A[0][0];b=A[0][1];
    for(i=0;i<n;i++){
        for(j=1;j<n;j++){
            if(!(a>A[j][1]||b<A[j][0])){
                if(a>A[j][0]){
                    a=A[j][0];
                }
                if(b<A[j][1]){
                    b=A[j][1];
                }
            }
        }
    }
    for(i=0;i<n;i++){
        if(a>A[i][1]||b<A[i][0]){c++;}
    }
    if(c!=0){
        printf("no");
    }else{
        printf("%d %d",a,b);
    }
    return 0;
}
int main(){
    int n,i,j,s,m,h=0;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++){ 
      scanf("%d%d",&a[i],&b[i]);
     }
    for(j=1;j<n;j++){
      for(i=0;i<n-j;i++){
       if(b[i]>b[i+1]){
         s=b[i+1];
         b[i+1]=b[i];
         b[i]=s;
         m=a[i+1];
         a[i+1]=a[i];
         a[i]=m;
        }
       }
     }
   for(i=n-2;i>=0;i--){
      if(b[i]>=a[n-1]&&a[i]<a[n-1]){
       a[n-1]=a[i];
      }
      if(b[i]<a[n-1]){
       h=1;
      }
    }
   if(h==0){
    printf("%d %d",a[n-1],b[n-1]);
    }
    if(h==1){
    printf("no");
    }
    return 0;
}
int main(){
	int n,i;
	scanf("%d",&n);
	int m[50000],q[50000];
	for (i=0;i<n;i++){
		scanf("%d%d",&m[i],&q[i]);
	}
	int a,b;
	a=m[0];
	b=q[0];
	for(i=1;i<n;i++){
		if(m[i]<a){
			a=m[i];
		}
		if(q[i]>b){
			b=q[i];
		}
	}
	int k;
	int c[50000];
	int d[50000];
	for (i=10*a;i<=10*b;i++){
		c[i]=1;
	}
	for (i=0;i<n;i++){
		for(k=10*m[i];k<=10*q[i];k++){
			d[k]=1;}
	}
	int f=1;
	for	(i=10*a;i<=10*b;i++){
		if(c[i]!=d[i]){
			f=0;
			break;
		}
	}
	if(f==0){printf("no\n");
	}
	else{printf("%d %d",a,b);
	}	

	return 0;
}
int main()

{

int n;

scanf("%d",&n);

int a[n],b[n];

int i;

for(i=0;i<n;i++){

   scanf("%d %d ",&a[i],&b[i]);

}

int k;

int p,q;

for(k=1;k<n;k++){

  for(i=0;i<n-k;i++){

    if(a[i]>a[i+1]){

       p=a[i];

       q=b[i];

       a[i]=a[i+1];

       b[i]=b[i+1];

       a[i+1]=p;

       b[i+1]=q;}
}
}

int m,t;

m=a[0];

t=b[0];

for(i=1;i<n;i++){

  if(a[i]<=t&&b[i]>t){

    t=b[i];

  }

   else if(a[i]>t){

       printf("no\n");

       return 0;

      }

  }

printf("%d %d",m,t);

return 0;

}
int main(){
    int n,k,e,i,c=0;
    scanf("%d",&n);
    int a[n];
    int b[n];
    for(i=0;i<n;i++){
        scanf("%d",&(a[i]));
        scanf("%d",&(b[i]));
    }
    for(k=0;k<=n;k++){
        for(i=0;i<n-k;i++){
            if(a[i]>a[i+1]){
                e=a[i];
                a[i]=a[i+1];
                a[i+1]=e;
                e=b[i];
                b[i]=b[i+1];
                b[i+1]=e;
            }else if(a[i]==a[i+1]){
                if(b[i]>b[i+1]){
                    e=b[i];
                    b[i]=b[i+1];
                    b[i+1]=e;
                }
            }
        }
    }
    for(i=0;i<n;i++){
        if(a[i+1]<=b[i]){
            a[i+1]=a[i];
            if(b[i+1]<=b[i]){
                b[i+1]=b[i];
            }
            c=c+1;
        }else{
            if(c>0){
                printf("%d %d",a[i],b[i]);
            }else if(c==0){
                printf("no");
            }
            break;
        }
    }
    return 0;
}
int main()
{
struct qujian{
 int x;
 int y;
} sz[50000],e;
 int n;
 scanf("%d",&n);
 int i;
for(i=0;i<n;i++)
 {
 scanf("%d",&sz[i].x);
 scanf("%d",&sz[i].y);
  }
int j,k;
for(k=1;k<=n;k++)
 {
 for(j=0;j<n-k;j++)
   {
   if(sz[j].x>sz[j+1].x)
    {
     e=sz[j+1];
     sz[j+1]=sz[j];
     sz[j]=e;
     }
   }
 }
for(i=0;i<n-1;i++)
 {
   if(sz[i].y>=sz[i+1].y)
    {
      sz[i+1].y=sz[i].y;
      sz[i+1].x=sz[i].x;
     }
   else if(sz[i].y>=sz[i+1].x&&sz[i].y<=sz[i+1].y)
     {
     sz[i+1].x=sz[i].x;
      }
   else if(sz[i].y<sz[i+1].x)
     {
      printf("no");
      return 0;
      }
 }
 if(i==n-1)
  {
  printf("%d %d",sz[n-1].x,sz[n-1].y);
  }
return 0;
}
int main(){
	int m,n,i,j,a,b,c,d;
	int s[10001]={0};;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		for(j=a+1;j<=b-1;j++){
			s[j]=1;
		}
		if(s[a]==0){
			s[a]=2;
		}
		else s[a]=1;
		if(s[b]==0){
			s[b]=2;
		}
		else s[b]=1;
	}
	for(i=1;i<10001;i++){
		if(s[i]!=0){
			c=i;
			break;
		}
	}
	for(i=10000;i>=1;i--){
		if(s[i]!=0){
			d=i;
			break;
		}
	}
	for(i=c+1;i<=d-1;i++){
		if((s[i]==0)||(s[i]==2)){
			printf("no\n");
			break;
		}

	}
	if(i==d) printf("%d %d\n",c,d);
	return 0;
}
int main(){
    int m=1,e,n,a[10000],b[10000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d\n",&a[i],&b[i]);
    }
    for(int i=0;i<n-1;i++){
       for(int k=i+1;k<n;k++){
           if(a[i]>a[k]){
               e=a[i];
               a[i]=a[k];
               a[k]=e;
           }
           if(b[i]>b[k]){
               e=b[i];
               b[i]=b[k];
               b[k]=e;
           }
       }
    }
    for(int i=0;i<n-1;i++){
        if(b[i]<a[i+1]){
            m=0;
        }
    }
    if(m==0){
        printf("no");
    }
    else{
        printf("%d %d",a[0],b[n-1]);
    }
    return 0;
}
int main()
{
	int a[100],b[100],n,i,j,p,q,d,x,y[100],k,s;
	d=0;
	scanf("%d\n",&n);
	for(i=0,j=0;i<n;i++,j++)
	{
		scanf("%d%d",&a[i],&b[j]);
	}
	for(p=0;p<n;p++)
	{
		for(i=n-1,j=n-1;i>p;i--,j--)
		{
			if(a[i]<a[i-1])
			{
				q=a[i];       
				a[i]=a[i-1];
				a[i-1]=q;
				s=b[j];
				b[j]=b[j-1];
				b[j-1]=s;
			}
		}
	}
	for(i=0,j=0,k=0;i<n-1;i++,j++,k++)
	{
		y[0]=b[0];
		if(y[k]>=a[i+1]&&y[k]>=b[j+1])
		{
			x=a[0];
			y[k+1]=y[k];
		}else if(y[k]>=a[i+1]&&y[k]<b[j+1])
		{
			x=a[0];
			y[k+1]=b[j+1];
		}	
		if(y[k]<a[i+1])
		{
			printf("no");
			return 0;
		}
	}
	printf("%d %d",x,y[n-1]);
	return 0;
}
main()
{
	int a[number][2],i,j,n,c,d,min,max;
	scanf("%d",&n);
	for(i=0; i<=n-1; i++)
	{
		scanf("%d%d",&a[i][0],&a[i][1]);
	}
	for(i=0; i<=n-2; i++)
	{
		for(j=0; j<=n-2-i; j++)
		{
			if( a[j][0]>a[j+1][0] ) 
			{
				c=a[j][0];
				a[j][0]=a[j+1][0];
				a[j+1][0]=c;
				d=a[j][1];
				a[j][1]=a[j+1][1];
				a[j+1][1]=d;
			}
		}
	}
    min=a[0][0];
	max=a[0][1];
	for(i=1; i<=n-1; i++)
	{
		if(max<a[i][0])
		{
			printf("no\n");
			return 0;
		}
		if(max<a[i][1]) max=a[i][1];
	}
	printf("%d %d\n",min,max);
	return 0;
}
struct point{
	int a;
	int b;
};

int main(){
	int n,i,j=0,A,B,k;
	scanf("%d",&n);
	struct point range[n];
	for(i=0;i<n;i++){            
		scanf("%d%d\n",&(range[i].a),&(range[i].b));
	}
	A=range[0].a;     
	B=range[0].b;  
        for(k=0;k<n;k++){                  
	  for(i=1;i<n;i++){
		if(!(A>range[i].b||B<range[i].a)){
			if(B<range[i].b){
                           B=range[i].b;
                        }
			if(A>range[i].a){
			  A=range[i].a;
			}
		}
	  }
        }
 	for(i=0;i<n;i++){
          if(A>range[i].b||B<range[i].a){
             j++;
          }
        }
	if(j==0){
		printf("%d %d",A,B);
	}else{
		printf("no");
	}
	
	return 0;
}
int main(){
    int sz1[50000],sz2[50000],n,i;
    double m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&sz1[i],&sz2[i]);
    }
    int x=sz1[0],y=0;
    for(i=0;i<n;i++){
        if(x>sz1[i])x=sz1[i];
        if(y<=sz2[i])y=sz2[i];
    }
    for(m=x+0.1;m<y;m++){
        for(i=0;i<n;i++){
            if(m<=sz2[i]&&m>sz1[i]) break;
            else continue;
        }
        if(i<n) continue;
        else {printf("no");
        return 0;
        }
    }
    printf("%d %d",x,y);
    return 0;
}
int main(){ 
	int i=0,n;
	int front=0,back=0; 
	scanf("%d",&n);
	if(n<3||n>50000) {  
		printf("no");
		return 0;
	}
	int *a=(int *)malloc(n*sizeof(int)); 
	int *b=(int *)malloc(n*sizeof(int)); 
	while(i<n) { 
		scanf("%d %d",a+i,b+i); 
		if(a[i]>b[i])  {  
			printf("input error");   
			return 0;  
		}
		if((front!=back&&a[i]<front)||front==back) {  
			front = a[i];
			back  = b[i]; 
		} 
		i++;
	}
	for(i=0;i<n;i++){ 
		if(front<=a[i]&&a[i]<=back&&back<b[i]) 
		{ 
			back  = b[i];  
			i=-1; 
		}
	}
	for(i=0;i<n;i++){ 
		if(a[i]<front||b[i]>back)  {
			printf("no");
			return 0;  
}
 }
	free(a);
	free(b); 
	printf("%d %d\n",front,back);
}
int main()
{
    int n,i,k,d;
    scanf("%d",&n);
    struct qj{
        int a;
        int b;
    }qj[n],c;
    for(i=0;i<n;i++){
        scanf("%d%d",&(qj[i].a),&(qj[i].b));
    }
    d=qj[0].b;
    for(i=0;i<n;i++){
        if(qj[i].b>d){
            d=qj[i].b;
        }
    }
   for(k=1;k<n;k++){
   for(i=0;i<n-k;i++){
       if(qj[i].a>qj[i+1].a){
           c=qj[i];
           qj[i]=qj[i+1];
           qj[i+1]=c;
           
       }
   }
   }
   for(i=1;i<n;i++){
       if(qj[0].b>=qj[i].a&&qj[0].b<qj[i].b){
           qj[0].b=qj[i].b;
       }
   }
   if(qj[0].b==d){
       printf("%d %d",qj[0].a,qj[0].b);
   }else{
       printf("no");
   }
   return 0;
}
int main()
{
    int n,i,k,Max,Min;
    double j;
    scanf("%d",&n);
    int *num=(int*)malloc(n*2*sizeof(int));
    for(i=0;i<2*n;i++)scanf("%d",num+i);

     for(i=1,Max=0;i<2*n;i=i+2){if(Max<*(num+i)) Max=*(num+i);}
     for(i=0,Min=*(num);i<2*n-1;i=i+2){if(Min>*(num+i)) Min=*(num+i);}
     //printf("%d",k);
     for(j=Min;j<=Max;j=j+0.5)
    {
        for(i=0,k=1;i<2*n;i=i+2)
           {
            if(j>=*(num+i)&&j<=*(num+i+1))
                    {k=0;break;}
           }
        //printf("j=%lf k=%d\n",j,k);
        if(k) {printf("no\n");return 0;}

    }

     printf("%d %d",Min,Max);
     return 0;
}
int a[50000],b[50000];
int main()
{
	int n,i,k=1,a0,b0,result=1;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d %d",&a[i],&b[i]);
	a0=a[0];
	b0=b[0];
	for(;k<n-1;)
	{
		for(i=1;i<n;i++)
		{
			k=i;
			if(a[i]<=a0&&b[i]>=b0)
			{
				if(!(a[i]==a0&&b[i]==b0))
				{
					a0=a[i];
					b0=b[i];
					break;
				}
			}
			if(a[i]<a0&&b[i]>=a0&&b[i]<=b0)
			{
				a0=a[i];
				break;
			}
			if(a[i]>=a0&&a[i]<=b0&&b[i]>b0)
			{
				b0=b[i];
				break;
			}
		}
	}
	for(i=0;i<n;i++) if(a[i]<a0||b[i]>b0) result=0;
	if(result==1) printf("%d %d",a0,b0);
	else printf("no");
	return 0;
}
int main()
{
	int i,n,t=0;
	double m;
	int a[50000],b[50000],mina=10001,maxb=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{scanf("%d %d",&a[i],&b[i]);}
	for(i=0;i<n;i++)
	{mina=(mina<a[i])?mina:a[i],maxb=(maxb>b[i])?maxb:b[i];}
	for(m=mina;m<=maxb;m=m+0.5)
	{	
		for(i=0;i<n;i++)
		{
			if((m>=a[i])&&(m<=b[i]))
			{t++;break;}
		}
	}
	if(t==(2*(maxb-mina+1)-1))
	{
		printf("%d %d",mina,maxb);
	}
	else printf("no");
	return 0;
}
int main(){
    
    int n,i,j,e,a[50000],b[50000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
            scanf("%d %d",&a[i],&b[i]);
    }
    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;
                               e=b[i+1];
                               b[i+1]=b[i];
                               b[i]=e;
                      }
                      else if(a[i]==a[i+1]){
                               if(b[i]>b[i+1]){
                                   e=b[i+1];
                                   b[i+1]=b[i];
                                   b[i]=e;
                               }
                      }
            }
    }
    
    
    int tmp = b[0];
    for(i = 1; i < n; i++)
    {
        if(a[i] > tmp) 
            {printf("no\n");return 0;}
        if(tmp < b[i])
            tmp = b[i]; 
    }
    
    
    /*j=0;
    for(i=0;i<n-1;i++){
            if(b[i]<a[i+1])
            {
                printf("no");
                break;
            }
            else j++;
    }
    
    if(j==n-1) */printf("%d %d",a[0],tmp);
    //scanf("%d",&n);
    return 0;
}
int main()
{
	int n,i,m,k;
	int a[50000],b[50000];
scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}
		for(i=0;i<n;i++){
			for(k=i+1;k<n;k++){
				if(a[i]>a[k]){
				m=a[i];
				a[i]=a[k];
				a[k]=m;
				m=b[i];
				b[i]=b[k];
				b[k]=m;
			}
		}
       }
for(i=0;i<n-1;i++){
	if(b[i]<a[i+1]){
	printf("no");
	break;
	}else{	
		if(b[i]>b[i+1]){
			m=b[i];
				b[i]=b[i+1];
				b[i+1]=m;
		}
	}
}
if(i==n-1){
	printf("%d %d",a[0],b[n-1]);
}
return 0;
}
int main()
{
   int i,j,n,t,s,d,test;
   double g;
   int a[50001],b[50001];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
      scanf("%d%d",&(a[i]),&(b[i]));
   }
   t=10000;
   for(i=0;i<n;i++)
   {
      if(a[i]<t)
		  t=a[i];
   }
   j=0;
   for(i=0;i<n;i++)
   {
      if(b[i]>j)
		  j=b[i];
   }
   test=0;
   for(g=(double)t;g<=(double)j;g=g+0.5)
   {
	   d=0;
      for(s=0;s<n;s++)
	  {
	      if(b[s]>=g&&a[s]<=g)
			  d=1;
	  }
	  if(d==0)
	  { test++;
	  break;}
 
   }
      if(test>0){
		  printf("no\n");
	  }else{
	      printf("%d %d\n",t,j);
	  }
return 0;
}
int main(){
    int n,i,j,e,result=0,max,min,k,num=1;
	int a[3][50001];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[0][i],&a[1][i]);
	}
	max=min=a[0][0];
	for(j=0;j<2;j++){
		for(i=0;i<n;i++){
			if(a[j][i]>max)max=a[j][i];
			if(a[j][i]<min)min=a[j][i];
		}
	}
	for(j=n-1;j>0;j--){
		for(i=0;i<j;i++){
			if(a[0][i]>=a[0][i+1]){
				for(k=0;k<2;k++){
					e=a[k][i+1];
				    a[k][i+1]=a[k][i];
				    a[k][i]=e;
				}
			}
		}
	}
	
	for(i=1;i<n;i++){
		for(j=0;j<i;j++){
			if(a[1][j]>=a[0][i]){
				num++;
				break;
			}
		}
	}
	if(num==n)result=1;
	if(result==0)printf("no");
	if(result==1)printf("%d %d",min,max);

	return 0;
}
int main(){
    int n,i,k,s=0,sz[M],a[M],b[M],max,min;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&a[i],&b[i]);
    }
     max=b[0];
     for(i=0;i<n;i++){
          for(k=i+1;k<n;k++){
              if(b[k]>=max){
                  max=b[k];
              }
          }
     }
    
    min=a[0];
     for(i=0;i<n;i++){
          for(k=i+1;k<n;k++){
              if(a[k]<=min){
                  min=a[k];
              }
          }
     }
    for(i=0;i<=max;i++){
        sz[i]=0;
    }
    for(i=0;i<n;i++){
        for(k=a[i];k<(b[i]);k++){
        sz[k]=1;
        }
    }
    for(i=0;i<=max;i++){
        s+=sz[i];
    }
     if(s==(max-min)){
         printf("%d %d",min,max);
     }else{
         printf("no");
     }
     return 0;
    
}
int main()
{
int a[50000],b[50000],n,i,s,v=0,z;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
}
for(z=0;z<n;z++){
    for(i=0;i<n-1;i++){
if(a[i]>a[i+1]){
 s=a[i];
a[i]=a[i+1];
a[i+1]=s;
s=b[i];
b[i]=b[i+1];
b[i+1]=s;
}
}
}
for(i=0;i<n-1;i++){
if(b[i+1]<b[i]){
    a[i+1]=a[i];
    b[i+1]=b[i];
}
}
for(i=0;i<n-1;i++){
    if(a[i+1]>b[i]){
        v+=1;
    }
}
if(v==0){
printf("%d %d",a[0],b[n-1]);
}
if(v>0){
printf("no");
}
return 0;
}
int main()
{
	int n,i,j;
	int max=0,min=100000;
	int a[100000],b[100000];
	int flag=0;
	int c[200000]={0};
	scanf ("%d",&n);
	for(i=1;i<=n;i++)
	{	scanf ("%d",&a[i]);
	    scanf ("%d",&b[i]);
        {
		for(j=2*a[i];j<=2*b[i]-1;j=j+1)	
		{
			if(c[j]==0) {c[j]=1;}	
		}
		if(a[i]<min) min=a[i];
		if(b[i]>max) max=b[i];
		}
	}
	
	for(j=2*min;j<=2*max-1;j=j+1)
	{
		if(c[j]==0)
			{flag=1;}
			}
	if(flag==0)
		{printf("%d %d",min,max);}
	else
	{printf("no");	}
	return 0;
}
int main()
{
    int n,a[50000],b[50000],c[50000],d[50000];
    int max,min,i,j;
    double k;
    int e;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&(a[i]),&(b[i]));
        c[i]=a[i];
        d[i]=b[i];
    }
    
    for(i=0;i<(n-1);i++)
    {
        if(a[i]<a[i-1])
        {
            e=a[i];
            a[i]=a[i+1];
            a[i+1]=e;
        }
       
    }
    min=a[n-1];
    for(i=0;i<(n-1);i++)
    {
        if(b[i]>b[i+1])
        {
            e=b[i];
            b[i]=b[i+1];
            b[i+1]=e;
        }
    }
    max=b[n-1];
    
    for(k=min+0.1;k<=max;k++)
    {
        for(j=0;j<n;j++)
        {
            if(k>=c[j]&&k<=d[j])
            {
            break;
            }
            else
            {
               if(j==n-1){
                   printf("no");
                   return 0;
               }
               else{
                   continue;
               }
            }
        }
        
    }
    printf("%d %d",min,max);
    return 0;
}
int main()
{
    int a[60000],b[60000],n,i,m,p,q,s; 
    float k;
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
    }
    p=a[0];
    q=b[0];
    for(i=0;i<n;i++)
    {
        if(a[i]<p)
        {
            p=a[i];
        }
        if(b[i]>q)
        {
            q=b[i];
        }
    }
    for(k=p+0.5;k<=q;k++)
    {
        s=0;
        for(m=0;m<n;m++)
        {
            if(k<=b[m]&&k>=a[m])
            {
                s=1;
            }
            else
            {
                s=s;
            }
        }
        if(s==0)
        {
            printf("no");
            break;
        }
    }
    if(s!=0)
    {
        printf("%d %d",p,q);
    }
    return 0;
}
int main(){
	int n,i,k,z,y;
	int x[50001],d[50001],j[50001];
	scanf("%d",&n);
	for(i=0;i<=n-1;i++){
		scanf("%d%d",&x[i],&d[i]);
	}
	y=0;
	z=0;
	for(i=0;i<=n-1;i++){
		if(x[i]<x[y]){
			y=i;
		}
		if(d[i]>d[z]){
			z=i;
		}
	}
	for(i=0;i<=n-1;i++){
		for(k=x[i]+1;k<=d[i];k++){
			j[k]=1;
		}
	}
	for(k=1,i=x[y]+1;i<=d[z];i++){
		if(j[i]==1){
			k++;
		}else{
			printf("no");
			break;
		}
	}
	if(k==d[z]-x[y]+1){
		printf("%d %d",x[y],d[z]);
	}
	return 0;
}
int main(){
	int n,i,k,m,c,h;
	double e;
	int p[50001],q[50001],s[5001],t[50001];
    scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&p[i],&q[i]);
		s[i]=p[i];
		t[i]=q[i];
	}
	for(k=1;k<n;k++){
		for(i=0;i<n-k;i++){
			if(p[i]>p[i+1]){
               m=p[i];
			   p[i]=p[i+1];
			   p[i+1]=m;
			}
			if(q[i]<q[i+1]){
                c=q[i];
				q[i]=q[i+1];
				q[i+1]=c;
			}
		}
	}
    for(e=1.0*p[0];e<=1.0*q[0];e=e+0.5){
		h=0;
		for(k=0;k<n;k++){
			if(e>=1.0*s[k]&&e<=1.0*t[k])
				break;
            else
                h++;
		}
		if(h==n){
			printf("no");
			return 0;
		}
	}
	printf("%d %d",p[0],q[0]);

	return 0;
}
int main(){
    int a[10000],b[10000],c[10000]={0};
	int min=10000,max=0,i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<n;i++){
	    if(min>a[i]){
		    min=a[i];
		}
		if(max<b[i]){
		    max=b[i];
		}
	}
         c[min]=1;
	for(i=min+1;i<=max;i++){
	     for(j=0;j<n;j++){
		     if(a[j]<=(i-0.5)&&i<=b[j]){
			      c[i]=1;
			 }
		 }
	}
	for(i=min;i<=max;i++){
	    if(c[i]==0){
		    printf("no");
                       break;
		}else if(i==max){
		    printf("%d %d",min,max);
		}
	}
	return 0;
}
int main(){
int a[50000],b[50000],n,i,t,y=0,j,k,x;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
}
for(i=0;i<n-1;i++){
for(j=n-1;j>i;j--){
if(a[j]<a[j-1]){
k=a[j],x=b[j];
a[j]=a[j-1],b[j]=b[j-1];
a[j-1]=k,b[j-1]=x;
}
}
}
for(i=0;i<n-1;i++){
if(b[i]<a[i+1]){
y++;
}
if(b[i]>=b[i+1]){
t=b[i];
b[i]=b[i+1];
b[i+1]=t;
}
}
if(y!=0){
printf("no");
}else{
printf("%d %d",a[0],b[n-1]);
}
return 0;
}
int main(){
 int n;
int a[5000][2];
int i,j;
int r;
int t0,t1;
scanf("%d",&n);
for(i=0;i<n;i++)
{ for(j=0;j<2;j++)
{ 
scanf("%d ",&a[i][j]);
}
}
for(i=0;i<n-1;i++)
{ for(j=i+1;j<n;j++)
{
if(a[i][0]>a[j][0])
{
t0=a[i][0];
t1=a[i][1];
a[i][0]=a[j][0];
a[i][1]=a[j][1];
a[j][0]=t0;
a[j][1]=t1;
}
}
}
r=a[0][1];
for(i=0;i<n;i++)
{
if(a[i][1]>r){r=a[i][1];
}
if(r<a[i+1][0])
{printf("no");
}
if(r<a[i+1][0])
{break;
}
}
if(r>=a[i+1][0])
{printf("%d %d",a[0][0],r);
}
return 0;
}
int main(){
   int n;
   scanf("%d", &n);
   int a[50000], b[50000];
   int i;
   for (i=0;i<n;i++){
       scanf("%d %d", &a[i], &b[i]);
   }
   int k;
   int e;
   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;
               e=b[i+1];
               b[i+1]=b[i];
               b[i]=e;
           }
        }
       }
   int left, right;
   left=a[0];
   int m;
   m=0;
   for (i=0;i<n-1;i++){
     if (a[i+1]<=b[i]){
         m++;
         if(b[i]>b[i+1]){
             b[i+1]=b[i];
         }
     }
       }
   right=b[n-1];
   if (m==n-1){
       printf("%d %d", left,right);
   }else {
       printf("no");
       
   }
   return 0;
}
int main(){
int n,i,j,min,max,have_a_gap=0; //have_a_gap?1?,?????.

scanf("%d",&n);     //???????

struct Space{
int left,right;
} spaces[n],temp;          //????,???????????

for(i=0;i<n;i++)
{
    scanf("%d %d",&spaces[i].left,&spaces[i].right);    //???????
}

for(i=0;i<n-1;i++)//??n-1?,??
{
    for(j=0;j<n-1-i;j++)
    {
        if(spaces[j].left>spaces[j+1].left)
        {
            temp=spaces[j];
            spaces[j]=spaces[j+1];
            spaces[j+1]=temp;
        }
    }
}

min=spaces[0].left;
max=spaces[0].right;


for(i=0;i<n-1;i++)
{
    if(max<(spaces[i+1].left))    //????
    {
        have_a_gap=1;
        printf("no");
        break;
    }
    else                            //??????
    {
        if(spaces[i+1].right>max) max=spaces[i+1].right;
    }
}

if(have_a_gap==0) printf("%d %d",min,max);

return 0;
}