semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int out(char str[100],char a,char b)
{
    if(str[0]=='!')  return 1;
    else
    {
        for(int i=0;i<strlen(str);i++)
        {
                if(str[i]==b)
                {
                             str[i]='!';
                             for(int j=i;j>=0;j--)
                             {
                                     if(str[j]=='!')  continue;
                                     else
                                     {
                                             cout<<j<<' '<<i<<endl;
                                             str[j]='!';
                                             return out(str,a,b);
                                     }
                             }
                }
        }
    }
}
int main()
{
    char  line[100];
    cin>>line;
    out(line,line[0],line[strlen(line)-1]);
    return 0;
}
void fuck(int n);
int main()
{
	char c,boy;
	int a[100],i=0,j;
	boy=cin.get();
	a[0]=1;
	while((c=cin.get())!='\n')
	{
		i++;
		if(c==boy) a[i]=1;
		else {
			a[i]=-1;
			j=i-1;
			while(a[j]!=1) j--;
			cout<<j<<" "<<i<<endl;
			a[j]=0;}
	}
	return 0;
}
void f(char s[],int n,int m)
{
	int i,b,g;
	char *s2;
	if(n==2)
		printf("%d %d\n",m,m+1);
	else
	{
		b=0;
		g=0;
		for(i=0;;i++)
		{
			if(s[i]==s[0])
				b++;
			else
				g++;
			if(b==g)
				break;
		}
		if(i==n-1)
		{
			s2=s+1;
			f(s2,n-2,m+1);
			printf("%d %d\n",m,m+n-1);
		}
		else
		{
			f(s,i+1,m);
			s2=s+i+1;
			f(s2,n-i-1,m+i+1);
		}
	}
}

void main()
{
	char s[100];
	int n;
	gets(s);
	n=strlen(s);
	f(s,n,0);
}
int main ()
{
	struct
	{
		char ch;
		int num;
	}student[100];//?????????????????
	int sum = 0;
	char temp;
	while (true)//???????????
	{
		cin.get(temp);
		if ( temp == '\n' ) break;
		student[sum].ch = temp;
		student[sum].num = sum;
		sum ++;
	}
	char boy, girl;//?????????????????
	boy = student[0].ch;
	girl = student[sum-1].ch;
	for ( int i = 0; i < sum/2; i ++ )//????????????
		for ( int j = 0; j < sum - 1; j ++ )
		{
			int k = j + 1;
			while( student[k].ch == 0 ) k ++;
			if ( student[j].ch == boy && student[k].ch == girl )
			{
				cout << student[j].num << " " << student[k].num << endl;
				student[j].ch = 0;
				student[k].ch = 0;
				break;
			}
		}
	return 0;
}
void main()
{
	int i,j,k,n,m,len,r;
	char s[1000]={""},a,b;
	gets(s);
	len=strlen(s);
	for(i=0;i<len;i++)
	{
		a=s[0];
		if(s[i]!=a) {b=s[i];break;}
	}
 for(r=0;r<len/2+1;r++)
 {
	for(i=0;i<len;i++)
	{
		if(s[i]==a)
		{
			for(j=i+1,k=0;j<len;j++)
			{
		   	 if(s[j]==' ') continue;
			 else if(s[j]==b) {s[i]=' ';s[j]=' '; printf("%d %d\n",i,j);k++;break;}
			 else break;
			}
				if(k==1)break;
		}
	

	}
 }


}
//********************************************************
//?????????
//??????
//?????2010.12.31
//????:???????????????????
//********************************************************
int main ()
{
	char str[10000];//?????????????
	char c1, c2;//???????????????????
	int a[10000];//??????????????????
	int i , j, l;//??????ij?????
	cin >> str;
	l = strlen(str);
	for ( i = 0; i < 10000; i++)
	{
		a[i] = 0;
	}//?????????0??????
	c1 = str[0];//???????????????????
	for (i = 0; i < l; i++)
		if (str[i] != c1)
		{
			c2 = str[i];
			break;
		}//??????????
	for (i = 0; i < l; i++)
	{
		if (str[i] == c2)//???????????
		{
			for (j = i - 1; j >= 0; j--)
			{
				if (str[j] == c1 && a[j] == 0)//????????????????????
				{
					cout << j << " " << i << endl;
					a[j] = 1;//???????????1
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	char a[110];
	int b[110];
	int c[110];
	char s1,s2;
	int i,j,k,l,m,n,q=0;
	cin.getline(a,110);//??
	n=strlen(a);
	s1=a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]!=a[0])
		{s2=a[i];break;}
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==s2)//?????????
		{
			for(j=i-1;j>=0;j--)
			{
				if(a[j]==s1)//??????
				{break;}
			}
			b[q]=j;c[q]=i;//??
			q=q+1;
			a[i]='\0';a[j]='\0';//??
		}

	}
	for(k=0;k<q;k++)
	{
		cout<<b[k]<<" "<<c[k]<<endl;//??
	}
	return 0;
}
int a[100],num=0,v[100];
char c;
void f()
{
	char b;
	int m;
	cin>>b;
	if(num==0)
		c=b;
	if(b==c)
	{
		a[num]=0;
		num++;
		f();
	}
	if(b!=c)
	{
		a[num]=1;
		for(m=num;;m--)
		{
			if(a[m]==0&&v[m]==0)
			{
				v[m]=1;
				cout<<m<<" "<<num<<endl;
				break;
			}
		}
		if(m!=0)
		{
			num++;
			f();
		}

	}

}

int main()
{
	int i;
	for(i=0;i<=99;i++)
		v[i]=0;
	f();
	return 0;
}
//******************************************
//*???????.cpp                     **
//*??: ??     1100012808              **
//*???2011.11.22                       **
//******************************************
void zifu(char a[])   //??????????????
{
	int i, j;
	for (i = 1; i < strlen(a); i++)  
	{
		if (a[i] != a[0])//????????????
		{
			for (j = i - 1; a[j] != a[0]; j--)   
			{
				a[j] = a[i];   //?????????????
			}
			cout << j << " " << i << endl; //???????
			a[j] = a[i];//?????????????
		}
	}
	return;
}
						

int main()  //???
{        //?????
    char a[10000];
	int i;  
	cin >> a;
	zifu(a);
	return 0;
} //?????
main()
{
	int i,j,k,e,f,*e_point,*f_point,flag;
	char a,b,c[100],z=' ';
	gets(c);
	e_point=&e;
	f_point=&f;
	a=c[0];b=c[strlen(c)-1];
	for(k=1;k<=strlen(c)/2;k++)
	{
		for(i=0;i<strlen(c);i++)
	    {
	    	flag=0;
	    	if(c[i]==a)
	    	{
	    		j=i+1;
	    		while(c[j]==z)
	    		{
	    			j+=1;
	    		}
	    		if(c[j]==b)
	    		{
	    			e=i;
	    			f=j;
	    			c[i]=z;
	    			c[j]=z;
	    			flag=1;
	    		}
	    	}
	    	if(flag)break;
	    }
		printf("%d %d\n",e,f);
	}
}
int main()
{
	char children[100];
	gets(children);
	int boys[50],i,top=0;
	boys[0] = 0;
	for(i=1; children[i]; i++)
		if(children[i] == children[0])
			boys[++top] = i;
		else
			printf("%d %d\n", boys[top--], i);
	return 0;
}
char x,y;
int main()
{
	int i;
	void result(char a[]);
	char line[200];
	scanf("%s",line);
	x=line[0];
	for(i=0;i<=strlen(line)-1;i++)
	{
		if(line[i]!=x) 
		{y=line[i];
		break;}
	}
    result(line);
	
	return 0;
}
void result(char a[])
{
    if((a[0]!='.')&&(a[strlen(a)-1]!='.'))
	{
	int i,j;
	for(i=1;i<=(strlen(a)-1);i++)
	{
		if(a[i]==y)
		{
		for(j=i-1;j>=0;j--)
		{
			
			if (a[j]==x)
			{
				printf("%d %d",j,i);
				printf("\n");
				a[i]='.';a[j]='.';
				break;
			}
		}
		}
	}
    result(a);
	}
	
}
int main()
{
	char line[150];char girl;
	gets(line);
	 int len=strlen(line);
	char boy=line[0];
	for(int i=0;i<len;i++)
	{
		if(line[i]!=boy){
			girl=line[i];break;
		}
	}
	for(int i=0;i<len;i++)
	{
		if(line[i]==girl)
		{
			for(int j=i-1;j>=0;j--)
			{
				if(line[j]==boy)
				{
					printf("%d %d\n",j,i);
					line[j]=' ';break;
				}
			}
		}
	}
	getchar();
	getchar();
	return 0;
}
int main()
{
    char ch[100];
    cin>>ch;
    int len=(int)strlen(ch);
    for (int i=0;i<len;i++)
    {
        if (ch[i]==')'||ch[i]=='}'||ch[i]==']'||ch[i]=='>')
        {
            int j=i;
            while (ch[j]!='('&&ch[j]!='{'&&ch[j]!='['&&ch[j]!='<')
                j--;
            cout<<j<<" "<<i<<endl;
            ch[i]='%';
            ch[j]='%';
        }
    }
	return 0;
}
int n,vis[510];
char s[510];

void dfs(int p,int q)
{
	for(;vis[p];p++);
	if (p>=n) return;
	if (s[p]!=s[0])
		cout<<q<<' '<<p<<endl,vis[p]=vis[q]=1;
	else
		for(;!vis[p];) dfs(p+1,p);
}

int main()
{
	cin>>s;
	n=strlen(s);
	dfs(0,-1);
	return 0;
}
int main()
{
	char f[10000]={0};
	int n,i,j;
	
	scanf("%s",f);
	n=strlen(f);

	for(i=1;i<n;i++)
	{
		if(f[i]!=f[0])
		{
			for(j=i;j>=0;j--)
			{
				if(f[j]==f[0])
				{
					printf("%d %d\n",j,i);
					if(j!=0)
						f[j]=0;
					break;
				}
			}
		}
	}



	return 0;
}
char m[100];
int num = 0;
int q = 0;

void search(int a, int b, char boy, char girl)
{
	if (num == (b + 1) / 2)
		return;
	int i, t;
	for (i = a; i < b; i++)
	{
		if (m[i] == boy)
		{
			for (t = i + 1; t < b; t++)
			{
				if (m[t] != '.')
				{
					break;
				}
			}
			if (m[t] == girl)
			{
				num ++;
				m[i] = '.';
				m[t] = '.';
				break;
			} 
		}
	}
	cout << i << " " << t << endl;
    search(a, b, boy, girl);
}

int main()
{
    char boy, girl;
	int len;
	cin >> m;
	len = strlen(m);
	boy = m[0];
	girl = m[len - 1];
	search(0,len - 1, boy, girl);
	return 0;
}
int ture(int c[210],int a,int b)                                            //?????????????????? 
{  
   if(c[a]!=1||c[b]!=2)  
      {
                         return 0;
      }
   int i;
   int sum=0;
   for(i=a;i<=b;i++)
     {  sum=sum+c[i];
     }
   if(sum==3)
     {  c[a]=0;
        c[b]=0;
        return 1;                                    //?????1? 
     }
   else
     { 
       return 0;                                      
     }
}

int main()
{  char a[210]={0};
   char b;
   int i=0;
   int num;
   int c[210]={0};
   while(1)                                    //????? 
     {  cin.get(b);
        if(b=='\n')
           {  num=i;
              break;
           } 
        else 
           {  a[i]=b;
              i=i+1;
           }
     }
   
                           //???????????1??????2?? 
     for(i=0;i<num;i++)
            {   if(a[i]==a[0])
                   {  c[i]=1;
                   }
                else
                   {  c[i]=2;
                   }
            }
   
      int k;
      int t=0;
      int count=0;
      while(1)                           
      {   t=0;
          for(i=0;i<num;i++)
             { for(k=i+1;k<num;k++)
                  {  if(ture(c,i,k)==1)                 //????????? 
                        {  cout<<i<<' '<<k<<endl;
                           count=count+1;
                           t=1;
                           break;
                         }
                 }
             if(t==1)  break;  
            }
         if(count==num/2)   break;
      }
        
  
   return 0;
}
int k,n;

char str[1000],c1,c2;

int main(){
    int i,j,t=1;
    scanf("%s",str);
    n=strlen(str);
    c1=str[0];
    c2=str[n-1];
    
    for(i=t;i<n;i++){
        if(str[i]==c2){
            for(j=i-1;j>=0;j--){
                if(str[j]==c1){
                    printf("%d %d\n",j,i);
                    str[i]=' ';
                    str[j]=' ';
                    break;
                }
            }
        }
        t++;
    }
//scanf("%d",&k);
return 0;
}
char str[100], b, g;
void match(int k)
{
	int i;
	if(str[k] == '\0')
		return;
	if(str[k] == g)
	{
		str[k] = '*';
		for(i = k - 1; i >= 0; i--)
			if(str[i] == b)
			{
				str[i] = '*';
				cout << i << " " << k << endl;
				break;
			}
	}
	match(k + 1);
}

int main()
{
	int length;
	cin.getline(str,100);
	length = strlen(str);
	b = str[0];
	g = str[length - 1];
	match(0);
	return 0;
}
void main(){
	int i,k,m,s=0,t[51][2];
	memset(t,0,sizeof(t));
	char a[101];
	gets(a);
	int n=strlen(a);
	k=n;
	for(;;){
	if(k==1||k==0)break;
	else{
		for(i=0;i<n;i++){
			if(a[i]){
			if(a[i]==a[0])m=i;
			else if(a[m]!=a[0])continue;
			else if(a[i]!=a[m]){
				t[s][0]=m;t[s][1]=i;
				s++;
				a[i]=0;a[m]=0;
				k-=2;
				m++;
			}
			}
		}
	}
	}
	for(i=0;i<50;i++){
		if(t[i][1]==0)break;
	}
	for(k=0;k<i-1;k++){
		for(m=k+1;m<i;m++){
			if(t[k][1]>t[m][1]){
				t[50][0]=t[m][0];t[50][1]=t[m][1];
				t[m][0]=t[k][0];t[m][1]=t[k][1];
				t[k][0]=t[50][0];t[k][1]=t[50][1];
			}
		}
	}
	for(k=0;k<i;k++)
		printf("%d %d\n",t[k][0],t[k][1]);
}
int d=0,c=0,m=0;
char a[100],b,g;
void handshake(int x)
{
    if(x==c)
    {
       cout<<x-1<<' '<<x<<endl;
       a[x-1]=' ';a[x]=' ';
    }
    if(x>c&&a[x]==b)
    {
        handshake(x-1);
    }
    if(x>c&&a[x]==g)
    { 
           
            handshake(x-1);
            for( m=x-1;m>=0;m--)
            {
               if(a[m]==b)
               {
               cout<<m<<' '<<x<<endl;
               a[m]=' ';
               a[x]=' ';
               break;
               }
            }
     }
}
int main()
{  
    int i=0,j=0;
    cin>>a;
     b=a[0];
    for(i=0;i<100;i++)
    {
        if(a[i]!=a[0])
       {
         g=a[i];
        break;
        }
    
    }
    for(i=0;i<100;i++)
    {
       if(a[i]==b||a[i]==g)
       d++;
    }
    for(i=0;i<d;i++)
    {
      if(a[i]==g)
      {  
         c=i;
         break;
      }
    }   
    
    handshake(d-1);
       return 0;
}
int girl = -1;
char boy_symbol = 0;
int main()
{
    int Match(int boy);
    Match(0);
    return 0;
}
int Match(int boy)
{
	girl ++;
    char ch;
    ch = cin.get();
	if (boy_symbol == 0) boy_symbol = ch;
    if (ch != boy_symbol)
    {
        return girl;
    }
    else
    {
        int t = Match(boy + 1);
        cout << boy << " " << t << endl;
        if(boy != 0)
            return Match(t + 1);
    }
}
int main()
{
    int n,i,j;
	char a[100],m;
	gets(a);
	n=strlen(a);
	m=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]!=m)
		{
			for(j=i-1;j>=0;j--)
			{
				if(a[j]==m)
				{
					printf("%d %d\n",j,i);
					a[i]=' ';
					a[j]=' ';
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	char str[110];
	cin>>str;
	int length;
	length=strlen(str);
	int i,j,k=0;
	char b,g;
	b=str[0];
	for(i=0;i<length;i++){
		if(str[i]!=b){
			g=str[i];
			break;
		}
	}
	while(1){
		if(str[0]==' '){
			break;
		}
		for(i=1;i<length;i++){
			if(str[i]==g){
				j=i-1;
				while(str[j]==' '){
					j--;
				}
				if(str[j]==g){
					break;;
				}
				else if(str[j]==b){
					cout<<j<<" "<<i<<endl;
					str[i]=' ';
					str[j]=' ';
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	int len,i,j,b[101],top=0;
	char s[101],boy;
	gets(s);
	boy=s[0];
	for(i=0;s[i];i++)
	{
		if(s[i]==boy)
		{
			b[top]=i;
			top++;
		}
		else if(s[i]!=boy&&s[i]!=' ')
		{
			s[b[top-1]]=' ';
			s[i]=' ';
			printf("%d %d\n",b[top-1],i);
			top--;
		}
	}
	return 0;
}
char a[1000], girl, boy;//??????
int work(int l, int r)//??work??
{
    if (a[l] != a[l+1])
    {
        cout << l << ' ' << l+1 << endl;
        return 0;
    }
    int p,s,q;
    q = l+1;
    p = l+2;
    s = 1;
    while (p<r)   //????????????????????
    {
        while (s!= 0)
        {
            if (a[p] == boy) s++;
            if (a[p] == girl) s--;
            p++;
        }
        work(q,p-1);   //?????????
        s = 1;        //??cnt,??tmp???????????
        q = p;
        p++;
    }
    cout << l << ' ' << r << endl;
    return 0;
}
int main()
{
	int i=0,p,len=0;
	cin >> a;
	len = strlen(a);
	boy = a[0];
	girl = a[len-1];
    work(0,len-1);
    return 0;
}
void main()
{
	char a[100];
	int i,j,l,k,b[100];
	gets(a);
    l=strlen(a);
	for(i=0;i<l;i++)
		b[i]=i;
    for(k=0;k<l;)
	{
	for(i=0;i<l-k-1;i++)
		if(a[i]==a[0]&&a[i+1]==a[l-k-1])
		{
			printf("%d %d\n",b[i],b[i+1]);
			for(j=i;j<l;j++)
			{
				a[j]=a[j+2];
				b[j]=b[j+2];
			}
			break;
		}
		k=k+2;
	}
}
/*        ????
??????     2010.12.29            */

int main()
{
	int i,len,j;
	int sta[10000]={0};//????????? 1boy 2girl 0??
	char lin[10000]={'\0'};//????
	char boy,girl;
	cin.getline(lin,sizeof(lin));
	len=strlen(lin);
	boy=lin[0];//?????
	girl=lin[len-1];//?????

	for(i=0;i<len;i++)
		sta[i]=lin[i]==boy?1:2;//??????
	for(i=0;i<len;i++)
		if(sta[i]==2)
			for(j=i-1;j>=0;j--)
				if(sta[j]==1)
				{
					cout<<j<<" "<<i<<endl;
					sta[i]=sta[j]=0;
					break;
				}
	return 0;
}
void leave(char a[]);
int main()
{
   char children[1000000],boy,girl;
   cin>>children;
   int i=0,n=strlen(children);
   for(i=0;;i++)
   {
       boy=children[0];
       if(children[i]!=boy) {girl=children[i]; break;}
   }
   for(i=0;i<n;i++)
   {
       if(children[i]==boy) continue;
       for(int j=i;j>=0;j--)
       {
           if(children[j]==boy)
           {
               cout<<j<<" "<<i<<endl;
               children[j]=0;
               break;
           }
       }
   }
   return 0;
}
char str[110];
int len;
int px(int xb, char b, char g);
// ???????????
// ????????????
// ?????????? ???????????????????????
// ?????????????????????
// ???????????
// ???1?? ???2???
// ???????? ?????0
// ??????????
// ?????????????????
// ????????? ???????????????????????????????
// ??????? ??????????? ????
// ????? ??????????????
// ???????????????????
// ??????? ????? ???????????? ????
int main()
{
	char boy, girl;
	cin >> str;
	len = strlen(str);
	boy = str[0];
	girl = str[len - 1];
	px(0, boy, girl);
	return 0;
}
int px(int xb, char b, char g)
{
	int i, k;
	for (i = xb; i <= len - 1; i++)
	{
		while (str[xb] == '*') xb++;
		if (str[xb] == b) 
		{
			str[xb] = '*';
			k = px(xb + 1, b, g);
			cout << xb << " " << k << endl;
		}
		else
		{
			if (str[xb] == g)
			{
				str[xb] = '*';
				return xb;
		}
		}
	}
}
int len;
char a[200],b,g;
int match (int p)
{
	if (p==len-1)
		return p;
	int q;
	if (a[p]==b)
	{
		q=match(p+1);
		cout<<p<<" "<<q<<endl;
		return match(q+1);
	}
	else
		return p;
}
int main()
{
	cin>>a;
	len = strlen(a);
	b=a[0];
	g=a[len-1];
	match(0);
}
//
//	?????	????
//	?????	?????????????????????????????????????????????
//	?????	?	? ? ? ?? 1000012733 ?
//	?????	2010 ? 12 ? 31 ?
//
void line ( char *p, int *q, int len )
{
	int i, j;
	for ( i = 0; i < len; i++ )
	{
		if ( *( p + i ) == *p )
		{
			for ( j = i + 1; j < len; j++ )
			{
				if ( *( q + j ) == 0 )
					continue;
				else
				{
					if ( *( p + j ) != *( p + i ) )
					{
						cout << i << " " << j << endl;
						*( q + i ) = 0;
						*( q + j ) = 0;
						line ( p, q, len );
					}
					else
						break;
				}
			}
		}
	}
}
int main()
{
	char string[1000];
	int sign[1000];
	int len, i;
	cin.getline ( string, 1000 );
	len = strlen ( string );
	for ( i = 0; i < len; i++ )
	{
		sign[i] = 1;
	}
	line ( string, sign, len );
	return 0;
}
int main()
{
	char queue[100];
	cin.getline(queue,100);
	int i,j;
	for(i=1;i<strlen(queue);i++)
	{
		if(queue[i]!=queue[0])
		{
			queue[i]=')';
		}
		if(queue[i]==queue[0])
		{
			queue[i]='(';
		}
	}
	queue[0]='(';
	for(i=0;i<strlen(queue);i++)
	{
		if(queue[i]==')')
		{
			j=i-1;
			while((queue[j]=='*')&&(j>0))
			{
				j=j-1;
			}
			cout<<j<<" "<<i<<endl;
			queue[j]='*';
			queue[i]='*';
		}			
	}
	return 0;
}
void Loop(char s[],int n)
{
	int i, p, q;
	for(i=1;i<n;i++)
	{
		if(s[i]!=s[0]&&s[i])
		{
			p = i;
			break;
		}
	}
	if(p==n-1)
	{
		cout << "0 " << n-1 << endl;
		return;
	}
	for(i=p;i>=0;i--)
		if(s[i]==s[0])
		{
			q = i;
			break;
		}
	cout << q << " " << p << endl;
	s[q] = s[p] = 0;
	Loop(s,n);
}
int main()
{
	int n, i;
	char s[MAXN];
	cin >> s;
	n = strlen(s);
	Loop(s,n);
	return 0;
}
int main()
{
    int i,j,A[80]={0};
    int k=1;
    char s[80];
    gets(s);
    for(i=0;s[i]!='\0';i++)
    {
       if(s[i]==s[0])
       {
           A[k]=i;
           k++;
       }
       if(s[i]!=s[0])
      {
          printf("%d %d\n",A[k-1],i);
          k--;
       }
    }
     return 0;
}
int main()
{
	char team[100]={'\0'};
	char b,g;
	int i,j,num=0,emnum=0,n;									
	cin.getline(team,100);
	b=team[0];
	for (i=0;i<100;i++)
		if (team[i]!=b)
		{
			g=team[i];
			break;
		}														
		for (i=0;i<100;i++)
			if (team[i]!='\0')
				num++;												
		for (n=1;n<=num/2;n++)
		{
			for (i=0;i<num;i++)
			{
				if (team[i]=='\0')
					continue;										
				else if ((team[i]!='\0')&&(team[i+1]!='\0'))
				{
					if ((team[i]==b)&&(team[i+1]==g))			
					{
						cout<<i<<" "<<i+1<<endl;
						team[i]='\0';
						team[i+1]='\0';
						break;
					}
					else
						continue;
				}
				else if ((team[i]!='\0')&&(team[i+1]=='\0'))
				{
					emnum=0;
					j=i+1;
					while (team[j]=='\0')
					{
						emnum++;
						j++;
					}
					if ((team[i]==b)&&(team[i+emnum+1]==g))	
					{
						cout<<i<<" "<<i+emnum+1<<endl;
						team[i]='\0';
						team[i+emnum+1]='\0';
						break;
					}
					else 
						continue;
				}
			}	
		}
		return 0;
}
int main()
{
	char str[100],a,b;
	int i,j,n,k;
	scanf("%s",str);
	a=str[0];
	for(n=0;;n++)
	{
		if(str[n]!=a)
		{
			b=str[n];
			break;
		}
	}
	for(n=0;str[n]!='\0';)
	{
		n=n+1;
	}
	for(i=1;i<=n/2;i++)
	{
		for(j=0;j<n-1;j++)
		{
			if(str[j]==a)
			{
				for(k=j+1;;k++)
				{
					if(str[k]!='\0')
						break;
				}
				if(str[k]==b)
				{
					printf("%d %d\n",j,k);
					str[j]='\0';
					str[k]='\0';
					break;
				}
			}
		}
	}
	return 0;
}
char boy,girl;
int l;
void result(char a[],int remain)//????????????????????????????
{
	int i,j;
	for(i=0;i<l;i++)
	{
		if(a[i]==girl)
		{
			for(j=i-1;j>=0;j--)
			{
				if(a[j]==boy)
				break;
			}
			a[i]='0';a[j]='0';
			cout<<j<<" "<<i<<endl;
			remain=remain-2;
			break;
		}
	}
	if (remain>0)
		result(a,remain);//?????????????????????????
}


int main()
{
	int i;
	char a[100];
	cin.getline(a,100);
	l=strlen(a);
	boy=a[0];
	for(i=1;i<l;i++)
	{
		if (a[i]!=boy)//??????????
		{	girl=a[i];
		break;}
	}
	result(a,l);
	return 0;
}
/*
 * 1000012739_finaltest3_7.cpp
 *
 *  Created on: 2011-1-8
 *      Author: ???
 *		Title: ????
 */


int indexx=-1;
char boy='\0',girl='\0';

int slv(void)
{
	char c;
	int ind,m;
	while (true)
	{
		indexx++;
		cin>>c;
		if (indexx==0)
			boy=c;
		else
			if (girl=='\0' && c!=boy)
				girl=c;
		if (c==girl)
		{
			return indexx;
		}
		else
		{
			ind=indexx;
			m=slv();
			cout<<ind<<' '<<m<<endl;
		}
	}
}

int main()
{
	slv();
	return 0;
}
int total,i,j;
char boy,girl;
char child[100];
int flag[100];
void departure();

int main()
{
    cin>>child;
    total=strlen(child);
    boy=child[0];
    girl=child[total-1];
    for(i=0;i<=total-1;i++)flag[i]=i;
    departure();

    return 0;


}
 void departure()
{
    if(total==0)return;
    else
    {
        for(i=1;i<=total-1;i++)
        {

           if(child[i]==girl&&child[i-1]==boy)
           {
               cout<<flag[i-1]<<' '<<flag[i]<<endl;
              if(i!=total-1)
              {
                  for(j=i+1;j<=total-1;j++)
                  {
                      child[j-2]=child[j];
                      flag[j-2]=flag[j];

                  }
                 total-=2;
              }
              else total-=2;
            departure();
           }
        }
    }
}
char str[101];
int n=0;
void f(int m,char a,char b)
{
	if(m==0)
		return;
	int i=0,j=0;
	for(;i<n;i++)
		if(str[i]==b)
			break;
	for(j=i;j>=0;j--)
	{
		if(str[j]==a)
		{
			printf("%d %d\n",j,i);
			str[i]='*';
			str[j]='*';
			break;
		}
		else
			continue;
	}
	return f(m-1,a,b);
}
int main()
{
	scanf("%s",str);
	n=strlen(str);
	f(n/2,str[0],str[n-1]);
	return 0;
}
void main()
{
 char text[101],c,d;int i,j,k,a[51],b[51],n,x=0;
 gets(text);c=text[0];n=strlen(text);
 for(i=0;i<n;i++)  if(text[i]!=c)   {d=text[i];break;}
 n=strlen(text);
 for(i=0;i<n;i++)
 {if(text[i]==d)    
 for(j=i-1;j>=0;j--)    
 if(text[j]==c) {a[x]=i;b[x]=j;x++;text[i]='q';text[j]='q';break;}
  }
 for(i=0;i<x;i++)   printf("%d %d\n",b[i],a[i]);
}
/*??(15.2)????*/ 



char boy;

int queue(int num)//????num???????num?????girl??? 
{
	char input;
	input=getchar();
	if(input==boy)
	{
		int girl;
		girl=queue(num+1);
		printf("%d %d\n",num,girl);
		return queue(girl+1);
	}
	else return num;
}

int main()
{
	boy=getchar();
	printf("0 %d\n",queue(1)); 
	return 0;
}
int main()
{
int n,sp,st[100]={0};
char ch,boy;
scanf("%c",&boy);
for(n=sp=1;sp>0;n++)
{
     scanf("%c",&ch);
     if(ch==boy){
         st[sp]=n;
         sp++;
         }
     else{
         sp--;
        printf("%d %d\n",st[sp],n);}
 }
    return 0;
}
const int N = 110 ;

int q[N] ;
char str[N], a ;

int main ()
{
    scanf ("%s", str) ;
    for (int i = 0, t = 0; i < strlen (str); i ++ )
        if (str[i] == str[0])
            q[ ++ t] = i ;
        else printf ("%d %d\n", q[t -- ], i) ;
    return 0 ;
}
char c[1000],b,g;
int l;
void game(){
	for(int i=0;i<l;i++){
		if(c[i]==b){
			for(int j=i+1;j<l;j++){
				if(c[j]==' ')continue;
				else if(c[j]==b){i=j-1;break;}
				else {
					cout<<i<<' '<<j<<endl;
					c[i]=' ';c[j]=' ';
					for(int k=i-1;k>=0;k--){
						if(c[k]==b){
							i=k-1;
							break;
						}
					}
					break;
				}
			}
		}
	}
	if(c[0]!=' ')game();
}
int main(){
	cin>>c;
	l=strlen(c);
	b=c[0];
	for(int i=0;i<l;i++){
		if(c[i]!=b){
			g=c[i];
			break;
		}
	}
	game();
	return 0;
}
int main()
{ char w;
  char a[105];
  int i,j=1,k,m=0,t;
  int b[100],c[100];
 for(k=0;k<105;k++)
    { 
     w=getchar();
      if(w!='\n')
        {a[k]=w;} 
      if(w=='\n')
       {break;}
     }
  while(j<=k)
  {     
   for(i=0;i<k;i++)
      { 
        if((a[i]=='{'||a[i]=='('||a[i]=='['||a[i]=='<')&&(a[i+j]=='}'||a[i+j]==')'||a[i+j]==']'||a[i+j]=='>'))
         {
          b[m]=i;c[m]=i+j;m++;
           a[i]='\0';
           a[i+j]='\0';
         }
      }
    j=j+2;
   }
  for(i=0;i<m-2;i++)
     for(j=0;j<m-2-i;j++)
       if(c[j]>c[j+1]){t=c[j];c[j]=c[j+1];c[j+1]=t;t=b[j];b[j]=b[j+1];b[j+1]=t;}
   for(i=0;i<k/2;i++)
    cout<<b[i]<<' '<<c[i]<<endl;

 return 0;
}