semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(){
int i,j,a[50001],x,y,k=0,l=0,m,n,q=0;
for(i=0;i<50001;i++){a[i]=0;}
scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d %d",&x,&y);
  for(j=x;j<y;j++){a[j]=1;}
}
for(i=0;i<50001;i++){if(a[0]==1||(a[i-1]!=1&&a[i]==1)){
   j=i;
   while(a[j]==1){j++;}
   for(k=j;k<50001;k++){if(a[k]==1){printf("no");q=1;break;}}
   if(q==0){printf("%d %d",i,j);break;}
}} 
return 0;
}
//??????????????????????


int getMin(int ai[], int ais[])//?????
{
    int i, min = 0;
	for (i = 1; i < MAX && ai[i] != -1; i++) {
		if (ai[i] < ai[min])
			min = i;
	}
	ais[min] = 0;
	return min;
}
int getMax(int bi[])//?????
{
	int i, max = 0;
	for (i = 1; i < MAX && bi[i] != -1; i++) {
		if (bi[i] > bi[max])
			max = i;
	}
	return max;
}
int hasEqual(int a, int ai[], int ais[]) {
	int i;
	for (i = 0; i < MAX; i++) {
		if (ai[i] <= a && ais[i] == 1) {
			ais[i] = 0;
			return i;
		}
	}
	return -1;
}
int main() {
	int ai[MAX], bi[MAX];
	int aischeck[MAX];
	int n = 0, i, temp;
	for (i = 0; i < MAX; i++)//???
	{
		ai[i] = -1;
		bi[i] = -1;
		aischeck[i] = 1;
	}
	int mi, ma, min, max;
	scanf("%d", &n);
	while (n > MAX) {
		scanf("%d", &n);
	}
	for (i = 0; i < n; i++) {
		scanf("%d%d", &ai[i], &bi[i]);
		while (ai[i] > bi[i])//????????????????
		{
			printf("??????????:\n");
			fflush(stdin);
			scanf("%d%d", &ai[i], &bi[i]);
		}
	}
	mi = min = getMin(ai, aischeck);
	ma = max = getMax(bi);
	temp = hasEqual(bi[min], ai, aischeck);
	while (temp != -1)//????
	{
		temp = hasEqual(bi[temp], ai, aischeck);
		if (bi[temp] == bi[ma]) {
			printf("\n%d %d", ai[mi], bi[ma]);
			return 0;
		}
	}
	printf("no\n");
}


/*
int main(){
    int n,min,max;
    int add=0;
    int a[100000];
    int b[100000];
    int sz[100000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
   // printf("%d%d\n",a[i],b[i]);    
}
    for(int i=0;i<n;i++){
        if(i==0)min=a[i];
        else if(i!=0&&a[i]<min)
            min=a[i];
            
    }
    for(int i=0;i<n;i++){
        if(i==0)max=b[i];
        else if(i!=0&&b[i]>max)
            max=b[i];
            
    }
    for(int i=min;i<=max;i++){
        sz[i]=1;
    }
    for(int i=0;i<n;i++){
    for(int j=a[i]+0.5;j<=b[i];j++){
        sz[j]=0;
    }
    }
    for(int i=min;i<=max;i++){
        add=add+sz[i];
    }
    if(add>0)printf("no");
    else printf("%d %d",min,max);
}




*/
int main(){
int n,i,k;
int 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=1;i<=n-k;i++){
		if(b[0]<a[i]||a[0]>b[i]){
		}else{
			if(a[0]<=a[i]){
				a[i]=a[n-k];
				a[n-k]=0;
			}else{
				a[0]=a[i];
				a[i]=a[n-k];
				a[n-k]=0;
			}
			if(b[0]>=b[i]){
				b[i]=b[n-k];
				b[n-k]=0;
			}else{
				b[0]=b[i];
				b[i]=b[n-k];
				b[n-k]=0;
			}
			break;
		}
	}
}
if(a[1]==0){
	printf("%d %d",a[0],b[0]);
}else{
	printf("no\n");
}
	return 0;
}
int main(){
    int n,i,j,h,p=1;
    scanf("%d",&n);
    int z[n];
    int y[n];
    for(i=0;i<n;i++){
        scanf("%d %d",&z[i],&y[i]);
    }
    for(j=1;j<=n;j++){
        for(i=0;i<n-j;i++){
            if(z[i]>z[i+1]){
                h=z[i];
                z[i]=z[i+1];
                z[i+1]=h;
            }
           if(y[i]>y[i+1]){
               h=y[i];
               y[i]=y[i+1];
               y[i+1]=h;
           }}}
          for(i=0;i<n-1;i++){
              if(z[i+1]>y[i]){
                  printf("no");
                  p=0;
                  break;
              }
          }
          if(p==1){
              printf("%d %d",z[0],y[n-1]);
          }
         return 0;
}
int main()
{
    int n,x=1;
    int a[5000],b[5000];
    int i,j,p;
    double t;
    scanf("%d",&n);
    
                 
for(i=0;i<n;i++)
          {
                      scanf("%d %d",&a[i],&b[i]);
                          }
           
           
           
          int min=a[0];
           for(i=0;i<n;i++)
           {
                 if(a[i]<min)
                 {
                                  min=a[i];
                                  }          
                           }
                         
                 int max=b[0];
                 for(i=0;i<n;i++)
                 {
                                 if(b[i]>max)
                                 {
                                                  max=b[i];
                                                  }
                                 }
                int sz[5000]={0};
for(t=min+0.5,p=0;t<=max-0.5;t++,p++){
                             
                              for(i=0;i<n;i++){
                                               if(t>a[i]&&t<b[i]){
                                                              sz[p]=1;
                                                                  }
                                              
                                               }
                              if(sz[p]==0)
                              {
                                          x=0;
                                          printf("no");
                                          }
                              
                              }
if(x==1){
         printf("%d %d",min,max);
         }
  
         return 0;
         }
int main(){
int n,k,i,j,p,q,min,max;
scanf("%d",&n);
int sz[10000],a[100],b[100];
for(i=0;i<=10000;i++){sz[i]=0;}
for(i=0;i<n;i++){scanf("%d %d",&(a[i]),&(b[i]));
for(k=2*a[i];k<=2*b[i];k++){sz[k]=1;}
}
for(i=1;i<=n;i++){
for(j=0;j<n-1;j++){if(a[j+1]<a[j]){p=a[j+1];a[j+1]=a[j];a[j]=p;}}}
min=a[0];
for(i=1;i<=n;i++){
for(j=0;j<n-1;j++){if(b[j+1]>b[j]){q=b[j+1];b[j+1]=b[j];b[j]=q;}}}
max=b[0];
for(i=2*a[0];i<=2*b[0];i++){if(sz[i]!=1){printf("no");return 0;}}
printf("%d %d",min,max);
return 0;}
int main()
{
	int n,a[50000],b[50000];
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	int shuzhou[10000];
	for(i=0;i<10000;i++)
	{
		shuzhou[i]=0;
	}
	int m;
	for(i=0;i<n;i++)
	{
		for(m=a[i]*2;m<=b[i]*2;m++)
		{
			shuzhou[m]=1;
		}
	}
    int min=a[0],max=b[0];
	for(i=0;i<n;i++)
	{
			if(a[i]<min)
			{
				min=a[i];
			}
		
	}
	for(i=1;i<n;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
		}
	}
	int panduan=1;
	for(i=min*2;i<=max*2;i++)
	{
		if(shuzhou[i]==0)
		{
			panduan=0;
			break;
		}
	}
	if (panduan==0)
	{
		printf("no");
	}
	if(panduan==1)
	{
		printf("%d %d",min,max);
	}
	return 0;
}
int main()
{
    int n,i,k,e,m,c,max,z,a;
    double j;	
    struct qj{
		int a,b;
	}qj[50000];
          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].a;
		qj[i].a=qj[i+1].a;
		qj[i+1].a=e;
		m=qj[i].b;
		qj[i].b=qj[i+1].b;
		qj[i+1].b=m;
		}
	}
}
max=0;
for(i=0;i<n;i++)
{
	if(max<qj[i].b)
      max=qj[i].b;
}
c=0;
for(j=qj[0].a+0.5;j<max;j++)
{
	z=0;
	for(i=0;i<n;i++)
	{
	if((j<qj[i].b)&&(j>qj[i].a))
           z=1;
	}
	if(z==1)
		c++;
}
if(c==(max-(qj[0].a)))
{
	printf("%d %d",(qj[0].a),max);
}
else{
	printf("no");
}

	return 0;

}
int main()
{
    int n,i,a,b,s,t;
    double l;
    scanf("%d",&n);
    int q[n],p[n];
    for(i=0;i<n;i=i+1){
        scanf("%d%d",&(q[i]),&(p[i]));
    }
    a=q[0];
    for(i=0;i<n;i=i+1){
        if(q[i]<a){
            a=q[i];
        }
    }
    b=0;
    for(i=0;i<n;i=i+1){
        if(p[i]>b){
            b=p[i];
        }
    }
    s=0;
    for(l=a+0.5;l<b;l=l+1){
        t=0;
        for(i=0;i<n;i=i+1){
            if((l>=q[i])&&(l<=p[i])){
                t=t+1;
            }
        }
        if(t>0){
        s=s+1;
        }
    }
    if(s==b-a){
        printf("%d %d\n",a,b);
    }else{
        printf("no");
    }
    return 0;
}
int main(){
    int n,i,u,k,e,p;
    int a[60000],b[60000];
    scanf("%d",&n);
    p=0;
    for(i=0,u=0;i<n;i++,u++){
        scanf("%d %d",&(a[i]),&(b[u]));
    }
    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;
            }
        }
    }
    for(k=1;k<n;k++){
        for(u=0;u<n-k;u++){
            if(b[u]>b[u+1]){
                e=b[u];
                b[u]=b[u+1];
                b[u+1]=e;
            }
        }
    }
    for(i=1,u=0;i<n;i++,u++){
        if(b[u]<a[i]){
            printf("no");
            break;
        }else{
            p=p+1;
        }
         if(p==n-1){
         printf("%d %d",a[0],b[n-1]);
         
         }    
    }
    return 0;
}
int main()
{
	int n,i,k,p,q,m;
	scanf("%d\n",&n);
	int qj[2][n];
	for(i=0;i<n;i++){
		scanf("%d%d\n",&qj[0][i],&qj[1][i]);
		}
	for(i=0;i<n;i++){
		for(k=0;k<n-i-1;k++){
			m=k+1;
			if(qj[0][k]>qj[0][m]){
				p=qj[0][m];
				qj[0][m]=qj[0][k];
				qj[0][k]=p;
				q=qj[1][m];
				qj[1][m]=qj[1][k];
				qj[1][k]=q;
				}
			}
		}
	for(k=0;k<n-1;k++){
			m=k+1;
			if(qj[0][m]>qj[1][k]) {
				printf("no");
				return 0;
			}
			else{
				if(qj[1][k]>qj[1][m]){
					qj[1][m]=qj[1][k];
					qj[0][m]=qj[0][k];
				}
			}
		}
	printf("%d %d",qj[0][0],qj[1][n-1]);	
	return 0;
}
int main()
{
	struct qujian
	{
		int zen,xiao;
	} a[10000];
	int i,n,b,c,t,j,min,max,m;
	scanf("%d",&n);
	t=0;
	max=0;
	m=0;
    for (i=1;i<=n;i++){
	   scanf("%d %d",&b,&c);
		   if (t==0){
			   min=b;
		       t=1;
		   }
		   if (b<min) min=b;
		   if (c>max) max=c; 
	   for (j=b;j<c;j++){
		   a[j].zen=1;
		   a[j].xiao=1;
	   }
	   a[c].zen=1;
     
	}
      for (j=min;j<max;j++)
		   if ((a[j].zen!=1) || (a[j].xiao!=1)){
			   m=1;
			   printf("no\n");
			   break;
		   }
       if (m==0) printf("%d %d\n",min,max);
	return 0;
}
int main()
{
	int n;
	float num, a[50000], b[50000], sum = 0, min, max;
	cin >> n;
	cin >> a[0] >> b[0];
	min = a[0];
	max = b[0];
	for (int i = 1; i < n; i ++)
	{
		cin >> a[i] >> b[i];
		min = a[i] > min ? min : a[i];
		max = b[i] > max ? b[i] : max;
	}
	num = min;
	for (float j = min; j <= max; j = j + 0.5)
	{
		for (int i = 0; i < n; i ++)
		{
			if (a[i] <= j && j <= b[i])
				sum ++;
		}
		if (sum == 0)
			break;
		sum = 0;
		num = num + 0.5;
	}
	if (num == max + 0.5)
		cout << min << " " << max << endl;
	else
		cout << "no" << endl;
	return 0;
}
int main(){
	int n,i,min,max=0,j=1,k,t=0;
	int a[10001][2];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a[i][0],&a[i][1]);
	}
	min=a[0][0];
	for(i=0;i<n;i++){
		for(k=0;k<(n-1);k++){
			if(a[k][0]>a[k+1][0]){
				t=a[k][0];
				a[k][0]=a[k+1][0];
				a[k+1][0]=t;
				
			}
			if(a[k][1]>a[k+1][1]){
				t=a[k][1];
				a[k][1]=a[k+1][1];
				a[k+1][1]=t;
			}

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

		if(a[i+1]<=b[i]){
			if(b[i+1]<=b[i]){
				a[i+1]=a[i];
				b[i+1]=b[i];
			}else{
				a[i+1]=a[i];
				b[i+1]=b[i+1];
			}
			
		}else{
			e++;
		}
	}
	if(e!=0){
		printf("no");
	}else{
		printf("%d %d",a[n-1],b[n-1]);
	}
	
	
	return 0;
}
int main()
{
	struct qujian
	{
		int num1;
		int num2;
	};
	struct qujian quj[50000];
	int n,i,j,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&quj[i].num1);
		scanf("%d",&quj[i].num2);
	}
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(quj[j].num1>quj[j+1].num1)
			{
				a=quj[j+1].num1;
				b=quj[j+1].num2;
				quj[j+1].num1=quj[j].num1;
				quj[j+1].num2=quj[j].num2;
				quj[j].num1=a;
				quj[j].num2=b;
			}
		}
	}
	a=quj[0].num1;
	b=quj[0].num2;
	for(i=1;i<n;i++)
	{
		if(quj[i].num1<=b&&quj[i].num1>=a)
		{
			if(quj[i].num2>b)
				b=quj[i].num2;
		}
		if(quj[i].num1>b)break;
	}
	if(i==n)
	{
		printf("%d %d",a,b);
	}
	else printf("no");
	return 0;
}
int main(){
int n,i,j,t,max,min;
int a[50000],b[50000],c[10000];
t=1;
max=1;
min=10000;
scanf("%d",&n);
for (i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
if (a[i]<min){
min=a[i];
}
if (b[i]>max){
max=b[i];
}
for (j=a[i];j<b[i];j++){
c[j]=1;
}
}
for (j=min;j<max;j++){
if (c[j]!=1){
t=0;
}
}
if (t==0){
printf ("no");
}else{
printf ("%d %d",min,max);
}
return 0;
}
int main()
{
	int n,i,x,y,j,k=0,p,q,l=0;
	int a[10000]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		for(j=0;j<10000;j++){
			if(j<=y-1&&j>=x){
				a[j]=1;
			}
		} 
	}
	for(j=0;j<10000;j++){
		if(a[j]==1){
			k++;
			if(k==1){
				p=j;
			}
			if(a[j+1]==0){
				q=j;
				l++;
				break;
			}
		}
	}
	for(j=q+1;j<10000;j++){
		if(a[j]==1){
			l++;
		}
	}
	if(l==1){
		printf("%d %d",p,q+1);
	}else{
		printf("no");
	}
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	struct qujian {
		int a,b;
	}qujian[50001];
	int i;
	for(i=0;i<n;i++){
		scanf("%d %d",&(qujian[i].a),&(qujian[i].b));
	}
	int max,min;
	min=qujian[0].a;
	max=qujian[0].b;
	for(i=0;i<n;i++){
		if(min>qujian[i].a){
			min=qujian[i].a;
		}
		if(max<qujian[i].b){
			max=qujian[i].b;
		}
	}
	int m;
	double s;

	for(s=1.0*min;s<=max;s=s+0.5){
		for(i=0;i<n+1;i++){
			if(i==n){
				m=0;
				break;
			}
			if(s<=qujian[i].b&&s>=qujian[i].a){
				break;
				m=1;
			}
		}
		if(m==0){
			printf("no");
			break;
		}
		if(s==max){
			printf("%d %d",min,max);
		}
	}
	return 0;
}
int main(){
	
int a[1000],b[1000],n,i,all[20000],j,m;
	
for(i=0;i<20000;i++)
	
	
all[i]=0;
	
   m=0;
	
scanf("%d",&n);
	
for( i=0;i<n;i++){
	
	
scanf("%d%d",&a[i],&b[i]);
	
	
for(j=0;j<20000;j++){
	
	
	
if(j>=2*a[i]&&j<=2*b[i])
	
	
	
	
all[j]=1;
	
	
}
	
}
	
int x,y;
	
for(i=1;i<20000;i++){
	
	
if(all[i]==0&&all[i+1]==1&&all[i-1]==1){
	
	
	
m++;
	
	
	
break;
	
	
}
	
	
else{
	
	
	
if(all[i]==1&&all[i+1]==1&&all[i-1]==0)
	
	
	
	
x=i/2;
	
	
	
if(all[i]==1&&all[i+1]==0&&all[i-1]==1)
	
	
	
	
y=i/2;
	
	
}
	
}
	
if(m==0)
	
	
printf("%d %d",x,y);
	

	
else{
	
	
printf("no");
	
}
	
getchar();
	
getchar();
	
return 0;
}
int main()
{
	int n,i,j;
	int x[50000][2];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	  for(j=0;j<2;j++)
	  {
	    scanf("%d",&x[i][j]);
	  }
	}
	int y[50000][2];
	int max,min;
	for (i=0;i<n;i++)
	{
	  y[i][0]=x[i][0];
	  y[i][1]=x[i][1];
	}
	for(i=0;i<n-1;i++)
	{
	  if(i==n-2)
	  {
	    min=(y[i][0])<=(y[i+1][0])?y[i][0]:y[i+1][0];
	  }
	  if((y[i][0])<=(y[i+1][0]))
	  {
	    min=y[i][0];
		y[i][0]=y[i+1][0];
		y[i+1][0]=min;
	  }
	}
	for(i=0;i<n-1;i++)
	{
	  if(i==n-2)
	  {
	    max=(y[i][1])>=(y[i+1][1])?y[i][1]:y[i+1][1];
	  }
	  if((y[i][1])>=(y[i+1][1]))
	  {
	    max=y[i][1];
		y[i][1]=y[i+1][1];
		y[i+1][1]=max;
	  }
	}
	int k=1;
	int maxmax,minmin,maxmin,minmax;
	if(n==2)
	{
	  maxmax=(x[0][1])>=(x[1][1])?(x[0][1]):(x[1][1]);
	  minmin=(x[0][0])<=(x[1][0])?(x[0][0]):(x[1][0]);
	  maxmin=(x[0][1])<(x[1][1])?(x[0][1]):(x[1][1]);
	  minmax=(x[0][0])>(x[1][0])?(x[0][0]):(x[1][0]);
	  if(maxmin>=minmax)
	  {
	    printf("%d %d",minmin,maxmax);
	  }
	  if(maxmin<minmax)
	  {
	    printf("no");
	  }
	}
	if(n>2)
	{
	while(k<n)
	{
	for(i=0;i<n-1;i++)
	{
	  maxmax=(x[i][1])>=(x[i+1][1])?(x[i][1]):(x[i+1][1]);
	  minmin=(x[i][0])<=(x[i+1][0])?(x[i][0]):(x[i+1][0]);
	  maxmin=(x[i][1])<(x[i+1][1])?(x[i][1]):(x[i+1][1]);
	  minmax=(x[i][0])>(x[i+1][0])?(x[i][0]):(x[i+1][0]);
	  if(i==n-2)
	  {
		if(maxmin>=minmax)
		{
		x[0][0]=minmin;
		x[0][1]=maxmax;
		break;
		}
		if(maxmin<minmax)
		{
         int p=x[i+1][0],q=x[i+1][1];
	     x[0][0]=x[i][0];x[0][1]=x[i][1];
	     x[i][0]=p,x[i][1]=q;
		 break;
		}
	  }
	  if(i<n-2&&maxmin>=minmax)
	  {
	    x[i+1][0]=minmin;
	    x[i+1][1]=maxmax;
	  }
	  if(i<n-2&&maxmin<minmax)
	  {
	  int p=x[i+1][0],q=x[i+1][1];
	  x[i+1][0]=x[i][0];x[i+1][1]=x[i][1];
	  x[i][0]=p,x[i][1]=q;
	  }
	}
	k++;
	if(min==x[0][0]&&max==x[0][1])
	{
	  printf("%d %d",min,max);
	  break;
	}
         if(k==n-1)
         {
	if(min!=x[0][0]||max!=x[0][1])
	  {
	    printf("no");
		break;
	  }
         }
	}
	}
	return 0;
}
void f(char , char , char *,int *);
int main()
{
	char a[100], b, g;
	int la, sum[100] = {0};
	cin >> a;
	la = strlen(a);
	b = a[0];
	g = a[la - 1];
    f(b, g, a, sum );
	return 0;
}
void f(char b, char g, char * a, int * sum)
{
	int i, j, l;
	l = strlen(a);
	for (i = 0; i < l ; i++)
	{
		if ((l > 2) && ( a[i] == g) && (sum[i] == 0))
		{
			for (j = i; j >= 0; j--)
			{	
				if ((sum [j] == 0) && (a[j] == b))
                {
					cout << j << " " << i << endl;
			        sum [i] = 1;
			        sum [j] = 1;
			        f(b, g, a, sum);
				}
			}
		}
	}
}
int main()
{
	char a[1000];
	char m,f;
	int i,j,temp;
	gets(a);
	m=a[0];
	for(i=0;;i++)
		if(a[i]!=m) {f=a[i];break;}
	do
	{
		for(i=0;i<strlen(a)-1;i++)
		{
			if(a[i]=='0') continue;
			temp=0;
			for(j=i+1;j<strlen(a);j++)
			{
				
				if(a[i]==m&&a[j]==m) break;
				if(a[i]==m&&a[j]==f)
				{
					printf("%d %d\n",i,j);
					a[i]='0';
					a[j]='0';
					temp=1;
					break;
				}
			}
			if(temp==1) break;
		}
	}
	while(a[strlen(a)-1]!='0');
	return 0;
}
int main(){
	char x,y;
	char a[1000];
	int b[1000];
	int i = 0;
	int m,n;
	char da;
	int db;
	int k;
	int jie1=0,jie2=0;

	while(scanf("%c",&a[i]) != EOF){
		x=a[0];
		if(a[i] == x&&jie1==0){
			i++;
			jie1=1;
			continue;
		}
		if(a[i]!=x&&jie2==0){
			y=a[i];
			jie2=1;
			i++;
			continue;
		}
		if(a[i]==x || a[i]==y){
			i++;
		}
		else break;
	}
	for(k=0;k<1000;k++){
		b[k] = k;
	}
	while(i!=0){
		for(m = 0;m < i-1;m++)
			if(a[m] == x && a[m+1] == y){
				i = i-2;
				printf("%d %d\n",b[m],b[m+1]);
				for(n=m;n<i;n++){
					da=a[n+2];
					a[n]=da;
					db=b[n+2];
					b[n]=db;
				}
				break;
			}
	}
	return 0;
}
int a[100];
int f(int n)
{
    for(int i=n-1;i>=0;i--)
    if(a[i]==0) { cout<<i<<' '<<n<<endl;
    a[i]=-1;break;}
}
int main()
{
    char c[100];
    cin>>c;
    a[0]=0;
    int i,k=strlen(c);
    for(i=1;i<k;i++)
    {
    if(c[i]==c[0]) a[i]=0;
    else a[i]=1;
    }
    for(i=0;i<k;i++)
    {  if(a[i]==1) f(i);
    }
    return 0;
}
char boy;

void f(char *s)
{
	int i,j,counter=0;
	for (i=0;s[i]!='\0';i++)
	{
		if (s[i]==boy)
		{
			for (j=i+1;s[j]!='\0';j++)
			{
				if (s[j]==boy)
					break;
				else if (s[j]!='0')
				{
					cout<<i<<" "<<j<<endl;
					s[i]='0';
					s[j]='0';
					f(s);
				}
			}
		}
	}
}

int main()
{
	char s[101];
	cin>>s;
	boy=s[0];
	f(s);
	return 0;
}
void getmarried (char str[], int num, char, char, int);
int main()
{
	char str[101];
	cin.getline(str, 101);
	int l = strlen(str);

	char b = str[0], g = str[l - 1];

	getmarried (str , 1, b, g , l);
}

void getmarried (char str[], int num, char b, char g, int l)
{
	if (str[num] == g)
	{
		for (int j = num - 1 ; j >= 0 ; j--)
		{
			if (str[j] == b)
			{
				cout << j << ' ' << num << endl;
				str[num] = str[j] = '#';
				break;
			}
		}
	}
	if (num < l - 1)
		return getmarried(str, num + 1, b, g , l);
}
void p(int a[])//??
{
	int i=0;
	for(i=0;a[i]!=0;i++)
	{
		if(a[i]==1)
		{
			int j=i+1;
			while(a[j]==3) j++;//?????????????
			if(a[j]==2)
			{
				cout<<i<<' '<<j<<endl;
				a[i]=3;a[j]=3;//??????
				p(a);//???
			}
		}
	}
}
int main()
{
	char a;
	int child[200]={0};
	int i=1;
	child[0]=1;
	cin>>a;
	while(cin.peek()!='\n')//?????????1???2???0????3????
	{
		char ch=cin.get();
		if(ch==a)
			child[i]=1;
		else child[i]=2;
		i++;
	}
	p(child);
	return 0;
}
char all[101];
int times[101];
void oper(char, int);
int main()
{
	char boy;
	int l;
	memset(times, 0, sizeof(times));
	cin.getline(all,101);
	l = strlen(all);
	boy = all[0];
	oper(boy, l);
	return 0;
}

void oper(char boy, int l)
{
	int i, j;
	if (l == 0)
		return;
	for (i = 1; i < l; i++)
	{
		if (all[i] != boy && all[i - 1] == boy)
		{
			cout << i - 1 + 2 * times[i - 1] << " " << i + 2 * times[i] << endl;
			for (j = i - 1; j < l - 2; j++)
			{
				all[j] = all[j + 2];
				times[j + 2]++;
				times[j] = times[j + 2];
			}
			l -= 2;
			break;
		}
	}
	oper(boy, l);
	return;
}
int b[100][2],count=0;

void deal(char a[],int num[],int n)
{
	int i,j;
	if(n!=0)
	{
	char mid;
	mid=a[0];
	for(i=0;i<n-1;i++)
	{
		if(a[i]==mid&&a[i+1]!=mid)
		{b[count][0]=num[i];b[count][1]=num[i+1];break;}
	}
	for(j=i+2;j<n;j++)
	{a[j-2]=a[j];num[j-2]=num[j];}
	count++;
	deal(a,num,n-2);
	}
}
		
void main()
{
	char m,ar[100];
	int i,n,num[100];
	
	gets(ar);
	m=ar[0];
	n=strlen(ar);
	for(i=0;i<n;i++)
	{num[i]=i;}

	deal(ar,num,n);

	for(i=0;i<n/2;i++)
	{printf("%d %d\n",b[i][0],b[i][1]);}
}
int main()
{
	char a[100];
	int i, j, m;
	cin.getline(a,100);
	m = strlen(a);
	for ( i = 1; i < m; i++)
	{
		if (a[i] == a[m - 1])
		{
			for (j = i - 1; ; j--)
			{
				if (a[j] == a[0])
				{
					cout << j << " " << i << endl;
					a[i] = 's';
					a[j] = 's';
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
    int n=0,length,x[102],b[102],i,j,l[100]={0};
    char c,str[102],nan;
    c=getchar();
    nan=c;
    while (c!='\n')
    {
          if (c==nan) x[n]=1;
          else
          {
              x[n]=2;
              l[n]=1;
          }
          n++;
          c=getchar();
    }
    length=n;
    while (n!=0)
    {
          for(i=0;i<length;i++)
          {
                               if(x[i]==1)
                               {
                                          j=i;
                                          i++;
                                          while(x[i]==0) i++;
                                          if (x[i]==1) 
                                          {
                                                       i--;
                                                       continue;
                                          }
                                          b[i]=j;
                                          x[j]=x[i]=0;
                                          n=n-2;
                               }
          }
    }
    for(i=0;i<length;i++)
    {
                         if(l[i]==1)
                         {
                                    cout<<b[i]<<' '<<i;
                                    if (b[i]!=0) cout<<endl;
                         }
    } 
    return 0;
}
int main()
{
	char a[10000];
	int k,n=0;
	for(k=0;k<10000;k++)
	{
		scanf("%c",&a[k]);
		if(a[k]==' ')
			break;
		n+=1;
	}
	for(k=1;k<n;k++)
	{
		if(a[k]==a[0])
			continue;
		int m=1,i;
		for(i=k-1;i>=0;i--)
		{
			if(a[i]!=a[0])
				m+=1;
			if(a[i]==a[0])
				m-=1;
			if(m==0)
			{
				printf("%d %d\n",i,k);
				break;
			}
		}
	}
	return 0;
}
static int i=0,a2[2][101];

int f(char s[],char a,char b,int n)
{
	int j,k,e,flag2=0;
	for(j=0;j<n;j++)
		if(s[j]!=' ') {flag2=1;break;}//??????????
	if(flag2==0) return 0;//?????????????
	
	for(j=0;j<n-1;j++)
		if(s[j]==a){
		for(k=j+1;k<n;k++)
		if(s[k]==b) 
		{
			if(k==j+1)	{a2[0][i]=j; a2[1][i]=k; s[j]=' '; s[k]=' ';i++;break;}
			else{
			int flag=0;
			for(e=j+1;e<k;e++)
			{
			    if(s[e]!=' ') {flag=1;break;}
			}
			if(flag==0)	{a2[0][i]=j; a2[1][i]=k; s[j]=' '; s[k]=' ';i++;break;}}
		}}
    f(s,a,b,n);
}

void main()
{
	char s1[101],a1,b1;
	int l,t,qqq,l1,x,y,temp;
	scanf("%s",s1);//???????
	l=strlen(s1);//???????
	a1=s1[0];//?a1????
    for(t=0;t<l;t++)
		if(s1[t]!=a1) {b1=s1[t];break;}//?b1????
	qqq=f(s1,a1,b1,l);
	l1=l/2;
    for(x=1;x<=l1-1;x++)
		for(y=0;y<l1-x;y++)
		{
			if(a2[1][y]>a2[1][y+1]) {temp=a2[1][y];a2[1][y]=a2[1][y+1];a2[1][y+1]=temp;temp=a2[0][y];a2[0][y]=a2[0][y+1];a2[0][y+1]=temp;}
		}
    for(t=0;2*t<l;t++)
		printf("%d %d\n",a2[0][t],a2[1][t]);
}
int main()
{
	char a[100];
	gets(a);
	int length=strlen(a);
	char nan,nv;
	nan=a[0];
	int i,j;
	for(i=0;i<length;i++)
	{
		if(a[i]!=nan) {nv=a[i];break;}
	}
    int b[100]={0};
	for(i=0;i<length;i++)
	{
		if(a[i]==nv)
		{
			for(j=i-1;j>=0;j--)
			{
				if(a[j]==nan&&b[j]==0) {printf("%d %d\n",j,i);b[j]=1;break;}
			}
		}
	}
	/*printf("%c %c",nan,nv);*/
	return 0;
}