semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
   int n,i,j,k,m,M,a[100000][2];
   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=0;i<n-j;i++)
      {
		  if(a[i][0]>a[n-1-j][0])
		  { 
			m=a[n-1-j][0];
			a[n-1-j][0]=a[i][0];
			a[i][0]=m;
			M=a[n-1-j][1];
			a[n-1-j][1]=a[i][1];
			a[i][1]=M; 
		  } 
	  }
	 }
	for(i=1;i<n;i++)
	{
		for(j=1;j<=i;j++)
		{
			if(a[i][0]<=a[i-j][1])
			{
				break; 
			} 
			
		} 
		if(j==i+1)
			{
				printf("no");
				break; 
			} 
	} 
	if(i==n)
	{
	     for(j=0;j<n;j++)
	    { 
          for(k=0;k<n-j;k++)
          {
		      if(a[k][1]>a[n-j-1][1])
		      { 
			    m=a[n-j-1][1];
			    a[n-j-1][1]=a[k][1];
			    a[k][1]=m;
			
		      } 
	      }
	     }
	printf("%d %d",a[0][0],a[n-1][1]);	
	} 
		return 0; 

}
int main(){
    int n,s=0,i,m,sz[50000],a[50000],b[50000],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++){
              if(b[i]>=max){
                  max=b[i];
              }
     }
    
    min=a[0];
     for(i=0;i<n;i++){
              if(a[i]<=min){
                  min=a[i];
              }
     }
    for(i=0;i<=max;i++){
        sz[i]=0;
    }
    for(i=0;i<n;i++){
        for(m=a[i];m<(b[i]);m++){
        sz[m]=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 n,i,j,k,m,l,min,max,d=1;
	int a[50001],b[50001];
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);}
	  for(k=1;k<=n;k++){
		for(j=0;j<n-k;j++){
			if(a[j]>a[j+1]){
				m=a[j];
				l=b[j];
				a[j]=a[j+1];
				b[j]=b[j+1];
				a[j+1]=m;
				b[j+1]=l;
			}
		}
	  }
	  min=a[0],max=b[0];
    for (i=0;i<n-1;i++){
		if (max<a[i+1]){
			printf("no");
          d=0;
		break ;}
	else if(max<b[i+1]){
		max=b[i+1];}
}
	if(d==1){printf("%d %d",min ,max);}
	return 0;
}
int main(){
	int n,i,j,zx,zd,t,k=1;
	int a[asd],b[asd],z[zxc];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0,zx=a[0];i<n;i++){
		if(a[i]<zx){
			zx=a[i];
		}
	}
	for(i=0,zd=b[0];i<n;i++){
		if(zd<b[i]){
			zd=b[i];
		}
	}
	for(i=0;i<=zd;i++){
		z[i]=1;
	}
	for(i=0;i<n;i++){
		for(j=0;j<=zd;j++){
			if(j>=a[i]&&j<b[i]){
				z[j]=0;
			}
		}
	}
	z[zd]=0;

	for(i=zx;i<=zd;i++){
		if(z[i]==1){
			k=k*0;
		}else{
			k=k*1;
	}
	}
	if(k==0){
		printf("no");
	}else{
		printf("%d %d",zx,zd);
	}
	return 0;
}
int main()
{
	int n,a[50000],b[50000],p=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{scanf("%d%d",&a[i],&b[i]);
	}
	int min=10000,max=1;
	for(int j=0;j<n;j++)
	{
		if(a[j]<min)
		{min=a[j];}
	    if(b[j]>max)
		{max=b[j];}
	}
    for(double e=min;e<=max;e=e+0.5)
	{ int s=0;
		for(int k=0;k<n;k++)
		{
			if(e<a[k]||e>b[k])
			{s++;}
		}
         if(s>=n)
		 {p++;}
	}
	if(p==0)
	{printf("%d %d",min,max);}
	else{printf("no");}
	return 0;
}
int main(){
 struct qujian{
	int a;
	int b;
 }q[MAX_NUM];
 int s[MAX_LEN]={0};
 int n,i,j,min_a,max_b;
 scanf("%d",&n);
 scanf("%d%d",&q[1].a,&q[1].b);
 min_a=q[1].a;
 max_b=q[1].b;
 for(j=q[1].a;j<q[1].b;j++)
	 s[j]=1;
 for(i=1;i<n;i++){
     scanf("%d%d",&q[i].a,&q[i].b);
	 if(q[i].a<min_a)
		 min_a=q[i].a;
	 if(q[i].b>max_b)
		 max_b=q[i].b;
	 for(j=q[i].a;j<q[i].b;j++)
		 s[j]=1;
 }s[max_b]=1;
 for(i=min_a;i<=max_b;i++){
	 if(s[i]==0){
		 printf("no");
	     break;
	 }
 }if(i==max_b+1)
	 printf("%d %d",min_a,max_b);
return 0;
}
int main(){
int n,c,m;
scanf("%d\n",&n);
int a[100],b[100];
for(int i=0;i<n-1;i++){
scanf("%d%d\n",&a[i],&b[i]);
}
scanf("%d%d",&a[n-1],&b[n-1]);


for(int k=1;k<=n;k++){
int e;	
for(int	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;	

}	
}
}



for(c=0;c<n-1;c++){
for(m=0;m<=c;m++){
if(b[m]>=a[c+1]){
 break;
 }else{
    continue;
}
}

if(m!=c+1){
    continue;
}else{
    break;
}
}



if(c==n-1){ 
    
for(int	k=1;k<=n;k++){
int e;	
for(int	i=0;i<n-k;i++){
if(b[i]> b[i+1]){	
e=b[i+1];	
b[i+1]=b[i];	
b[i]=e;	}}}


printf("%d %d",a[0],b[n-1]);
}else{
printf("no");
}


return 0;
}
int main()
{
	int i,j;
	int n,m;
	int min,max,tail;
	int a[50000],b[50000];
	
	
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	min=a[0];
	tail=b[0];
	max=b[0];
	for(i=1;i<n;i++)
	{
		if(a[i]<min)
		{
			min=a[i];
		}
	}
	for(i=1;i<n;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
		}
		if(b[i]<tail)
		{
			tail=b[i];
		}
	}
	for (j=0;j<n;j++)
	{
		for(i=0;i<n;i++)
		{
			if ((a[i]<=tail)&&(b[i]>=tail))
			{
				tail=b[i];
			}
		}
	}
	if(tail==max)
	{
		printf("%d %d",min,max);
	}
	else
	{
		printf("no");
	}

    return 0;
}
int main()
{
	int n,s[50000][2];
	int i,j,k;
	scanf("%d",&n);

	for(i=0;i< n;i++){
		scanf("%d%d",&s[i][0],&s[i][1]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(s[i][0]>s[j][0]){
				k=s[i][0];
				s[i][0]=s[j][0];
				s[j][0]=k;
				k=s[i][1];
				s[i][1]=s[j][1];
				s[j][1]=k;
			}
		}
	}
	k=0;
	for(i=0;i<n;i++){
		if(s[i][1]>=s[i+1][0]){
			if(s[i][1]>s[i+1][1])
				s[i+1][1]=s[i][1];
		}
		else k=1;
	}
	if(k==1)
		printf("no\n");
	else printf("%d %d\n",s[0][0],s[n-1][1]);
	return 0;
}
int main(){
    int n,i,k,z;
    z=1;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++){
        scanf("%d %d",&a[i],&b[i]);
    }
    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;
            }
        }
    }
    for(k=1;k<=n;k++){
        for(i=0;i<n-k;i++){
            if(b[i]>b[i+1]){
                e=b[i+1];
                b[i+1]=b[i];
                b[i]=e;
            }
        }
    }
   for(i=0;i<n-1;i++){
       if(a[i+1]>b[i]){
           z=0;
        }
   }
   if(z!=0){
       printf("%d %d",a[0],b[n-1]);
   }else{
       printf("no");
   }
   
    
    
    return 0;
}
int main()
{
     int n,a[50000],b[50000],m[10000],max,min,sum=0;
     int i,j,k;
     scanf("%d",&n);
     for(i=1;i<=n;i++){
             scanf("%d%d",&a[i],&b[i]);
             }
     for(i=1;i<=10000;i++){
             m[i]=0;}
     for(j=1;j<=n;j++){
             for(k=a[j]+1;k<=b[j];k++){
                     m[k]=1;}
                     }
     max=1,min=10000;                
     for(i=1;i<=10000;i++){
             if(m[i]==1){
                         if(i<min){
                                   min=i;}
                         if(i>max){
                                   max=i;}
                                   }
                                   }
     for(j=min;j<=max;j++){
             if(m[j]==0){
                         sum++;}
                         }
     if(sum==0){
                printf("%d %d",min-1,max);}
        else printf("no");

     return 0;
}
int main()
{
    int n,i,a,b,t,l=0;
    int ai[50000],bi[50000],sz[10000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&ai[i],&bi[i]);
        }
    for(t=0;t<10000;t++){
        sz[t]=0;
        }
    for(i=0;i<n;i++){
        if(ai[i]==bi[i]){
        t=ai[i]-1;  
        sz[t]=1;
        }
        for(t=ai[i]-1;t<bi[i]-1;t++){
            sz[t]=1;
        }
    }
    a=ai[0];
    b=bi[0];
    for(i=1;i<n;i++){
        if(a>ai[i])
        a=ai[i];
        if(b<bi[i])
        b=bi[i];
    }
    sz[b-1]=1;
    for(t=a-1;t<b;t++){
        if(sz[t]==0){
           printf("no");
           l=1;
           break;
        }
    }
    if(l==0)
    printf("%d %d",a,b);    

    return 0;
}
int main()
{
	int i, j, n, max = 0, min = 1000;
	int sz[10000] = { 0 };
	struct  qujian{
		int x, y;
	} a[50000];
	scanf("%d\n", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d\n", &a[i].x, &a[i].y);
	}
	for (i = 0; i<n; i++){
		if (min>a[i].x){
			min = a[i].x;
		}
		if (max<a[i].y){
			max = a[i].y;
		}
	}
          sz[min]=1;
     for (i = min + 1; i<=max;i++){
		for (j = 0; j < n; j++)
                             {
			if ((i - 0.5) >= a[j].x&&i <= a[j].y){
				sz[i] = 1;
			}			
                              }
	}
	for (i = min; i <= max; i++){
		if (sz[i] == 0){
			printf("no");
			break;
		}
		else if (i == max){

				printf("%d %d", min, max);
		 }
                  }

	
	return 0;
}
int main(){
	int n=0,i,s=0;
	scanf("%d",&n);
	struct qujian{
		int x,y;
	}e,qujians[50000];
	for(i=0;i<n;i++){
		scanf("%d%d",&qujians[i].x,&qujians[i].y);
	}
	int k;
	for(k=1;k<=n;k++){
		for(i=0;i<n-k;i++){
			if(qujians[i].x>qujians[i+1].x){
				e=qujians[i+1];
				qujians[i+1]=qujians[i];
				qujians[i]=e;
			}
		}
	}
    int p=qujians[0].x;
	for(i=0;i<n;i++){
		if(qujians[i].x<p){
			p=qujians[i].x;
		}
	}
	for(i=0;i<n;i++){
		if(qujians[i+1].x>qujians[i].y){
			s=1;
			break;
		}else{
			qujians[i+1].x=qujians[i].x;
			if(qujians[i].y>qujians[i+1].y){
				qujians[i+1].y=qujians[i].y;
			}else{
				qujians[i+1].y=qujians[i+1].y;
			}
		}
	}
		
		
	
	int m=qujians[0].y;
	for(i=0;i<n;i++){
		if(qujians[i].y>m){
			m=qujians[i].y;
		}
	}

	if(s==1){
		printf("no");
	}else{
		printf("%d %d",p,m);
	}
	return 0;

}
int main()
{
	int n,k,min,max,sz1[50000],sz2[50000];
	double e;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&sz1[i],&sz2[i]);
		if(i==0){
			max=sz2[i];
			min=sz1[i];
		}else{
			if(max<sz2[i])
				max=sz2[i];
			if(min>sz1[i])
				min=sz1[i];
		}
	}
	e=min+0.5;
	for(int j=0;max-e>0;j++){
		for(k=0;k<n;k++){
			if(e>sz1[k]&&e<sz2[k])
				break;
		}
		if(k==n){
			printf("no");
			break;
		}
		e++;
	}
	if(e>max)
		printf("%d %d",min,max);
	return 0;
}
int main(){
    int t,i,j,n,p,max;
    int a[1000],b[1000];
    scanf("%d",&n);
    for (i=1;i<=n;i++){
        scanf("%d%d",&(a[i]),&(b[i]));
    }
    for (i=1;i<=n;i++){
        for (j=1;j<=n-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;
            }
        }
    } max=b[1]; p=1;
    for (i=2;i<=n;i++){
        if (a[i]<=max){
            if (b[i]>max){max=b[i];}    
        }else {p=0;break;}
    }
    if (max<b[n]){max=b[n];}
    if (p==0){
        printf("no");
    }else{printf("%d %d",a[1],max);}
    return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int *left=(int*)malloc(sizeof(int)*n);
	int *right=(int*)malloc(sizeof(int)*n);
	int i,j;
	int tmp,sign=0,min,max;	
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&left[i],&right[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if(left[j]<left[j-1])
			{
				tmp=left[j];
				left[j]=left[j-1];
				left[j-1]=tmp;
				tmp=right[j];
				right[j]=right[j-1];
				right[j-1]=tmp;
			}
		}
	}
	min=left[0];
	max=right[0];
	for(i=1;i<n;i++)
	{
		for(j=1;j<n;j++)
		{
			if(left[j]<=max)
			{
				if(right[j]>max)
				{
					max=right[j];
				}
				sign++;
			}
		}
		if(sign==0)
			break;
		else if(i==n-1&&sign==n-1)
			sign=1;
		else
			sign=0;
	}
	if(i==n&&sign==1)
		printf("%d %d\n",min,max);
	else
		printf("no\n");
	free(left);
	free(right);
	return 0;
}
int main(){
int n,i,j,k,max,min,z,t;
double d;
z=0;
scanf("%d",&n);
int a[n],b[n];
for(i=0;i<n;i++){
    scanf("%d%d",&a[i],&b[i]);
    }
min=a[0];
max=b[0];
for(i=1;i<n;i++){
    if(a[i]<min){min=a[i];}
    if(max<b[i]){max=b[i];}
}
int sz[10000];
for(i=min;i<=2*max-min;i++){sz[i]=0;}
for(d=min;d<=max;d=d+0.5){
    k=0;
    for(j=0;j<n;j++){
        if(d<=b[j]&&d>=a[j]){k++;}
    }
    if(k!=0){t=min+2*(d-min);
    sz[t]=1;}
}
for(i=min;i<=2*max-min;i++){
    if(sz[i]==0){z++;}
}
if(z==0){printf("%d %d",min,max);}
else printf("no");
return 0;
}
int main()
{
    int n,i,k,t,e,p,q,s=0,a,b;
    scanf("%d",&n);
    struct point
    {
           int x,y;
    }
    points[50000];
    for(i=0;i<n;i++)
    {
           scanf("%d%d",&a,&b);
           points[i].x=a;
           points[i].y=b;
    }
    for(k=1;k<=n;k++)
    {
           for(i=0;i<n-k;i++)
           {
                   if(points[i].x>points[i+1].x)
                   {
                          t=points[i].x;
                          points[i].x=points[i+1].x;
                          points[i+1].x=t;
                          e=points[i].y;
                          points[i].y=points[i+1].y;
                          points[i+1].y=e;
                   }
           }
    }
    p=points[0].x;
    for(i=0;i<n;i++)
    {
            if(points[i].y>=points[i+1].x)
            {
                if(points[i].y>points[i+1].y)
                {
                     points[i+1].y=points[i].y;
                }
            }
            else
            {
                     s++;
            }
    }
    
    q=points[n-1].y;
    if(s==0)
    {
           printf("%d %d",p,q);
    }
    else
    {
           printf("no");
    }
  
    return 0 ;
}
int main()
{
    int n,a,b,c,d,e,f,g;
	int z[50000][2];
	int x[1000];
    scanf("%d",&n);
	e=0;
	for(a=0;a<=n-1;a++)
	{
		scanf("%d",&z[a][0]);
		scanf("%d",&z[a][1]);
	}
	for(b=0;b<=n-2;b++)
	{
		for(a=0;a<=n-2-b;a++)
		{
        if (z[a][0]>z[a+1][0])
		{
			c=z[a][0];
			d=z[a][1];
			z[a][0]=z[a+1][0];
			z[a][1]=z[a+1][1];
			z[a+1][0]=c;
			z[a+1][1]=d;
		}
		}
	}
    for(a=1;a<=n-1;a++)
	{
		x[0]=0;
		for(b=0;b<=a-1;b++)
		{
            if (z[b][1]>=z[a][0]) x[0]+=1;
		}
		if (x[0]==0) e=1;
	}
	if (e==1)
	{
		printf("no");
		return 0;
	}
	f=z[0][0];
	g=z[0][1];
	for(a=0;a<=n-1;a++)
	{
        if (g<z[a][1]) g=z[a][1];
	}
	printf("%d %d",f,g);
	return 0;
}
int main(){
int n,a[50000],b[50000];
int i,x,y,j;
int m,p;
double e,f;
m=100;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
x=a[0],y=b[0];
for(i=0;i<n;i++){
if(a[i]>x){
x=a[i];
}
if(b[i]>x){
x=b[i];
}
if(a[i]<y){
y=a[i];
}
if(b[i]<y){
y=b[i];
}
}

for(i=y;i<=x;i++){
e=i+0.1;
f=i-0.1;
for(j=0;j<n;j++){
p=1;
if(i==y){
if(e<=b[j]&&e>=a[j]){
p=0;
break;
}
}
if(i==x){
if(f<=b[j]&&f>=a[j]){
p=0;
break;
}
}
if(i<x&&i>y){
if(e<=b[j]&&e>=a[j]){
p=0;
break;
}
}

}
if((j=n-1)&&p==1){
m=0;
printf("no");
break;
}
}
if(m!=0){
printf("%d %d",y,x);
}
return 0;
}
int main(){
	int a[50000],b[50000];
	int n,i,r=0,k,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(k=0;k<n-1;k++){
		for(i=n-1;i>k;i--){
			if(a[i]<a[i-1]){
				x=a[i];
				a[i]=a[i-1];
				a[i-1]=x;
				x=b[i];
				b[i]=b[i-1];
				b[i-1]=x;
			}
		}
	}
	for(i=0;i<n-1;i++){
		if(b[i]<a[i+1]){
			r++;
		}
		if(b[i]>=b[i+1]){
			x=b[i];
			b[i]=b[i+1];
			b[i+1]=x;
		}
	}
	if(r!=0){
		printf("no");
	}else{
		printf("%d %d",a[0],b[n-1]);
	}
	return 0;
}
int main()
{
    int n,a[10001],b[10001],c[10001],i,j,max,M,m,temp,k,s,h=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d%d",&a[i],&b[i]);
    for(j=0;j<n;j++)
    {
        for(i=n-1;i>h-1;i--)
            if(a[i]<a[i-1])
            {
                k=a[i-1];
                a[i-1]=a[i];
                a[i]=k;
                s=b[i-1];
                b[i-1]=b[i];
                b[i]=s;
            }
        h++;
    }

    for(i=1;i<n;i++)
        if(b[i]<b[i-1])
        {
            a[i]=a[i-1];
            b[i]=b[i-1];
        }
    m=a[0];
    M=b[n-1];

    for(i=0;i<n;i++)
    {
        if(i==0)
            max=b[i];
        if(b[i]<a[i+1]&&b[i]>=max)
        {
            printf("no");
            return 0;
        }
        if(i!=n-1&&b[i+1]>max)
            max=b[i+1];
    }
    printf("%d %d",m,M);
}
int main(){
int n,i,min=0,max=0;
float j;
int a[50000],b[50000];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d\n",&a[i],&b[i]);
}
for(i=0;i<n;i++){
if(i==0){
min=a[0];max=b[0];
}
if(a[i]<min)min=a[i];                            //?????//
if(b[i]>max)max=b[i];
}
 
for(j=min+0.0;j<=max+0.0;j=j+0.5){
  for(i=0;i<n;i++){                                           
    if(a[i]<=j&&j<=b[i])break;       
  }
  if(i==n){ printf("no");break;}
}
 
if(j>max)printf("%d %d",min,max);
return 0;
}
int a[10000],c[50000],b[10000],d[10000],e[10000];
int main()
{
	
	int n,x,y,i,j,p,q,m=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		d[i]=a[i];
		e[i]=b[i];
	}
	 
	for(j=1;j<n;j++)
	{
		for(i=0;i<n-1;i++)
		{
			if(d[i]<=d[i+1])
			{
				x=d[i+1];
				d[i+1]=d[i];
				d[i]=x;
			}
			if(e[i]>=e[i+1])
			{
				y=e[i+1];
				e[i+1]=e[i];
				e[i]=y;
			}
		}
	}
	p=d[n-1];
	q=e[n-1];
	
	for(i=p;i<q;i++)
	{
		c[i]=0;
	}

	
	for(i=0;i<n;i++)
	{
		for(j=a[i];j<b[i];j++)
		{
			c[j]=j;
		}
	}


	for(i=p;i<q;i++)
	{
		if(c[i]==0)
		{
			m=m+1;
		}
	}
	if(m==0)
	{
		printf("%d %d",p,q);
	}else
	{
		printf("no");
	}

	return 0;
}
void main()
{
	int extent[10001],n,i,min,max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int a,b,j;
		scanf("%d %d",&a,&b);
		if(i==0) 
		{
			min=a;
			max=b;
		}
		else
		{
			if(min>a) min=a;
			if(max<b) max=b;
		}
		for(j=2*a-1;j<=2*b-1;j++)
			extent[j]=1;
	}
	for(i=2*min-1;i<=2*max-1;i++)
		if(!extent[i]) break;
	if(i==2*max) printf("%d %d\n",min,max);
	else printf("no");
}
int main(){
	int n;
	int a[10001];
	int b[10001];

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&(a[i]),&(b[i]));
	}
	for(int k=1;k<=n;k++){
	for(int i=0;i<n-k;i++){
		if(a[i]>a[i+1]){
			int e=0,f=0;
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
			f=b[i];
			b[i]=b[i+1];
			b[i+1]=f;
		}
	}
	}
	int c=0,d;
	d=b[0];
	for(int i=1;i<n;i++){		
		if(d>=a[i]){
			c++;
		}
		if(d<b[i]){
			d=b[i];
		}
	}
	if(c==n-1){
		printf("%d %d",a[0],d);
	}else{
		printf("no");
	}	
	return 0;
}
int main(){
	int a[10000],b[10000],c[10000]={0},i,k,m,n,p,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<n;i++){
		if(a[i]<b[i])
			for(k=a[i];k<b[i];k++){
				c[k]=1;
			}
	}
	for(m=1;m<=9999;m++){
		if(c[m]==1){
			x=m;
			break;}
	}
	for(m=9999;m>=1;m--){
		if(c[m]==1){
			p=m;
			break;}
	}
	for(i=x;i<=p;i++){
		if(c[i]==0){
			printf("no");
			break;}
	}
	if(i==p+1){
        printf("%d %d",x,p+1);}
	return 0;
}
int main(){
	int n,a[5001],b[5001],num[10001]={0};
	scanf("%d",&n);
	for(int x=0;x<n;x++){
		scanf("%d %d",&a[x],&b[x]);
		for(int y=a[x];y<=b[x];y++){
			num[y]=1;
		}
	}
	int e;
	for(int k1=1;k1<=n;k1++){
		for(int i1=0;i1<n-k1;i1++){
			if(a[i1]>a[i1+1]){
				e=a[i1+1];
				a[i1+1]=a[i1];
				a[i1]=e;
			}
		}
	}
    for(int k2=1;k2<=n;k2++){
		for(int i2=0;i2<n-k2;i2++){
			if(b[i2]>b[i2+1]){
				e=b[i2+1];
				b[i2+1]=b[i2];
				b[i2]=e;
			}
		}
	}
	for(int m=0;m<n-1;m++){
		if(b[m]==(a[m+1]-1)){
			printf("no\n");
			return 0;
		}
	}
	for(int z=a[0];z<=b[n-1];z++){
		if(num[z]==0){
			printf("no\n");
			break;
		}else {
            if(z==b[0]){
			  printf("%d %d",a[0],b[n-1]);
			}
		}

	}



	return 0;
}
int main()
{
	int n,c,d,i,j,max,sum;
	int a[50001],b[50001];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=i;j<=n;j++)
		{
			if(a[i]>a[j])
			{
				c=a[i];
				d=b[i];
				a[i]=a[j];
				b[i]=b[j];
				a[j]=c;
				b[j]=d;
			}
		}
	}
	sum=0;
	max=b[1];
	for(i=1;i<=n;i++)
	{
		if(a[i]>max)
		{
			sum=sum+1;
			break;
		}
		else
		{
			if(b[i]>max)
			{
				max=b[i];
			}
		}
	}
	if(sum!=0)
	{
		printf("no");
	}
	else
	{
		printf("%d %d",a[1],max);
	}
	return 0;

}
int main(){
    int n,i,p,e,s;
    scanf("%d\n",&n);
    struct qj{
        int a,b;
    }qj[50000];
    for(i=0;i<n;i++){
        scanf("%d %d\n",&(qj[i].a),&(qj[i].b));
    }
    for(p=0;p<n;p++){
        for(i=n-1;i>p;i--){
            if(qj[i].a<qj[i-1].a){
                e=qj[i].a;
                qj[i].a=qj[i-1].a;
                qj[i-1].a=e;
            }
            if(qj[i].b<qj[i-1].b){
                e=qj[i].b;
                qj[i].b=qj[i-1].b;
                qj[i-1].b=e;
            }
        }
    }
    s=0;
    for(i=1;i<n;i++){
        if(qj[i].a>qj[i-1].b){s=1;}
    }
    if(s==1){
        printf("no");
    }else{printf("%d %d",qj[0].a,qj[n-1].b);}
    return 0;
}
int main(){
int n,i,k,e,w,j,min,max;
scanf("%d\n",&n);
int a[n],b[n];
for(i=0;i<n;i++){
if(i==n-1){
scanf("%d %d",&(a[i]),&(b[i]));
}
else{
scanf("%d %d\n",&(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];
a[i]=a[i+1];
a[i+1]=e;
w=b[i];
b[i]=b[i+1];
b[i+1]=w;
}
}
}
min=a[0];
max=b[0];
j=1;
for(i=1;i<n;i++){
    if(min<=a[i]){
    if(max<a[i]){
      j=0;
    }
    else{
    if(max<=b[i]){
    max=b[i];
    }
    }
    }
   if(min>a[i]){
   if(b[i]<min){
   j=0;
   }
   else{
   min=a[i];
   if(max<=b[i]){
   max=b[i];
}
}
}
}
if(j==0){
printf("no");
}
else{
printf("%d %d",min,max);
}
return 0;
}
int main()
{
	int n,i,flag,min,max,j;
	int a[50000],b[50000];
	double k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	min=a[0];
	max=b[0];
	for(i=1;i<n;i++)
	{
		if(a[i]<min) min=a[i];
		if(b[i]>max) max=b[i];
	}
	flag=1;
	for(k=min;k<=max;k=k+0.5)
	{
		for(j=0;j<n;j++)
		{
			if((k>=a[j])&&(k<=b[j])) 
			{
				flag=1;
				break;
			}
			else flag=0;
		}
		if(flag==0) 
		{
			printf("no");
			break;
		}
	}
	if(flag==1)
	{
	printf("%d %d",min,max);
	}
	return 0;
}
int main(){
  int n,i,k,e,t,s,a[50000],b[50000];
  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];
        a[i]=a[i+1];
        a[i+1]=e;
        e=b[i];
        b[i]=b[i+1];
        b[i+1]=e;
        }
     }
  }
t=0;
s=0;
  for(i=1;i<n;i++){
     for(k=0;k<i;k++){
       if(b[k]>=a[i]){
        s=s+1;
       }
     }
     if(s!=0){
       t=t+1;
       s=0;
    }
  }
  if(t!=n-1){
    printf("no");
  }else{
   for(k=1;k<=n;k++){
     for(i=0;i<n-k;i++){
        if(b[i]<b[i+1]){
        e=b[i];
        b[i]=b[i+1];
        b[i+1]=e;
        }
     }
  }
   printf("%d %d",a[0],b[0]);
  }
  return 0;
}
int main() 
{ int n,a[5001],b[5001],c[5001],i,j,m; 
  m=0; 
  scanf("%d",&n); 
  for(i=0;i<n;i++) 
  {
	  scanf("%d%d",&(a[i]),&(b[i])); 
  } 
  for(i=1;i<n;i++) 
  { 
	  for(j=0;j<n-i;j++) 
	  { 
		  if(a[j]>a[j+1]) 
		  { 
			  int e; 
			  e=a[j]; 
			  a[j]=a[j+1]; 
			  a[j+1]=e; 
			  e=b[j]; 
			  b[j]=b[j+1]; 
			  b[j+1]=e; 
		  } 
	  } 
  } 
  
  //???c[]??????????????????????????, c[i]????i???????(??0--??i-1)?????????
  c[1] = b[0];                      
  for( i = 2; i < n; i++ )
  {
	  if( b[i-1] > c[i-1] ) 
		  c[i] = b[i-1];
	  else
		  c[i] = c[i-1];
  }

  for( i = 1; i < n; i++ )
  {
	  if( a[i] > c[i] ) 
	  { 
		  m++; 
	  } 
  } 
  if(m==0) 
  { 
	  if( b[n-1] > c[n-1] )
	    printf("%d %d",a[0],b[n-1]); 
	  else
        printf("%d %d",a[0],c[n-1]);
  }
  else
  { 
	  printf("no"); 
  } 
  return 0; 
}
int main()
{int n,ai=0,bi=0,i,j,a[2][50000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	scanf("%d %d",&a[1][i],&a[0][i]);
	}
	for(i=n-1;i>0;i--)
	{	for(j=0;j<i;j++)
		{	if(a[1][j]>a[1][i])
			{	ai=a[1][j];
				bi=a[0][j];
				a[1][j]=a[1][i];
				a[0][j]=a[0][i];
				a[1][i]=ai;	
				a[0][i]=bi;
			}	
		}
	}
	ai=a[1][0];
	bi=a[0][0];
	for(i=0;i<n-1;i++)
	{	if(a[1][i+1]>bi)
		{	printf("no");
			return 0;
		}
		else
		{	if(a[0][i+1]>bi)
			bi=a[0][i+1];
		}
		
	}
	printf("%d %d",ai,bi);
	return 0;
}
int main(){
	int a[50000],b[50000],c[10002],d[10000];
	int i,n,j,k=0,l=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<10002;i++){
		c[i]=0;
	}
	for(i=0;i<n;i++){
		for(j=a[i];j<b[i];j++){
			c[j]=1;
		}
	}
	for(i=0;i<10001;i++){
		if(c[i]==c[i+1]){
			continue;
		}
		if(c[i]!=c[i+1]){
			k++;
			d[l]=i;
			d[l+1]=i+1;
			l=l+2;
		}
	}
	if(k==2){
		printf("%d %d",d[2],d[3]+1);
	}else{
			printf("no");
	}
	return 0;
}
int main()
{
	int a[50000],b[50000],n,i,j;
	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<n-i-1;j++)
			 if (a[j]>a[j+1]) {int x=a[j];a[j]=a[j+1];a[j+1]=x;x=b[j];b[j]=b[j+1];b[j+1]=x;}
	int sign=1;
	for (i=1;i<n;i++)
	{
		if (a[i]>b[i-1]) {sign=0;break;}
		if (b[i-1]>b[i]) b[i]=b[i-1];
	}
	if (sign==0) printf("no\n");
	else printf("%d %d\n",a[0],b[n-1]);
	return 0;
}
int main(){
int q[50000],z[50000],i,n,k,e,zm[50000],max=0;
scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d%d\n",&q[i],&z[i]);
}
for(k=1;k<=n;k++){
  for(i=0;i<n-k;i++){
    if(q[i]>q[i+1]){
      e=q[i];
      q[i]=q[i+1];
      q[i+1]=e;
      e=z[i];
      z[i]=z[i+1];
      z[i+1]=e;
    }
  }
}

int l=n-1;
for(i=1;i<=n;i++){
  for(k=0;k<=n-i;k++){
    if(z[k]>z[max]){
      max=k;
    }
  }
  zm[l]=z[max];
  l--;
  max=0;
}
int p=0;
for(i=0;i<n-1;i++){
  if(q[i+1]<=zm[i]){
    p++;
  }
}
if(p!=n-1){
  printf("no");
}
if(p==n-1){
  printf("%d %d",q[0],zm[n-1]);
}
return 0;
}