semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	int i,j,k=0,n,t,b[100][2];
	char x,y,a[100];
	gets(a);
	n=strlen(a);
	x=a[0];
	for(i=1;;i++)
		if(a[i]!=x){y=a[i];break;}
		while(k<n/2)
	for(i=0;i<n;i++)
	{if(a[i]=='2')continue;
		for(j=i+1;a[j]=='2';j++);
		if(a[j]==a[i])continue;
		if(a[j]==y)
		{b[k][0]=i;b[k][1]=j;k++;
		a[i]='2';a[j]='2';}}
	for(i=0;i<n/2-1;i++)
		for(j=0;j<n/2-1-i;j++)
			if(b[j][1]>b[j+1][1])
			{t=b[j+1][1];b[j+1][1]=b[j][1];b[j][1]=t;
			t=b[j+1][0];b[j+1][0]=b[j][0];b[j][0]=t;}
	for(i=0;i<n/2;i++)
		printf("%d %d\n",b[i][0],b[i][1]);

}
/*
 * 1000012826_????.cpp
 *
 *  Created on: 2011-1-5
 *      Author: Administrator
 */

int k;
int len;
void pei(char a[],int k){
      int i,j;
      if(k==len/2)return;//?????????
      for(i=1;i<len;i++){
    	  if(a[i]!=a[0]&&a[i]!='.'){//???????????
    		  for(j=i;j>=0;j--){//??????????
    			  if(a[j]==a[0])
    			  { cout<<j<<" "<<i<<endl;
    			  a[i]='.';a[j]='.';//?????
    			  break;
    			  }
    		  }
    		  break;
    		  }
      }
      k++;//???????
      pei(a,k);
}

int main(){
	char a[101];
	cin.getline(a,100);
	len=strlen(a);
	k=0;
	pei(a,0);
}
int main()
{
	int i,j,u,n,b[N]={0};
	char a[N];
	scanf("%s",a);
	n=strlen(a);
	b[0]=1;
	for(i=1;i<n;i++)
	{
		if(a[i]==a[0]) b[i]=1;
		if(a[i]!=a[0]) b[i]=2;
	}
	u=n/2;
	while(u--)
	{
		for(j=0;j<n;j++)
		{
			if(b[j]==2)
			{
				for(i=j;i>=0;i--)
				{
					if(b[i]==1)
						break;
				}
					printf("%d %d\n",i,j);
					b[i]=0;
					b[j]=0;
			}
		}
	}
		return 0;
}
int main()
{
	char a[101],c;
	int l,sp=0,i,j=1,b[100];
	gets(a);
	l=strlen(a);
	c=a[0];
	b[0]=0;
	for(i=1;i<l-1;i++)
		if(a[i]==c)
			b[j++]=i;
		else printf("%d %d\n",b[--j],i);
	printf("0 %d",l-1);

	return 0;
}
int main()
{
	char boy,girl,children[102]={'\0'};
	int sum,i,j;//sum???????????
	cin.getline(children,101,'\n');
	sum=strlen(children);
	boy=children[0];
	girl=children[sum-1];
	while(children[sum-1]!='\0')
	{
		j=0;
		while(children[j]!=girl&&j<sum)//???????????
			j++;
		i=j-1;
		while(children[i]!=boy&&i>=0)//?????????????????
			i--;
		children[i]='\0';//??????
		children[j]='\0';
		if(j==sum-1)//????????
			cout<<i<<" "<<j;
		else
			cout<<i<<" "<<j<<endl;
	}
	return 0;
}
// ???? ?? 1000062708
int main()
{
	char s[1000001];
	int n, i, j;
	char a, b;
	cin.getline(s,1000001);
	n = strlen(s);
	a = s[0];
	for(i = 0;i < n;i++)
		if(s[i] != a)
		{
			b = s[i];
			break;
		}
	for(i = 0;i < n;i++)
		{
			if(s[i] == b)
			{
				j = i - 1;
				while(s[j] != a) j--;
				s[i] = ' ';
				s[j] = ' ';
				cout << j << " " << i << endl;
			}
		}
	return 0;
}
/**
* ???2010.12.31
* ?????
* ???????
* ??????????????????????????????????????????????????????????????????????
****/

char str[100];
int len;
int num[100];
int paixu[100];
void search(char b,char g)//??gg????????????????????????????????
{
	int i = 0, n =0;
	for( n = 0; n < len ; n++ )
	{
		if(str[n] == g)
		{
			if( str[n-1] == b)
			{
				paixu[num[n]] = num[n-1];
	            i = n-1;
				for(;i <= len; i++)
				{
					str[i] = str[i+2];
				}
				i = n - 1;
				for(; i <= len; i++)
				{
					num[i] =num[i+2];
				}
			}
		}
	}
	if(str[0] != '\0')
	{
		search(b,g);
	}
}
int main ()
{
	
	char b, g,str1[100];
	cin.getline(str , 100);
	b = str[0];//?????????
	int i;
	len = strlen(str);
	for(i = 0;i<len ;i++)
	{
		num[i] = i;
	}
	for(i = 1; str[i] == str[0] ; i++);
	g = str[i];//?????????
	for( i = 0; i < len; i++)
	{
		str1[i] = str[i];
	}
	search(b,g);//????

	for( i = 0; i < len; i++)
	{
		if(str1[i] == g)
		{
			cout << paixu[i] <<" "<<i<<endl;
		}
	}

	
	return 0;
}
int main ()
{
	char s[100];
	char boy, girl, null;
	int i, j, l;
	null = '0';
	scanf ("%s", s);
	l = strlen (s);
	boy = s[0];
	for (i = 0; i < l; i++)
	{
		if (s[i] != s[0])
		{
			girl = s[i];
			break;
		}
	}
	for (i = 0; i < l; i++)
	{
		if (s[i] != null)
		{
		    if (s[i] == girl)
			{
			    for (j = i - 1; j >= 0; j--)
				{
					if (s[j] == boy)
					{
						printf("%d %d\n", j, i);
						s[i] = null;
						s[j] = null;
						break;
					}
				}
			}
		}
	}
	return 0;
}
void main()
{
	int i,j,k,n,num[101];
    char a[101],B,G;
	gets(a);
	n=strlen(a);           //n???
	B=a[0];                //??????????
	G=a[n-1];
    for(i=0;i<=n-1;i++)    //??????
		num[i]=i;
    for(i=1;i<=(n/2);i++)    //?i?
		for(j=0;j<=((n-1)-2*(i-1)-1);j++) //???i??a?????
		{
            if(a[j]==B&&a[j+1]==G)
			{
				printf("%d %d",num[j],num[j+1]);
				printf("\n");
                for(k=j+2;k<=((n-1)-2*(i-1));k++)
				{
					a[k-2]=a[k];
					num[k-2]=num[k];
				}
				j=-1;
			}
		}
}
int counter=0;
void match()
{
    char temp;
    temp=cin.get();
    int num1=counter++;
    while(cin.peek()==temp)
        match();
    cin.get();
    cout<<num1<<' '<<counter++<<endl;
}


int main()
{
    match();
    return 0;
}
int num (char a[]);	//????????
int judge (char a[]);//???????????
int leave (int n,char a[],char b,char g);	//??????????????????
int main ()
{
	char a[105]={0};
	char boy,girl;
	cin.getline (a,101);
	int n;
	n=num(a);
	boy=a[0];girl=a[judge (a)];
	leave (n,a,boy,girl);


	return 0;
}
int num (char a[])
{	
	int n=0;
	for (int i=0;a[i]!=0;i++)
		n=i;
	return n+1;
}
int judge (char a[])
{
	int flag=0;
	for (int i=1;;i++)
		if (a[i]!=a[i-1])	//??????????????????????
		{flag=i;break;}
	return flag;
}
int leave (int n,char a[105],char b,char g)
{
	while (1){
	int flag=-1,flag1,flag2=0;	//flag??????0????flag1???????flag2?????? 
	for (int i=0;i<n;i++)		//??????????
	{
		if (a[i]==b&&a[i+1]==g)	//????????????????0
		{
			cout<<i<<" "<<i+1<<endl;a[i]=0;a[i+1]=0;
			flag1=i;flag2=i+1;break;
		}
		else if (a[i]==b&&a[i+1]==0)//??????0??? 
			flag=i;
		else if (a[i]==g&&flag>=0)	//0??????????????????0
		{	
			cout<<flag<<" "<<i<<endl;
			a[i]=0;a[flag]=0;
			flag1=flag;flag=-1;flag2=i;break;
		}
	}
	if ((flag1==0)&&(flag2==(n-1)))	//?????????????????
		break;
	}
	return 0;
}
/* title :????*
* author : ???*
* time : 2011.11.9 */


int a[100][2];
char c[100];
char b;
int n;

void combine(char c[], int i)
{
	int m, j, k;
	m = strlen(c);
	for(j = 0; j < m; j++)
	{
		if(c[j] != b && c[j] != ' ')
		{
			c[j] = ' ';
			a[i][1] = j;
			for(k = j - 1; k >= 0; k--)
			{
				if(c[k] == b)
				{
					a[i][0] = k;
					c[k] = ' ';
					break;
				}
			}
			break;
		}
	}
	if(i < n / 2 - 1)
		combine(c, i + 1);
}
	

int main()
{
	int j, k, t;
	cin >> c;
	n = strlen(c);
	b = c[0];
	combine(c, 0);
	for(j = 0; j < n / 2 - 1; j++)
	{
		for(k = 0; k < n / 2 - j - 1; k++)
		{
			if(a[k][1] > a[k + 1][1])
			{
				t = a[k + 1][1];
				a[k + 1][1] = a[k][1];
				a[k][1] = t;
				t = a[k + 1][0];
				a[k + 1][0] = a[k][0];
				a[k][0] = t;
			}
		}
	}
	for(j = 0; j < n / 2; j++)
	{
		cout << a[j][0] << " " << a[j][1] << endl;
	}
	return 0;
}
int main()
{
   char a[110];
   int i=0,j,k,l,t1,t2;
   for(;;)
   {
        a[i]=getchar();
        if(a[i]=='\n') break;
        i++;
    }
    l=i-1;
    for(i=0;i<=l;i++)
    {
        if(a[i]!=a[0])
        {
            a[i]=0;
            for(j=i;j>=0;j--)
            {
                if(a[j]==a[0])
                {a[j]=0;
                cout<<j<<" ";
                break;}
            }
            cout<<i<<endl;
        }
    }
        return 0;
}
char a[100], b, g;
int x[100], y[100];
int l;

void couple(int n)
{ 
	if(n == 0)
		return;
	else
	{
		for(int i = 0; i < l-1; i++)
		{
			int j = i + 1;
			if(a[i] == b)
			{
				while(a[j] == '0')
					j++;
				if(a[j] == g)
				{
					cout << i << " " << j << endl;
					a[i] = a[j] = '0';
					return couple(n-2);
				}
			}
		}

	}
}

int main()
{
	cin >> a;
	l = strlen(a);
	b = a[0];
	for(int i = 1; i < l; i++)
	{
		if(a[i] != b)
		{
			g = a[i];
			break;
		}
	}
	couple(l);
	return 0;
}
void f(char a[1000], char b, char g, int len, int k)
{
	int i, j;

    while(k < len - 1)
	{
	for(i = k;i < len;i++)
	{
		if(a[i] == g)     break;
	}
   
	for(j = i-1;j > 0;j--)
	{
		if(a[j] == b)     break;
	}
	if(i == len) break;
	cout << j << " " <<i << endl;
	a[i] = ' ';
	a[j] = ' ';
	f(a, b, g, len, i+1);
	}



}
int main ()
{
	char a[1000], b, g;
	int len, k = 0;
	cin.getline(a, 1000);
	len = strlen(a);
	b = a[0];
	g = a[len - 1];
    f(a, b, g, len, k);
	return 0;
}
int main(){
char kid[101];
scanf("%s",kid);
int zuhe[51][2];
char sigb;
int i,j=0,p;
sigb=kid[0];
for(i=0;i<strlen(kid);i++){
    if(kid[i]!=sigb){
        zuhe[j][1]=i;
        j++;
    }
}
for(j=0;j<strlen(kid)/2;j++){
    p=zuhe[j][1]-1;
    while(kid[p]!=sigb){
            p--;
    }
    zuhe[j][0]=p;
    kid[p]='0';
}
for(j=0;j<strlen(kid)/2;j++){
    printf("%d %d\n",zuhe[j][0],zuhe[j][1]);
}
return 0;
}
int main()
{
	char s[100],a,b;
	int slen,i,j;
	scanf("%s",s);
	slen=strlen(s);
	a=s[0];
	for(i=0;i<slen;i++)
	{
		if(s[i]!=s[0])
		{
			b=s[i];
			break;
		}
	}
	for(i=0;i<slen;i++)
	{
		if(s[i]==b)
		{
			for(j=i-1;j>=0;j--)
			{
				if(s[j]==a)
				{
					printf("%d %d\n",j,i);
					s[j]=0;
					break;
				}
			}
		}
	}
	return 0;
}
char str[100];

int match(char str[], char b, char g)
{
	int i, j;
	for(i = 0; str[i] != '\0'; i++)
	{
		if(str[i] == g)
			break;
	}
	if(str[i] == '\0')
		return 0;
	for(j = i; j >= 0; j--)
	{
		if(str[j] == b)
		{
			cout << j << " " << i << endl;
			break;
		}
	}
	str[i] = '#';
	str[j] = '#';
	match(str, b, g);
}

int main()
{
	char b, g;
	cin >> str;
	b = str[0];
	int i, length;
	length = strlen(str);
	for(i = 0; i < length; i++)
	{
		if(str[i] != b)
		{
			g = str[i];
			break;
		}
	}
	match(str, b, g);
	return 0;
}
void main()
{
	int l,i,t=0,n=0,j,x,y;
	int B[50]={0},G[50]={0};
	char a[100];
	char b,g;
	gets(a);
	l=strlen(a);
	b=a[0];
	for(i=1;i<l;i++){
		if(a[i]!=b){
			g=a[i];
			break;
		}
	}
	for(t=0;t<=l-2;t=t+2){
	for(i=0;i<l-1-t;i++){
		if(a[i]==b&&a[i+t+1]==g){
			B[n]=i;
			G[n]=i+t+1;
			a[i]='q';
			a[i+t+1]='q';
			++n;
		}
	}
	}
	for(i=1;i<n;i++){
		for(j=0;j<n-i;j++){
			if(G[j]>G[j+1]){
				x=G[j];
				G[j]=G[j+1];
				G[j+1]=x;
				y=B[j];
				B[j]=B[j+1];
				B[j+1]=y;
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d %d\n",B[i],G[i]);
	}
}
char c1, c2;
int num, k=0;
int s[1000][2];
int main()
{
	int i,j,temp;
    void f(char str[1000]);
	char c[1000];
	gets(c);
    c1=c[0];
	num=strlen(c);
	for(i=1;i<num;i++)
    {
		if(c[i]!=c1) {c2=c[i];break;}
	}
	f(c);
	for(i=0;i<k;i++)
	{
		for(j=0;j<k-1-i;j++)
		{
		    if(s[j][1]>s[j+1][1])
			{
				temp=s[j+1][1];
				s[j+1][1]=s[j][1];
				s[j][1]=temp;
	            temp=s[j+1][0];
				s[j+1][0]=s[j][0];
				s[j][0]=temp;
			}
		}
	}
	for(i=0;i<k;i++)
	{
		printf("%d %d\n", s[i][0], s[i][1]);
	}
	printf("\n");
	return 0;
}
void f(char str[1000])
{
	int i, j;
	for (i=0;i<num-1;i++)
		if (str[i]==c1)
		for (j=i+1;j<num;j++)
		{
			if (str[j]==c1) break;
			if (str[j]==c2)
			{
				s[k][0]=i; s[k++][1]=j;
				str[i]=' '; str[j]=' ';
				break;
			}
		}
	if (k*2<num)
		f(str);
}
/**
* @file 1.cpp
* @author ???
* @date 2011-09-24
* @description
* ??????:?????
*/

// ??????pai???
int pai(char xiao[], int n, int v, int i)
{
	int j, k; 
	if (xiao[i + 1] == 0)
		return 0;
	for (j = i + 1; xiao[j] != 0; j++)
	{
		if (xiao[j] == v)
			break;
	}
	for (k = j; xiao[k] != 0; k--)
	{
		if (xiao[k] == n)
		{
			xiao[k] = 1;
			break;
		}
	}
	cout << k << ' ' << j <<endl;
	pai(xiao, n, v, j);
	return 0;
}

int main()
{
	int n, i, v;
	char xiao[100] = {0};
	cin >> xiao;
	n = xiao[0];
	for (i = 1; i <= 100; i++)
	{
		if(xiao[i] != n)
		{
			v = xiao[i];
			break;
		}
	}
	pai(xiao, n, v, i - 1);
	return 0;
}
int main()
{
	void handinhand(char xpy[],int num ,int left,char boy,char girl);
	char xpy[101]={'\0'},boy,girl;
	int num;
	cin.getline(xpy,100);//?????
	boy=xpy[0];//????
	for (num=0;xpy[num]!=0;num++) ;
	girl=xpy[num-1];//????
	handinhand(xpy,num,num,boy,girl);//????????
	return 0;
}
void handinhand(char xpy[],int num,int left,char boy,char girl)
{
	int i=0,j,lf=left;
	if (left>0)//??????0
	{
		for (i=0;xpy[i]!=girl;i++) ;//???????,?????????
		for (j=i-1;xpy[j]!=boy&&j>-1;j--) ;//????????????????????
		cout<<j<<' '<<i<<endl;//??2???
		lf=left-2;//??????
		xpy[i]=0;//??2???
		xpy[j]=0;//
		handinhand(xpy,num,lf,boy,girl);//?????????
	}
}
/*
 * yi.cpp
 *
 *  Created on: 2012-10-20
 *      Author: 7
 */
int main()
{
	char s[500];
	int left[500],num[500];
	int flag=0,temp;
	cin>>s;
	int l,i=0,k=0,j;
	for(i=0;i<500;i++)
		num[i]=1000;
	l=strlen(s);
	for(i=0;i<l;i++)
	{
		if(s[i]==s[0])
		{
			left[k]=i;
			k++;
		}
		else
		{
			k--;
			num[flag]=left[k];
			num[flag+1]=i;
			flag=flag+2;
		}
	}
	for(i=0;i<flag;i=i+2)
	{
		for(j=0;j<flag-i;j=j+2)
		{
			if(num[j+1]>num[j+3])
			{
				temp=num[j];
				num[j]=num[j+2];
				num[j+2]=temp;
				temp=num[j+1];
				num[j+1]=num[j+3];
				num[j+3]=temp;
			}
		}
	}
		for(i=0;i<flag;i=i+2)
		{
			cout<<num[i]<<' '<<num[i+1]<<endl;
		}

}
//**********************************************
//**???????******************************
//**?????? 1000012741*********************
//**???2010?12?31?************************
//**********************************************
//??search?????????????len???????t????????p?q?????????????
void search (char str[502], int len, int t, char p, char q)
{	
	int i, j, m = 0;                                 //m??????????????????????????
	if (str[len - 1] == '0')                         //??????????????
		return;
    for (j = t; j < len && m == 0; j++)              //?t???????????????
	{
		if (str[j] == q)
		{
			for (i = j - 1; i >= 0 && m == 0; i--)   //????????????????????
			{
				if (str[i] == p)                     //??????????
				{
						str[i] = '0';
						str[j] = '0';
						cout << i << " " << j << endl;
						m = 1;                       //?m????????????????????????
				}
			}
		}
	}
	search(str, len, j, p ,q);                       //??????????
}
int main()
{ 
	char str[502], p, q;                             //str????????p?????????q????????
	cin >> str;
	int len = strlen(str);                           //???????
    p = str[0];                                      //??????????????
	for (int i = 1; str[i] != '\0'; i++)             //????????????q
	{
		if (str[i] != p)
		{
			q = str[i];
			break;
		}
	}
	search(str, len, 1, p, q);                      //??search??
	return 0;
}
//**********************************************
int flag[101]={0};
char str[101];
char b,g;
void match(int girl)              //int girl's pos
{
	int j;
	for(j=girl;j>=0;j--)
	{
		if(str[j]==b&&flag[j]==0)
		{
			cout<<j<<' '<<girl<<endl;
			flag[j]=1;
			break;
		}
	}
	return ;
}

int main()
{
	int i=0;
	cin >> str;
	b=str[0];
	int len=strlen(str);
	while(str[i]==b)i++;
	g=str[i];
	for(;i<=len-1;i++)
	{
		if(str[i]==g)match(i);
	}
	return 0;
}
struct ranking
{
            int sex;
            int order;
}stu[100];
void check(int len)
{
     int x,y;
     for(x=0; x< len-1; x++){
              if(stu[x].sex ==1 && stu[x+1].sex ==0){
                            cout << stu[x].order <<" " << stu[x+1].order << endl;
                            for(y=x; y<len-2; y++){
                                     stu[y]= stu[y+2];
                            }
                            return;
              }
     }           
}

int main(int argc, char *argv[])
{
    char ary[100], boy, girl;
    int len, order[100];
    int i,j,k;
    gets(ary);
    len = strlen(ary);
    if(len%2 ==0){
             for(i=0; i<len; i++){
                      order[i]= ary[i] == ary[0]? 1:0;
             }
    
             for(j=0; j< len; j++){
                      stu[j].sex= order[j];
                      stu[j].order= j;
             }
             while(len!=0){
                           check(len);
                           len-=2;
             }
    }
    else
    cout<< "wrong input" << endl;
    
    
   
    return EXIT_SUCCESS;
}
char dui_lie[100],zuo,you;
int zuobian,youbian,changdu;//?????? 

void qian_shou(int zuobian)//???? 
{
    for(youbian=zuobian+1;youbian<changdu;youbian++)
    {
                              if(dui_lie[youbian]==zuo || dui_lie[youbian]==you)
                              break;
    }//??????????????????????? 
    if(dui_lie[youbian]==you)
    {
                             dui_lie[zuobian]='*';
                             dui_lie[youbian]='*';
                             cout<<zuobian<<" "<<youbian<<endl;
    }//???????????????????????? 
    else
    {
        zuobian=youbian;
        qian_shou(zuobian);
    }//????????????????????????????? 
}



int main()
{
    
    int i;
    cin>>dui_lie;
    changdu=strlen(dui_lie);
    zuo=dui_lie[0];
    you=dui_lie[changdu-1];//???????????? 
    for(i=1;i<=changdu/2;i++) 
    {
                        zuobian=0;//??????????????? 
                        qian_shou(zuobian);
    } //??????????? 
return 0;
}
struct stu
{
	char c;
	int x;
};
struct stu stu1[1000],*p;

void main()
{
	int n,i,j,k;
	char s[1000];
	gets(s);
	n=strlen(s);
	p=stu1;
	for(i=0;i<n;i++)
	{
		(p+i)->c=s[i];
		(p+i)->x=i;

	}

	for(i=0;i<n;i++)
	{
		if((p+i)->c!=s[0])
		{
			printf("%d %d\n",(p+i-1)->x,(p+i)->x);n=n-2;
			for(j=i-1;j<n;j++)
			{
				(p+j)->c=(p+j+2)->c;
				(p+j)->x=(p+j+2)->x;
			}
			i=0;
		}
	}
}
int judge(int s,char k[])
{
	int sum=0,p;
	for(int i=0;i<s;i++){
		if (k[i]==' '){
			sum++;}}
	if (sum==s)p=1;
	else p=0;
	return(p);
}
int main()
{
	int i=0;
	char kids[110],boy,gal;
	cin.getline(kids,110);
	for(i=0;i<strlen(kids);i++)
	    if (kids[i]!=kids[i+1]){
			boy=kids[i];
			gal=kids[i+1];
			break;}
	while(judge(strlen(kids),kids)!=1){
		if (kids[i]==boy&&kids[i+1]==gal){
			cout<<i<<" "<<i+1<<endl;
			kids[i]=' ';
			kids[i+1]=' ';
			i=0;}
		else if (kids[i]==' '&&kids[i+1]==gal){
			for(int j=i;j>=0;j--){
				if (kids[j]==boy){
					cout<<j<<" "<<i+1<<endl;
					kids[i+1]=' ';
					kids[j]=' ';
					i=0;
					break;}}}
		else i++;}					
	return 0;
}
//***********************************
//*???????                 **
//*??????1100012914         **
//*???.11.18                  **
//***********************************

char queue[100], ch1, ch2;
int i, n, t, s;

void take_hand(int);

int main()
{
	cin >> queue;
	ch1 = queue[0];
	n = strlen(queue);
	for (i = 0; i < n; i++)
	{
		if (queue[i] != ch1)
		{
			ch2 = queue[i];
			break;
		}
	}
	for (s = 0; s < n / 2; s++)
	{
		i = 0;
		take_hand(i);
	}
	cin >> i;
	return 0;
}

void take_hand(int j)
{

	for (t = j + 1; t < n; t++)
	{
		if (queue[t] == ch1 || queue[t] == ch2)
			break;
	}
	if (queue[t] == ch2)
	{
		queue[j] = '*';
		queue[t] = '*';
		cout << j << " " << t << endl;
	}
	else
	{
		j++;
		take_hand(j);
	}
}
/*
 * 7.cpp
 *
 *  Created on: 2011-1-8
 *      Author: 10033
 */


int n,n0,i,j;
char nan,nv;
char a[1000];//????

void paidui(int j){//???????j=0????????????
	int k;
	for(k=j;k<n0;k++)
		if(a[k]==nan)break;
	j=k;
	for(i=j+1;i<n0;i++)//??????
		if(a[i]!='.')
			break;
	while(a[i]==nan){//????????????
		paidui(j+1);
		for(i=j+1;i<n0;i++)
			if(a[i]!='.')
				break;
	}
	if(a[i]==nv){//??j????,??,?".",????
		cout<<j<<" "<<i<<endl;
		a[j]='.';
		a[i]='.';
		return;
	}
}
int main(){//????
	cin.getline(a,100);//??
	nan=a[0];//????
	n0=strlen(a);//???
	nv=a[n0-1];//????
	paidui(0);//????
	return 0;
}//????
//*************************************************************
//*                  ?????????                       *
//*                  ?????1000010573                     *
//*                  ?????2011?01?                     *         
//*************************************************************



char str[100];
int len = 0;
int num[100] = {0} ;
int paixu[100] = {0} ;
void search(char b,char g)
{
	int i = 0, n =0;
	for( n = 0; n < len ; n++ )
	{
		if(str[n] == g)
		{
			if( str[n-1] == b)
			{
				paixu[num[n]] = num[n-1];
	            i = n-1;
				for(;i <= len; i++)
				{   str[i] = str[i+2];  }
				i = n - 1;
				for(; i <= len; i++)
				{	num[i] =num[i+2];   }
			}
		}
	}
	if(str[0] != '\0')
	{
		search(b,g);
	}
}
int main ()
{
	
	char b, g,str1[100];
	cin.getline(str , 100);
	b = str[0];//?????????
	int i;
	len = strlen(str);
	for(i = 0;i<len ;i++)
	{
		num[i] = i;
	}
	for(i = 1; str[i] == str[0] ; i++);
	g = str[i];//?????????
	for( i = 0; i < len; i++)
    {   str1[i] = str[i];   }
	search(b,g);//????

	for( i = 0; i < len; i++)
	{
		if(str1[i] == g)
		{	cout << paixu[i] <<" "<<i<<endl;    }
	}

	
	return 0;
}
int count = 0, n = 0;

int line(char b[], int y[])
{
	int f, len;
	len = strlen(b);
	if (n == 0)
	{
		cout << y[0] - 1 << " " << y[0] << '\n';
		b[y[0]] = '0';
		b[y[0]-1] = '0';
	}
	else
	{
		if (y[n-1] + 1 < y[n])
		{
			for (f = y[n] - 1; b[f] != '0'; f--)
			{
				cout << f << " " << y[n] << '\n';
				b[f] = '0';
				b[y[n]] = '0';
				break;
			}
		}
		else 
		{
			f= y[n] - 1;
			do
			{ 
				if (b[f] == '0')
					f--;

				else
				{
					cout << f << " " << y[n] << '\n';
					b[f] = '0';
					b[y[n]] = '0';
					break;
				}

			}while (1);
		}
	}
	n++;
	if (n < len / 2)
		line(b, y);
	else
		return 0;
}

int main()
{
	char a[100];
	int i, j = 0, x[100];
	cin >> a;
	for (i = 0;a[i] != 0;i++ )
	{
		if (a[i] != a[0])
		{
			x[j] = i;
			j++;
		}
	}
	line(a, x);
	return 0;
}
//*******************************************************
//*11.15??  ????                                  *
//*?????  ?? 1100012844                          *
//*???2011?11?23?                                 *
//*******************************************************
char a[100], boy, girl;
int girlNO[50], flag[100] = {0};
void qianshou(int k)
{
	int i;
	if (k != 0)
		qianshou(k - 1);
	i = girlNO[k] - 1;
	while (a[i] == girl || flag[i])
		i--;
	cout << i << " " << girlNO[k] << endl;
	flag[i] = 1;
}
int main()
{
	int j = 1, n = 0;
	a[0] = cin.get();
	boy = a[0];
	while ((a[j] = cin.get()) != '\n')
	{
		if (a[j] != boy)
		{
			girlNO[n] = j;
			n++;
		}
		j++;
	}
	girl = a[j - 1];
	qianshou(n - 1);
	return 0;
}
//********************************
//*???? 
//********************************


char a[110];
int a1[110] = {0};
int l;
char b,g;

void fi(int i)
{
	int j,k;
	for (j = i + 1; j < l; j++)
	{
		if (a[j] == g)
		{
			if (!a1[j])
			{
				for (k = j - 1; k >= 0; k--)
				{
					if((a[k] == b) && (!a1[k]))
					{
						cout << k << " " << j << endl;
						a1[k] = 1;
						a1[j] = 1;
						break;
					}
				}
			}
		}
	}
	return;
}

int main()
{
	int i;
	cin.getline(a,110);
	l = strlen(a);
	b = a[0];
	for (i = 0; i < l; i++)
	{
		if (a[i] != b)
		{
			g = a[i];
			break;
		}
	}
	fi(-1);
	cin.get();
    cin.get(); //????
	return 0;
}
int flag[100]={0};
void pailie(char b[100],int l)
{
	int i,j;
	int g=0;
	if(flag[l-1]==1);
        else
	{
	   for(i=0,g=0;i<l;i++)
	   {
		if(flag[i]==1) continue;
		for(j=i+1;j<l;j++)
		{
			if(flag[j]==1) continue;
			if(b[i]!=b[j])
			{
				cout<<i<<' '<<j<<endl;
				flag[j]=1;
				g=1;
				flag[i]=1;
				break;
			} 
			else break;
	   	}
		if(g==1) break;
	    }
	pailie(b,l);
	}
}
int main ()
{
	char a[100];
	int i,len;
	cin.getline(a,100);
	len = strlen(a);
	pailie(a,len);
	return 0;
}