semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
char str[200 + 1];
int length ,sum , i;
int flag[100 + 1];
char p , q;

void f(char s[] ,int k);

int main()
{   
	int  j;
	cin >> str;
	
	length = strlen(str);
	p = str[0];
	q = str[length - 1];
	j = 0; 
	for( i = 1 ;i <= length -1 ; i++)
		if(str[i] == q)
		{
		    j ++;
			flag[j] = i;
		}
	sum = j;
	f(str,1);
	return 0;
}
void f(char s[],int k)
{
	if(k <= sum)
	{
		for(i = flag[k] ; i >= 0 ; i --)
		{
			if(s[i] == p)
			{
				printf("%d %d\n",i,flag[k]);
				s[i] ='\0';
				s[flag[k]] = '\0';
				break;
			}
		}
		f(s,k+1);
	}
	else
		return;
}
char a[101],x,y;int len;
void find(int t)
{
	int j;
	if(t==2)
	{
		for(int i=0;i<len;i++)
		{
			if(a[i]==x)
				cout<<i;
			else if(a[i]==y)
				cout<<' '<<i<<endl;
		}
	}
	else if(t>2)
	{
		for(int i=0;i<len-1;i++)
			if(a[i]==x)
			{
			    j=1;
				while((i+j<len)&&(a[i+j]==' '))
					j++;
				if(a[i+j]==y)
					{
						cout<<i<<' '<<i+j<<endl;
						a[i]=' ';
						a[i+j]=' ';
						find(t-2);
						return;
				    }
			}
	}
return;
}
int main()
{
	int i;
	cin>>a;
	len=strlen(a);
	x=a[0];
	for(i=1;i<len;i++)
		if(a[i]!=x)
		{
			y=a[i];
			break;
		}
	find(len);
return 0;
}
int main()
{
	char input[101],boy,girl;
	int dui[101]={0},i=1,j;
	cin.getline(input,101,'\n');
	boy=input[0];
	while(input[i]==boy)
		i++;
	girl=input[i];
	for(i=0;input[i]!=0;i++)
	{
		if(input[i]==boy)
			dui[i]=1;
		if(input[i]==girl)
			dui[i]=2;
	}
	for(i=0;dui[i]!=0;i++)
	{
		if(dui[i]==2)
		{
			for(j=i-1;dui[j]!=1;j--);
			cout<<j<<" "<<i<<endl;
			dui[j]=0;
			dui[i]=0;
		}
	}
	return 0;
}
char queue[100];
int main ()
{
	cin >> queue;
	int len = strlen(queue), i, j, temp;
	for (i = 0; i < len - 1;)
	{
		if (queue[len - 1] == ' ')
			break;
		if (queue[i] != ' ')
		{
			if (queue[i + 1] == queue[i])
			{
				i++;
				continue;
			}
			else if (queue[i + 1] == ' ')
			{
				j = i + 1;
				while(queue[j] == ' ')
					j++;
				if (queue[j] != queue[i])
				{
					cout << i << " " << j << endl;
					queue[i] = queue[j] = ' ';
					if (i == 0)
						continue;
					temp = i - 1;
					while (queue[temp] == ' ')
						temp--;
					i = temp;
				}
				else
					i = j;
			}
			else
			{
				if (queue[i] == queue[0])
				{
					cout << i << " " << i + 1 << endl;
					queue[i] = ' ';
					queue[i + 1] = ' ';
					if (i == 0)
						continue;
					temp = i - 1;
					while (queue[temp] == ' ')
						temp--;
					i = temp;
				}
			}
		}
		else
		{
			i++;
			continue;
		}
	}
	return 0;
}
//#define B '('
//#define G ')'
int main(int argc, char* argv[])
{
	char s[N], e[N], B, G;
 int i,k;
 gets(s);
B = s[0];
 for(i=0;s[i];i++)e[i]='a';

i=0;
while(s[i])
{if(s[i]==B)i++;
 else{
   for(k=i-1;k>=0;k--)
    if(s[k]==B && e[k])
    {e[k]='\0';
     printf("%d %d\n",k,i);
     break;
     }
   i++;
  }
}
puts("\n");
return 0;
}
int main()
{
	int a[100]={0},b[2][50],i,j,k,l=0,len;
	char str[101]={'\0'},c,d;
	gets(str);
	len=strlen(str);
	for(i=0;i<len;i++)
		a[i]=i;
	c=str[0];
	for(i=0;i<len;i++)
		if(str[i]!=c){
			d=str[i];
			break;
		}
	for(i=0;i<len/2;i++){
		for(j=0;j<len-i*2;j++){
			if(str[j]==c&&str[j+1]==d){
				b[0][i]=a[j];
				b[1][i]=a[j+1];
				for(k=j;k<len-2*i-2;k++){
					a[k]=a[k+2];
				    str[k]=str[k+2];
				}
				str[len-2*i-2]='\0';
				break;
			}
		}
	}
	for(i=0;i<len/2;i++)
	    printf("%d %d\n",b[0][i],b[1][i]);
	return 0;
}
// ????
// ??? 1100012820
// 20111115
//******************
char line[100];
int i = 0;
void match(int af)
{
	for(;line[i] != '\0'; i++)
	{
		if (line[i] == line[0])
		{
			int boy = i;
			match(++i);
			cout << boy << " " << i << endl;
		}
		else
		{
			return;
		}
		
	}
	return;
}
int main()
{
	cin >> line;
	match(0);
	return 0;
}
int i=0,j=0;
int a[200];
char c,d;
int solve()
{
 
 scanf("%c",&c);
 if(c==d) {
            a[i]=j;
            j++;
            i++;
            solve();
            return 0;
            }
   if(c!=d){
            printf("%d %d\n",a[i-1],j);
            i--;
            j++;
            if(i==0) return 0;
            solve();
            }
}
int main()
{  
scanf("%c",&c);
  d=c;
  a[i]=j;
  j++;
  i++;
  solve();
 
}
/* ?? 1000012853  ???? 12.30*/
void paidui(char str[], const char f, const char m);  //?????str???????f????????m???????
int main()
{
	char str[1000] = {'0'};
	char f, m;
	int a[1000] = {0}, i = 0, j = 0;
	cin.getline(str,1000);
	m = str[0];                                       //??????
	for(i = 0; str[i] != '\0'; i++)                   //????????
	{
		if(str[i] != m)
		{
			f = str[i];
			break;
		}
	}
	paidui(str, f, m);                                //??????????f????m????????
	return 0;
}

//
void paidui( char str[], const char f, const char m) 
{
	int i = 0, flag1 = -1, flag2 = -1;
	if(str[0] == '0')                                 //???????????
		exit(1);
	else
	{
		while(str[i] != '\0')
		{
			if(str[i] == m)                           //flag1??????
				flag1 = i;
		    if(str[i] == f)                           //flag2??????
			    flag2 = i;
			if(flag1 >= 0 && flag2 >= 0)              //????????0???????????
			{
				cout << flag1 << " " << flag2 << endl;
			    str[flag1] = '0';                     //????0
			    str[flag2] = '0';                     //????0
			    paidui(str, f, m);                    //????????
			}
		    i++;
		}
	}
}
const int BOY=1;          //?????1????2????0
const int GIRL=2;
const int NONE=0;
int line[100]={NONE};     //????line????
int n=0;                  //???n
void leave()              //??leave??
{
	int last=-1;          //??last??????????
	for(int i=0;i<n;i++)  //????
	{
		if(line[i]==BOY)  //????????last???????
			last=i;
		if(line[i]==GIRL&&last>=0)  //????????????????????????????????
		{
			line[i]=line[last]=NONE;
			cout<<last<<' '<<i<<endl;
			leave();
		}
	}
}			
int main()
{
	char boy,c;       //??boy????????c???????
	boy=getchar();    //????????
	line[0]=BOY;      //???????
	n++;              //n?1
	for(;;)           //??
	{
		c=getchar();  //????
		if(c=='\n')break;//???????????????1??????????????
		n++;
		if(c==boy)
			line[n-1]=BOY;
		else line[n-1]=GIRL;
	}
	leave();           //??????
	return 0;
}
char input[100];//?????
int lidui[100];//?????????1?????0?????
int boynum[100];//i???????boynum[i]??????
void boysAndGirls ( char boy , int pos , int dis , int charlong )//boy?????????pos????????dis??????????dis????????charlong??????????
{
	if(dis == charlong) boynum[charlong-1] = 0;//????????????????????
	else
	{
		if(lidui[pos] == 1              //????????
				|| input[pos] == boy       //???????
				|| pos<dis                 //????????
				|| lidui[pos-dis] == 1 )//?????????????????
			boysAndGirls ( boy , pos+1 , dis , charlong );//??????????
		else
		{
			if(pos >= charlong - 1)
				boysAndGirls ( boy , 0 , dis+1 , charlong );//???????????????????
			else
			{
				if( input[pos-dis] != boy )//???????dis?????
					boysAndGirls ( boy , pos + 1 ,dis , charlong );//??????????
				else
				{
					boynum[pos] = pos - dis;//???????pos-dis?????
					lidui[pos] = 1;  lidui[pos - dis] = 1;//???????????
					boysAndGirls ( boy , pos + 1 , dis , charlong );//???????????
				}
			}
		}
	}
}
int main()
{
	int i,charlong ;
	char boy;
	cin >> input;
	boy = input[0];//?????????????
	charlong=strlen(input);
	boysAndGirls ( boy , 0 , 1 , charlong );//?????????
	for( i=0 ; i < charlong ; i++ )//??????
	{
		if( i == charlong - 1 )  cout <<"0 "<< charlong - 1;
		else
		{
			if( boynum[i] == 0 ) continue;
			else cout << boynum[i] << " " << i << endl;
		}
	}
	cin.get();cin.get();cin.get();cin.get();cin.get();cin.get();cin.get(); 
	return 0;
}
char str[200];
int match(int p);
char b;
char g;
int main ()
{
	// ??????match ??????????p?????????????
	// ????? ???????????????????????? ???????????
    cin.getline(str, 100);
	int len, a;
	len = strlen(str);
	b = str[0];
	g = str[len - 1];
	a = match(0);
	return 0;
}
int match(int p)
{
	int q;
	if (str[p] == b)
	{  
		q = match(p + 1);       // p?q?????? ???????? p?q????????? ????????
		cout << p << " " << q << endl;  // q?p + 1??????????????
	    return match(q + 1);
	}
	else return p;
}
/*
 * yi.cpp
 *
 *  Created on: 2012-10-20
 *      Author: 7
 */
int main()
{
	char s[500];
	int left[500];
	cin>>s;
	int l,i=0,k=0;
	l=strlen(s);
	for(i=0;i<l;i++)
	{
		if(s[i]==s[0])
		{
			left[k]=i;
			k++;
		}
		else
		{
			k--;
			cout<<left[k]<<" "<<i<<endl;
		}
	}
}
int boy=0,children[100][2];
int childnum=0;
int theboy;
void findpair(char boysign)
{
	if(boy==-1)
		return;
	char sign;
	cin>>sign;
	if(sign==boysign)
	{
		boy++;
		childnum++;
		children[childnum][0]=0;
		findpair(boysign);
		return;
	}
	else
	{
		childnum++;
		children[childnum][0]=1;
		for(int i=childnum; ;i--)
			if(children[i][0]==0&&children[i][1])
			{
				theboy=i;
				children[i][1]=0;
				break;
			}
		cout<<theboy<<' '<<childnum<<endl;
		boy--;
		findpair(boysign);
		return;
	}
}
int main()
{
	for(int i=0;i<100;i++)
	    children[i][1]=1;
	char boysign;
	cin>>boysign;
	findpair(boysign);
	return 0;
}
int main()
{
	int numl[51];
	int pl=0;
	char str[101];
	cin.getline(str,101);
	int len=strlen(str);
	for(int i=0;i<len;i++)
	{

		if(str[i]==str[0])
		{
			numl[pl]=i;
			pl++;
		}
		else if(str[i]!=str[0])
		{
			cout<<numl[pl-1]<<" "<<i;
cout<<endl;
			pl--;
		}
	}
   
	return 0;
}
/*
 * qimomoni_2.cpp
 *	????
 *  Created on: 2011-1-8
 *      Author: ???
 */

int Try(int i,char boy){
	char a;
	int b;
	cin.get(a);
	if(a!=boy)
		return i;
	else
	{
		b=Try(i+1,boy);
		cout<<i<<' '<<b<<endl;
		return Try(b+1,boy);
	}
}
int main(){
	int i=0;
	int b;
	char boy;
	cin>>boy;
	b=Try(i+1,boy);
	cout<<i<<' '<<b;
	return 0;
}
char a[110];
int l;
void vv(char a[], char b, char g)
{
    int i, flag = 0;
    l = strlen(a);
    for(i = 0; i < l; i++)
        if(a[i] != '*')
        flag = 1;
    if(flag == 0)
        return ;
    else
    {
    for(i = 0; i < l; i++)
    {
        if(a[i] == g)
        {
            for(int j = i - 1; j >= 0; j--)
            if(a[j] == b)
            {
                cout << j << " " << i << endl;
                a[j] = '*';
                a[i] = '*';
                break;
            }

        }
    }
    vv(a, b, g);
    }
}
int main()
{
    char b, g;
    cin >> a;
    l = strlen(a);
    b = a[0];
    g = a[l - 1];
    vv(a, b, g);

    return 0;
}
int main()
{
	int a[101],i,j,k,l;
	char s[101],mark;
	gets(s);
	l=strlen(s);
	mark=s[0];
	for(i=0;i<=l-1;i++)
	{
		if(s[i]==mark)
			a[i]=1;
		else
			a[i]=0;
	}
	i=0;k=0;
	while(k<l/2)
	{
		if(a[i]==1)
		{
			j=i+1;
			while(a[j]==-1)
			{j++;}
			if(a[j]==0)
			{
				printf("%d %d\n",i,j);
				a[i]=-1;a[j]=-1;
				k++;
				i=0;
			}
			else 
				i++;
		}
		else
			i++;
	}
	return 0;
}
int main()
{
	char a[100];
	int b[100], i, j=0, x;
	scanf("%s", a);
    x=a[0];
	/*for(i=1;i<strlen(a);i++)
	{
		if(a[i]!=a[0]) y=a[i];
	}*/
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]==x) {b[j]=i; j++;}
		else {printf("%d %d\n", b[j-1], i); j--;}
	}
	return 0;
}
/**
* @file homework.cpp
* @author ???
* @date 2011-11-16
* @description
* ??????: ????
*/


int main()
{
	int i, j, k;
	char a[1000];
	cin.getline(a, 1000);
	for (i=1;a[i]!='\0';i++) // ???1????2
	{
		if (a[i]==a[0]) a[i]=1;
		else a[i]=2;
	}
	a[0]=1;
	do
	{
		for (j=0;j<i;j++)
		{
			if (a[j]==2)
			{
				for(k=j-1;k>=0;k--)
				{
					if (a[k]==2) break;
					if (a[k]==1)
					{
						cout<<k<<" "<<j<<endl;
						a[k]=0;
						a[j]=0;
						break;
					}
				}
		
			}
		}
	} while (a[0]!=0);
	return 0;
}
int main()
{
    char a[110]={0};
    int b[110]={0};
    cin>>a;
    int i,p=0,k;
    for(i=0;i<=110;i++)
    {
                       if(a[i]!=0)
                       p++;
    }
    for(i=0;i<=p-2;i++)
    {
                       if(a[i]==a[0]) continue;
                       else 
                       {
                            k=i;
                            while(k>=0)
                            {
                                             if((a[k]==a[0])&&(b[k]==0)) break;
                                             k--;
                            }
                            cout<<k<<" "<<i<<endl;
                            b[k]=1;
                       }
    }
    return 0;
}
int main()
{
	int i,j,k,l,count;
	char s[105],head;
	gets(s);
	l=strlen(s);
	count=0;
	for(;;)
	{
		for(i=0;i<l;i++)
		{
			if(s[i]==' ') i++;
			else 
			{
				head=s[i];
				break;
			}
		}
		for(j=i;j<l;j++)
		{
			if(s[j]!=' '&&s[j]!=head)
			{
				for(k=j-1;k>=0;k--)
				{
					if(s[k]!=' ') break;
				}
				printf("%d %d\n",k,j);
				s[k]=' ';s[j]=' ';
			}
		}
		count+=2;
		if(count==l) break;
	}
	return 0;
}
int main()
{
	char str[110];
	int a[50][2];
	char s;
	int L,i,j,k=0;
	int p=0,t,q,m=0;
	cin.get(str,110,'\n');//??
	L=strlen(str);//???????
	s=str[0];
while(m!=L)
{
	for(i=0;str[i]!='\0';i++)
	{
		if(str[i]==s)
		{
			for( j=i+1;j<L;j++)
			{
				if(str[j]=='a')
					continue;
				else if(str[j]==s)
					break;
				else
				{
					a[p][0]=i;
					a[p][1]=j;
					str[i]='a';
					str[j]='a';
					p++;
					break;
				}
			}
		}
	}//????
m=0;
for(q=0;str[q]!='\0';q++)
		if(str[q]=='a')
			m++;
}

		
		for( i=0;i<L/2-1;i++)
			for( j=i+1;j<L/2;j++)//??
			 if(a[i][1]>a[j][1])
			 {
				 t=a[i][1];
				 a[i][1]=a[j][1];
				 a[j][1]=t;
				 t=a[i][0];
				 a[i][0]=a[j][0];
				 a[j][0]=t;
			 }
		for( i=0;i<L/2;i++)
			cout<<a[i][0]<<" "<<a[i][1]<<endl;//??
		return 0;
}
/*???1000012904-2.cpp
  ?????
  ????????????
  ???2010?12?31?
 */
void qianshou(int a[], int len)
{
	int i,j;
	for(i = 0; i < len; i++)
	{
		if(a[i] == 2)//???????????
		{
			for(j = i - 1; j >= 0 ; j--)
			{
				if(a[j] == 1)//????????????????????
				{
					cout << j << " " << i << endl;
					a[j] = 0;
					a[i] = 0;//??????????
					break;//??????????????
				}
			}
		}
	}
	return;
}
int main()
{
	char str[100];//?????????
	int a[100];//???????????????????
	int i = 0, len;
	cin.getline(str,100);
	len = strlen(str);//????????????str??????????????len
	for(i = 0; i < len; i++)
	{
		if(str[0] - '0' == str[i] - '0')
			a[i] = 1;//????????1
		else
			a[i] = 2;//????????2
	}
	qianshou(a, len);//????
	return 0;
}
void main()
{
	char quene[500]={'\0'},boy,girl;
	int i,n,g=0,pair;
	gets(quene);
	n=strlen(quene);
	pair=n/2;
	boy=quene[0];
	for(i=0;i<n;i++)
	{
		if(quene[i]!=boy)
		{
			girl=quene[i];
			break;
		}
	}
	while(pair>0)
	{
		for(i=g;i<n;i++)
		{
			if(quene[i]==girl)
			{
				g=i;
				break;
			}
		}
		for(i=g;i>=0;i--)
		{
			if(quene[i]==boy)
			{
				printf("%d %d\n",i,g);
				pair--;
				quene[i]='a';
				quene[g]='a';
				break;
			}
		}
	}
}
int main()
{
	char a[110];
	int  t[110],i=0,j=0,b[60],g[60],n=0,d=1,k=0;
	for(i=0;i<110;i++)t[i]=0;
	cin.getline(a,110,'\n');
	for(i=0;a[i]!='\0';)i++;
	n=i;
	for(d=1;d<=n-1;d=d+2)
	{for(i=0;i<n-d;i++)
	{if(a[i]!=a[0]||t[i]==1||t[i+d]==1)continue;
	else{
	if(a[i]!=a[i+d]){
		b[k]=i;g[k]=i+d;t[i]=1;t[i+d]=1;k++;
	}
	}
	}
	}
	for(i=0;i<k-1;i++){
		for(j=0;j<k-1-i;j++){
			int tem;if(g[j]>g[j+1]){
			tem=g[j];g[j]=g[j+1];g[j+1]=tem;tem=b[j];b[j]=b[j+1];b[j+1]=tem;
			}
		}
	}
	for(i=0;i<k;i++)
		cout<<b[i]<<" "<<g[i]<<endl;
	return 0;
}
int main()
{
	char a[101]={0},boy=0,girl=0;//????
	int b[101],i=0,k=0,x=0,n=0,d=0;//??,n?????d???
	for(i=0;i<101;i++)
		b[i]=i;
	for(i=0;;i++)//??
	{
		a[i]=getchar();
		if(a[i]=='\n')
			break;
		n++;
	}
	boy=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]!=boy)
		{
			girl=a[i];
			break;
		}
	}
	d=n/2;
	for(i=0;i<d;i++)
	{
		for(k=0;k<n;k++)
		{
			if(a[k]==boy&&a[k+1]==girl)//???????,???,????????????2?
			{
				cout<<b[k]<<" "<<b[k+1]<<endl;
				for(x=0;x<n-2*i;x++)
				{
					a[k+x]=a[k+x+2];
					b[k+x]=b[k+x+2];
				}
				break;
			}
		}
	}
	return 0;
}
int a[100], n, flag = 0;
char str[100], x, y;
void paidui(int n)
{
	int i = 0;
	for (; i < n;i++)
	{
		if (str[a[i]] == x && str[a[i + 1]] == y)
		{
			cout << a[i] << ' ' << a[i + 1] << endl;
			break;
		}
	}
		for (; i < n - 2; i++)
			a[i] = a[i + 2];
		if (n - 2 >= 2)
			paidui(n - 2);
}
int main ()
{
	cin.getline (str,100);
	n = strlen(str);
	x = str[0];
	for(int i = 0; i < n; i++)
	{
		if (str[i] != x)
		{
			y = str[i];
		    flag = 1;
		}
		if (flag == 1)
			break;
	}
	for (int i = 0; i < n; i++)
		a[i] = i;
	paidui(n);
	return 0;
}
int i=0;
char boy,girl;
void search(char a[])
{
	int j=0,k,bo,gi;
	if(a[0]!='.')
	{
		while(a[j]!=girl)
			j++;
		k=j-1;
		gi=j;
		a[gi]='.';
		while(a[k]=='.')
			k--;
		a[k]='.';
		bo=k;
		cout<<bo<<" "<<gi<<endl;
		search(a);
	}
}
int main()
{
	char a[100];
	cin.getline(a,100);
	while(a[i]!='\0')i++;
	boy=a[0];
	girl=a[i-1];
	search(a);
	return 0;
}
int main()
{
	char c[108];
	int l;
	char key;
	int i, j;
	int a[100];
	int count = 0;

	cin >> c;

	l = strlen(c);
	key = c[0];

	for(i = 0; i < l; i ++)
	if(c[i] != key)
	{
		a[count] = i;
		count ++;
	}

	for(i = 0; i < l / 2; i ++)
	{
		for(j = a[i]; j >= 0; j --)
			if(c[j] == key)
			{
				cout << j << " " << a[i] << endl;
				c[j] = key + 1;
				break;
			}
	}



	return 0;
}
//shu ru fa huai le bu xie zhu shi le = =!
int main()
{
	char str[100];
	cin.getline(str,101);
	int i,j,k,t=0;
	int number[51][2];
	int n=0;
	while(true)
	{
		if(str[n]=='\0')
			break;
		n++;
	}
	for(i=0;i<n-1;i++)
	{
		if(str[0]=='\0')
			break;
		if(str[i]==str[0])
		{
			for(j=i+1;j<n;j++)
			{
				if(str[j]!=str[0])
				{
					for(k=j;k>=0;k--)
					{
						if(str[k]==str[0])
							break;
					}
					str[j]=str[k]='\0';
					number[t][0]=k;
					number[t++][1]=j;
				}
			}
		}
	}
	int d;
	for(i=0;i<t-1;i++)
	{
		for(j=i+1;j<t;j++)
		{
			if(number[i][1]>number[j][1])
			{
				d=number[i][1];number[j][1]=number[i][1];number[i][1]=d;
				d=number[i][0];number[j][0]=number[i][0];number[i][0]=d;
			}
		}
	}
	for(i=0;i<t;i++)
	{
		cout<<number[i][0]<<" "<<number[i][1]<<endl;
	}
	return 0;
}
char x1,x2;
int sum=0;
int c[1000][1000]={0};
int doing(char b[])
{
	int i=0,j=0,z=0;
	for(i=0;i<sum;i++)
	{
   if(b[i]==x1)
      {
	   j=i+1;
	   while(b[j]=='\0')
		   j++;
	   if(b[j]==x2)
	      {
		   c[i][j]=1;
		   b[i]='\0';
		   b[j]='\0';
		   z=0;
		   for(i=0;i<sum;i++)
		      {
			 if(b[i]!='\0')
		     z++;
		      }
		   if(z!=0)
			   doing(b);
		    break;
	      }
	  
       }
	}
  return 0;
}
int main()
{
	int i=0,k=0,l=0;
	char a[1000];
	cin.getline(a,1000);
	
		while(a[i]!='\0')
			i++;
	sum=i;
	x1=a[0];
	i=0;
	while(a[i]==x1)
	{
		i++;
	}
	x2=a[i];
	//cout<<x2;
	doing(a);
	for(k=0;k<1000;k++)
		for(l=0;l<1000;l++)
			if(c[l][k]==1)
				cout<<l<<" "<<k<<endl;
	return 0;
}
void queue(char[],int);
char boy,girl;
int main()
{
	char str[100];
	cin.getline(str,100);
	int l=strlen(str);
	boy=str[0];
	for(int i=1;i<l;i++)
	{
		if(str[i]!=boy) 
		{
			girl=str[i];
			break;
		}
	}
	for(int i=0;i<l;i++)
	{
	  queue(str,l);
	}
	return 0;
}
void queue(char a[],int s)
{
	
	for(int i=0;i<s;i++)
	{
		if(a[i]==boy)
		{
			int k=1;
			while(a[i+k]=='0'){k++;}
			if(a[i+k]==girl)
			{
				cout<<i<<" "<<i+k<<endl;
				a[i]='0';
				a[i+k]='0';
				break;
			}
		}
	}
}
//????????
//??????
//?????2011-1-8 


int main()
{
    char str[500],s1;
    int i,j,t,boy[500],girl[500],p=0,n=0,list[500];
    gets(str);
    s1=str[0];
    for (i=0;i<strlen(str);i++)//???? 
      if (str[i]==s1) {p++;list[p]=i;}
      else {n++;girl[n]=i;boy[n]=list[p];p--;}//??????? 
    for (i=1;i<=n;i++)//?? 
      for (j=1;j<i;j++)
        if (girl[i]<girl[j])
          {
              t=girl[i];
              girl[i]=girl[j];
              girl[j]=t;
              t=boy[i];
              boy[i]=boy[j];
              boy[j]=t;
          }
    for (i=1;i<=n;i++)//?? 
      {
          cout<<boy[i]<<" "<<girl[i];
          if (i!=n) cout<<endl;
      }
    return 0;
}
int main()
{
    int i,j,k,n,p,m,c,l,a[10000],b[10000];
    char str[500],x,y;
    gets(str);
    n=strlen(str);
    y=str[0];
    for (i=0;i<n;i++)
    if (str[i]!=y) x=str[i];
    for (i=0;i<n;i++)
    {
        if (str[i]==x)
        {
            for (j=i;j>=0;j--)
                if (str[j]==y)
                {
                    printf("%d %d\n",j,i);
                    str[j]=' ';
                    break;
                }
            str[i]=' ';
        }
    }
}
int main()
{
	char a[102];
    int b[50],c[50],k,p,q,i,j,s=0,n,min,h,z;
	char f,g;
	gets(a);
	n=strlen(a);
	f=a[0];
     g=a[n-1];
	 for(z=1;z<=50;z++)
	 
	 { for(i=0;i<(n-1);i++){h=0;
		if(a[i]==f)
		{for(j=i+1;j<n;j++)
			{	
				if(a[j]==g)break;
				else
				{if(a[j]==f){h=1;break;}}
		
		}
		if(h==1)continue;
		else {b[s]=i;c[s]=j;a[i]='\0';a[j]='\0';s++;}}}}
		
		for(q=1;q<=n/2;q++){min=300;
		for(k=0;k<n/2;k++)
		{if(c[k]<min){min=c[k];p=k;}}
			printf("%d %d\n",b[p],c[p]);
			b[p]=400;c[p]=400;}

	return 0;
}
// ????.cpp : ??????????????
//


int main()
{
	int y=0,k,x,temp,p,q,t,i,j=0,boy[100],girl[100];
	char a[100];
	char sex[2];
	cin >> a;
	sex[0] = a[0];
	for (i=1;;i++)
	{
		if (a[i]!=a[0])
		{
			sex[1]=a[i];
			break;
		}
	}
	for (i=0;;i++)
	{
		for (k=0;a[k]!='\0';k++)
		{
			if (a[k]!='*')
			{
				y=1;
			}
		}
		if (y==0)
		{
			break;
		}
		y=0;
		if (a[i]=='*')
		{
			continue;
		}
		if (a[i+1]=='\0')
		{
			i=-1;
			continue;
		}
		if (a[i] == sex[0])
		{
			for (k=i+1;a[k]!=sex[0];k++)
			{
				if (a[k]==sex[1])
				{
					a[i]='*';
					a[k]='*';
					boy[j] = i;
					girl[j] = k;
					j++;
					break;
				}
			}
		}
	}
	for (p=0;p<j-1;p++)
	{
		for (q=0;q<j-1-p;q++)
		{
			if (girl[q]>girl[q+1])
			{
				temp=girl[q+1];
				girl[q+1]=girl[q];
				girl[q]=temp;
				temp=boy[q+1];
				boy[q+1]=boy[q];
				boy[q]=temp;
			}
		}
	}
	for (x=0;x<=j-1;x++)
	{
		cout << boy[x] << " " << girl[x] << endl;
	}
	return 0;
}
void fun(char, int);
char a, b;
char s[100];
int main()
{
	int n, i;
	cin >> s;
	n = strlen(s);
	a = s[0];
	b = s[n - 1];
	for(i = 0; i < n; i++)
	{
		fun(s[i],i);
	}
	return 0;
}
void fun(char c, int i)
{
	int k, j = 0;
	if(c == a)
		return;
	else
	{
		for(k = 1;; k++)
		{
			if(s[i - k] == a)
			{
				if(j == 0)
				{
				    cout << i - k << " " << i << endl;
					break;
				}
				else
					j--;
			}
			else
				j++;
		}
	}
	return;
}
void main()
{
	char a[100];
	gets(a);
	int length=strlen(a);
	int i,j;
	int w1,w2;
	char q;
	q=a[0];
	for(i=0;i<length;i++){
		if(a[i]==q){
			for(j=i+1;j<length;j++){
				if(a[j]==' '){
					continue;
				}
				else if(a[j]==q){
					i=j-1;
					break;
					
				}
				else if(a[j]!=q&&a[j]!=' '){
					printf("%d %d\n",i,j);
					a[i]=' ';
					a[j]=' ';
					i=-1;
					break;
				}
			}
		}
	}
}
int main()
{
	char a[110],c,d;
	int i,j,flag,flag1;
	gets(a);
	c=a[0];d=a[strlen(a)-1];
	do
	{
		  flag=0;flag1=0;
		     for(i=0;i<(strlen(a)-1);i++)
			 {
		     	if(a[i]!=1)
				{flag=1;break;}
			 }
			for(i=0;i<(strlen(a)-1);i++)
			{	if(a[i]!=c)
					continue;
				  for(j=i+1;a[j]!=c && j<(strlen(a));j++)
				  {
					  if(a[j]==d)
					{	printf("%d %d\n",i,j);
					   a[j]=1;
					   a[i]=1;
					   flag1=1;
					}
					  if(flag1)
						  break;
				  }
					if(flag1)
						break;
			}
	}
	while(flag);
		return 0;
}
void main()
{
	char c[100];
	int boy[100]={0},girl[100]={0};
	int i,j,k=0,r;
    scanf("%s",c);
	r=strlen(c);
	for(i=0;i<r;i++)
	{
		if(c[i]!=c[0])
		{
			girl[k]=i;
            for(j=i-1;j>=0;j--)
			{
				if(c[j]==c[0])
				{
					boy[k]=j;
					break;
				}
			}
			c[j]='0';
			k++;
		}
	}
	for(i=0;i<k;i++)
		printf("%d %d\n",boy[i],girl[i]);
}
int main()
{
	char a[100];
	cin.getline(a , 100 , '\n');
	//?????
	cout<<endl;
	int len;
	len=strlen(a);//?????????
	int G[50], k=0;
	char b=a[0];
	for (int i=0;i<len;i++)
	{//???????????????
	   if (a[i]!=b) G[k++]=i;
	}
	for (int i=0;i<k;i++)
	{
		for (int j=G[i]-1;j>=0;j--)
		{
		   if (a[j]==b) 
		   {//??????????????????????????
			   cout<<j<<" "<<G[i]<<endl;;
		       a[G[i]]='\0';//??????????????????
			   a[j]='\0';
			   break;
		   }
		}
	}
	return 0;
}
struct children{
	char sex;
	int num;
};
int main()
{
	char line[100];
	int n,m;
	int i,j,k;
	struct children pig[100];
	scanf("%s",line);
	n=strlen(line);
	for(i=1;i<n-1;i++)
	{
		if(line[i]==line[0])
			line[i]='(';
		else
			line[i]=')';
	}
	line[0]='(';
	line[n-1]=')';
	for(i=0;i<n;i++)
	{
		pig[i].num=i;
		pig[i].sex=line[i];
	}
	m=n;
	for(i=0;i<(n/2-1);i++)
	{
		for(j=0;j<m;j++)
		{
			if(pig[j].sex=='('&&pig[j+1].sex==')')
			{
				printf("%d %d\n",pig[j].num,pig[j+1].num);
				k=j;
				for(j;pig[m-3].num!=n-1;j++)
				{
					pig[j]=pig[j+2];
				}
				m-=2;
				break;
			}
		}
	}
	printf("%d %d\n",0,n-1);
	return 0;
}