semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
char a[100];
int counter;
int line[100];
void out(int l)
{
	int record;
	if (counter==0)
	{return;}
	for (int i=0;i<l;i++)
	{
		if (line[i]==1)
		{
			record=i;
			continue;
		}
		if (line[i]==0)
		{
			line[record]=-1;
			line [i]=-1;
			cout<<record<<' '<<i<<endl;
			counter-=2;
			out(l);
			break;
		}
	}
}

int main()
{ 
	cin.getline(a,100);
	char boy=a[0];
	int len=strlen(a);
	counter=len;
	for (int i=0;i<len;i++)
	{
		if (a[i]==boy)
		{line[i]=1;}
		else
		{line[i]=0;}
	}
	out(len);
	return 0;
}
int main()
{
    char s1,s2,a[100],p;
    int i,j,k,n,flag,tj,ttj;
    scanf("%s",a);

    for(i=0;;i++)
    {



        for(k=i;;k++)
        {
            if(a[k]=='\0')
            break;
            if(a[k]!='0')
            flag=1;
        }
        if (flag==0)
        break;
        flag=0;



        for(j=i;;j++)
        {
            if(a[j]!='0')
                {s1=a[j];
                tj=j;

              /*  printf("%c",s);  */
                break;}
        }


        for(j++;;j++)
        {
            if(a[j]!='0')
                {s2=a[j];
                ttj=j;
              /*  printf("%c",s);  */
                break;}
        }







        if(s1!=s2)
        {
            printf("%d %d\n",tj,ttj);

            a[tj]='0';
            a[ttj]='0';
            i=-1;
        }

        /*printf("%s\n",a);     */
    }


    return 0;
}
//****************************************
//*???????                       
//*?????? 1100012789      
//*???2011.11.16                       
//****************************************

char line[100], boy; // line?????boy????????
int flag[100] = {0}; // flag??????????0???????
int girlNum[50], n; // girlNum???????????
void FindBoy(int j);
int main()
{
	int i = 1, j = 0;
	line[0] = cin.get(); // ??????????
	boy = line[0];
	while ((line[i] = cin.get()) != '\n')
	{
		if (line[i] != boy) // ????????????
			girlNum[j++] = i;
		i++;
	}
	n = i;
	FindBoy(n / 2 - 1); // ???????????
	return 0;
}
void FindBoy(int j)
{
	int i;
	if (j != 0)	// ??????????????????????
		FindBoy(j - 1);
	for (i = girlNum[j] - 1; flag[i] == 1 || line[i] != boy;) // ???????????
		i--;
	cout << i << " " << girlNum[j] << endl; // ????
	flag[girlNum[j]] = 1; // ????????
	flag[i] = 1;
}
char d,e;
void sort(char *t,char *p,char *q,int i)
{
	int j,n;
	for(j=0;j<i;j++)
	{
		if(t[j]==e)
		{
			t[j]=0;
			*q=j;
			for(n=j;n>=0;n--)
			{
				if(t[n]==d)
				{
					t[n]=0;
					*p=n;break;
				}
			}
		break;
		}
	}
}
main()
{
	char a[100],b[50],c[50],*p,*q,*t;
	int i,j;
	p=b;q=c;t=a;
	for(i=0;i<100;i++)
	{
		scanf("%c",&a[i]);
		if(a[i]==10) break;
	}
	d=a[0];e=a[i-1];
	for(j=0;j<i/2;j++,p++,q++)
	{
		sort(t,p,q,i);
	}
	p=b;q=c;
	for(j=0;j<i/2;j++)
	{
		printf("%d %d\n",p[j],q[j]);
	}
	return 0;
}
int play(int a, int* blank1, int* blank2,int bad);

int main()
{
	char a[100];
	cin >> a;
	int blank1[100];
	int blank2[100];
	memset(blank1,-1,99 * sizeof(int));
	memset(blank2,-1,99 * sizeof(int));
	int w = 0,j = 0;
	for (;w < 100;w++)
	{
		if(a[w] != a[0])
		{
			blank1[j] = w;
			blank2[w] = j;
			j++;
		}
	}
if(j == 0)cout << j;
int i = 0;
	for (;i < j; i++)
	{
		cout << play(blank1[i],blank1,blank2,0) << ' ' << blank1[i] <<endl;
	}
if(i == 0)cout << i;
}

int play(int a, int* blank1, int* blank2,int bad)
{
	if(blank2[a - 1] == -1 && bad == 0)
		return a - 1;
	else if(blank2[a - 1] == -1 && bad != 0)
		return play(a - 1,blank1,blank2,bad-1);
	else
		return play(a - 1,blank1,blank2,bad+1);
}
char str[201];                  
int flag[101];                 
int i , k , length;
char a , b;                //?????? 
void f(char s[] , int l);  //???? 
int main()
{
	int j = 0;
	cin >> str;
	length = strlen(str);    //???????? 
	a = str[0];
	b = str[length - 1];            //????????a,b 
	for(i = 1; i <= length - 1; i++)
	{
		if(str[i] == b)       
		{
			j++; 
			flag[j] = i;	
		}	
	}
	k = j;                        //???????k 
	f(str , 1);                 
	return 0;
}	
void f(char s[] , int l)
{
	if(l <= k)
	{
		for(i = flag[l]; i >= 0; i--)    
		{
			if(s[i] == a)
			{
				cout << i << " " << flag[l] << endl;     //???????????????? 
				s[i] = '\0';
				s[flag[l]] = '\0';	              //?? 
				break;
			}	
		}	
		f(s , l + 1);  //?? 
	} 
	else
	return ;
}
int main()
{
	char str[100];
	int a[100],i,j,n;
	scanf("%s",str);
	n=strlen(str);
	for(i=0;i<=n-1;i++)
	{
		if(str[i]!=str[0])a[i]=100+i;
		else a[i]=i;
	}
	for(i=1;i<=n-1;i++)
	{
		if(a[i-1]<100&&a[i]>100)
		{
			printf("%d %d\n",a[i-1],a[i]-100);
			for(j=i-1;j<=n-3;j++)a[j]=a[j+2];
			i=0;
		}	
	}
}
char str[100]={0},p1,p2;
int p[100]={0},i,j,len,n1,n2,n=0;
void rank()
{
	for(i=0;i<len;i++)
	{
		if(p[i]==2){
			n1=i;
			p[i]=3;
			break;}}
			for(j=n1-1;j>=0;j--){
				if((p[j]!=2)&&(p[j]!=3))
					break;}
					n2=j;
					p[n2]=3;
				
			
	cout<<n2<<" "<<n1<<endl;
	n++;
	if(n<len/2)
		rank();
}
int main()
{
	cin>>str;
	len=strlen(str);
	p1=str[0];
	for(i=0;i<len;i++){
		if(str[i]!=p1)
		break;}
	p2=str[i];
	for(i=0;i<len;i++){
		if(str[i]==p1)
			p[i]=1;
		else
			p[i]=2;
	}
	rank();
	return 0;
}
void main()
{
    char c[100],z;
    int i,j=0,k,n,a[50];
    gets(c);
    n=strlen(c);
    z=c[0];
    for(i=0;i<n;i++)
    {
        if(c[i]==z) {a[j]=i;j++;}
        else
        {
            for(k=j-1;k>=0;k--)
            {
                 if(a[k]>=0) 
                 {printf("%d %d\n",a[k],i);a[k]=-1;break;} 
            } 
        } 
    }                     
}
void f(char a[], int l,char girl, char boy)
{
	if(a[0]!='.')
	{
		int i,j;
		for(i=1;i<l;i++)
		{
			if(a[i]==girl)
			{
				a[i]='.';
				for(j=i-1;j>=0;j--)
				{
					if(a[j]==boy)
					{a[j]='.';
					 printf("%d ", j);
					 j=-1;}
				}
				printf("%d\n", i);
				f(a,l,girl,boy);
				i=l;
			}
		}
	}
}

void main()
{
	char a[100];
	gets(a);
	int l;
	l=strlen(a);
	f(a,l,a[l-1],a[0]);
}
/*??????????????????????????????????????????????????????????????????????????0??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????     ??????????????????????????????????????????????????????????????????????100*/
int main()
{
	void ls(char c[],char,char);//????????????
	char c[101]={'\0'};
	cin.getline(c,101);
	char t1,t2;//??????????????
	t1=c[0];
	for(int i=0;i<101;i++)
		if(c[i]!=c[0])
	    {t2=c[i];break;}
	ls(c,t1,t2);
	return 0;
}

void ls(char c[],char t1,char t2)
{
	int i,j;
	if(c[0]!=' ')
	{
		for(i=0;c[i]!='\0';i++)
	    {
			if(c[i]==t2)//?????
			{
				for(j=i-1;j>=0;j--)//?????????
			    {
				if(c[j]==t1)
				{cout<<j<<' '<<i<<endl;
				c[i]=c[j]=' ';break;}//?????????????????
			    }
				break;
			}
		}
		ls(c,t1,t2);//??????????????
	}
}
//
//  main.cpp
//  ????
//
//  Created by ???? on 13-12-26.
//  Copyright (c) 2013? ????. All rights reserved.
//



int main()
{
    char a[100];
    cin.getline(a,100);
    int num[100];
    int len=(int)strlen(a);
    //cout<<len;
    num[0]=0;
    int k=0;
    char b=a[0];
    for(int i=1;i<len;i++)
    {
        if(a[i]==b){  num[++k]=i;  }
        else {   cout<<num[k]<<' '<<i<<endl;  k--;}
    }
    
    return 0;
}
struct child
{
	char c;
	int a;
}dui[100];
void print(struct child dui[],int n)
{ 
	int i;
	if(n==2)printf("%d %d",dui[0].a,dui[1].a);
	else
	{
		for(i=1;i<n;i++)
		{
			if(dui[i].c!=dui[i-1].c)
			{
				printf("%d %d\n",dui[i-1].a,dui[i].a);
				for(i=i+1;i<n;i++)
				{
					dui[i-2]=dui[i];
				}
				print(dui,n-2);
				break;
			}
		}
	}
}
void main()
{
	int i,n;
	char s[100];
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++)
	{
		dui[i].c=s[i];
		dui[i].a=i;
	}
	print(dui,n);
}
int main()
{
	char kid[101];
	int i,j;
	gets(kid);
	for(i=0;i<strlen(kid);i++)
	{
		if(kid[i]!=kid[0])
		{
		  j='0';
		  for(j=i-1;;j--)
		  {
			  if(kid[j]!='0')
			  {
				  break;
			  }
		  }
          if(kid[i]!=kid[j])
		  {
			  printf("%d %d\n",j,i);
			  kid[i]='0';
			  kid[j]='0';
		  }
		}
	}

	return 0;
}
int main()
{
	void sort(int[],int[],int);
	char str[1000],f,s,stack[1000];
	int sum=0,j,i,l=0,tot=-1,boy[500],girl[500],pair=-1,num[1000];
	gets(str);
	l=strlen(str);
	for (i=0;i<l;i++)
	{
		if (i==0) 
		{
			f=str[sum++];
			stack[++tot]=f;
			num[tot]=i;
			continue;
		}
		if (sum<2 && str[i]!=f) 
		{
			sum++;
			s=str[i];
printf("%c %c\n",f,s);
		}
		stack[++tot]=str[i];
		num[tot]=i;
for (j=0;j<tot+1;j++) printf("%c",stack[j]);
printf("%d\n",tot);
		while (tot>0 && sum>1 && stack[tot]==s && f==stack[tot-1])
		{ 
			girl[++pair]=num[tot--];
			boy[pair]=num[tot--];
printf("%d %d\n",boy[pair],girl[pair]);
		}
	}
	sort(boy,girl,pair);
	for (i=0;i<pair;i++)
		printf("%d %d\n",boy[i],girl[i]);
	printf("%d %d",boy[pair],girl[pair]);
	return 0;
}

void sort(int a[],int b[],int c)
{
	void swap(int,int);
	int i,j,k;
	for (i=0;i<c;i++)
	{
		k=i;
		for (j=i+1;j<c+1;j++)
			if (b[j]<b[k]) k=j;
		swap(a[i],a[k]);
		swap(b[i],b[k]);
	}
}

void swap(int x,int y)
{
	int t;
	t=x;
	x=y;
	y=t;
}
int main(){
	char b[100]={0};
	scanf("%s",b);
	char nan=b[0];
	int N,n;
	N=strlen(b);
	n=N/2;
	b[strlen(b)]=0;

	int i,j,k,r;
	for(r=0;r<n;r++){
	for(i=0;i<N;i++){
		if(b[i]!=nan&&b[i]!=0){
			for(j=i-1;j>=0;j--){
				if(b[j]==nan){
					k=j;
					break;
				}
			}
			b[i]=0;
			b[k]=0;
			printf("%d %d\n",k,i);
			break;
		}
	}
	}
}
int main ()
{
	char c[200],p,q;
	int i,j,k,n,a[100],b[100];
	while(cin>>c)
	{
	n=strlen(c);
	k=0;
	p=c[0];
	q=c[n-1];
	for(i=0;c[i]!='\0';i++)
		if(c[i]==q)
			for(j=i-1;j>=0;j--)
			{
				if(c[j]!=p&&c[j]!=q)
					continue;
				else if(c[j]==p)
				{
					a[k]=j;
					b[k]=i;
					c[i]='o';
					c[j]='o';
					k++;
					break;
				}
				else if(c[j]=='(')
					break;
			}
	for(i=0;i<k;i++)
		cout<<a[i]<<" "<<b[i]<<endl;
	}
	return 0;
}
int boy,girl,l=0;//???????????????
void match(char c[],int left)
{
	int i=0,j=0;
	for(i=0;i<l;i++)
	{
		if(c[i]==girl)
		{
			for(j=i-1;j>=0;j--)
			{
				if(c[j]==boy)
				{
					cout<<j<<" "<<i<<endl;
					break;
				}
			}
			c[i]='0';c[j]='0';
			left=left-2;
			break;
		}
	}
	if(left>0)
		match(c,left);
}
int main()
{
	char str[100];
	cin.getline(str,100);
	boy=str[0];
	l=strlen(str);
	girl=str[l-2];
	match(str,l);
	return 0;
}
int a[100];
int n;    //:n???????n1??????
int n1;
int main()
{
	void digui(int);
	char str[100];
	cin>>str;
	n=strlen(str);
	n1=n;

	for (int i1=0;str[i1]!='\0';i1++)
	{
		if ( str[i1]==str[0])   //:????1?????0?????-1
			a[i1]=1; 
		else a[i1]=0;
	}

	digui(n);  //:?n??????
	return 0;
}


void digui(int n)
{
	int count=0;
	int t=0;
	if ( n==2)  //:??2?????????
	{
		for (int i=0;i<n1;i++)
		{
			if ( a[i]!=-1 && count==0)
			{
				cout<<i<<" ";
				count++;
				a[i]=-1;
			}
			else if (a[i]!=-1 && count>0)
			{
				cout<<i;
				count++;
				a[i]=-1;
			}
		}
		cout<<endl;
	}

	else if (n>2)  //:?????????????????????????-1
	{
		for (int i=0;i<n1-1;i++)
		{
			if ( a[i]==1)
			{
				for (int j=i+1;j<n1;j++)
				{
					if (a[j]==-1)
						continue;
					else if ( a[j]==1)
						break;
					else if ( a[j]==0)
					{
						cout<<i<<" "<<j<<endl;
						a[i]=-1;
						a[j]=-1;
						digui(n-2);   //:????2??????????
					}
				}
			}
		}
	}
}
char str[100];
int i, k, l, j, p, q;
int nan, nv, nan1[100], nv1[100], nan2[100];
void pai();
int main()
{
	cin >> str;
	for(i = 1; ; i++)
	{
		if(str[i] != str[0])
		{
			k = i; break;
		}
	}
	for(i = 0; str[i] != '\0'; i++)
	{
		l++;
	}      
	j = 0;
	p = 0;
	for(i = 0; i < l; i++)
	{
		if(str[i] == str[0])
		{
			nan++;
		    nan1[j++] = i;
		}
		if(str[i] == str[k])
		{
			nv++;
			nv1[p++] = i;
		}
	}
	pai();
	return 0;
}
void pai()
{
	i = 0;
	j = 0;
	p = 0;
	for(i = 0; str[i] != '\0'; i++)
	{
	if(str[i] == str[0])
	{
		nan2[j] = 1;
	    j++;
	}
	if(str[i] == str[k])
	{
		for(q = j; q >= 0 ; q--)
		{
			if(nan2[q])break;
		}
	    cout << nan1[q] << ' ' << nv1[p] << endl;
		p++;
		nan2[q] = 0;
	}
	}
}
int paidui(int i,char a[110],int l)//????,i??????,l???????
{
	int j;
	if(a[i]==a[0]&&i<l)//??a[i]????????
	{
		j=paidui(i+1,a,l);//????paidui(i+1,a,l)
		cout<<i<<" "<<j<<endl;//??i j
		return paidui(j+1,a,l);//??paidui(j+1,a,l)
	}
	else if(a[i]!=a[0]&&i<l) //??a[i]?????????
			return i;//??i
}
int main()
{
	int l;
	char a[110];
	cin.getline(a,110);//??????
	l=strlen(a);
	paidui(0,a,l);
	return 0;
}
// ?????? ???1000010500 
// ???? 
// 2010-12-31

void print(int n,char xulie[],int m,int f)
{
    int i,j;
    for (i = 0;i <= n;i++)
        if (xulie[i] == m)
            for (j = i + 1;j <= n;j++)
            { 
                if (xulie[j] == '0')               // ????????? 
                   continue;
                else if (xulie[j] == f)
                {
                    xulie[i] = '0';                // ?????????'0' 
                    xulie[j] = '0';
                    cout << i << " " << j << endl; // ?????? 
                    print(n,xulie,m,f);            // ???? 
                }
                else
                    break;
            }
    return;
}   
int main()
{
    char xulie[100],m,f;                   // m??????f????? 
    int len;
    cin.getline(xulie,101);
    len = strlen(xulie);                   // ????? 
    m = xulie[0];
    f = xulie[len - 1];
    print(len - 1,xulie,m,f);
    return 0;
}
int x=0;
int main()
{
	char a[100];
	int N(char a[],char f);
	cin.getline(a,100);
	char m1;
	m1=a[0];
	N(a,m1);
}
int N(char a[],char f)
{
	char m=f;
    lop:
	if(a[x]==m)
	{
		int l=x;
		x++;
		cout<<l<<" "<<N(a,m)<<endl;
		goto lop;
	}
	if(a[x]!=m&&a[x]!='\0')
	{
		x++;
		return x-1;
	}

	if(a[x]=='\0')
	return 0;
}
struct student{
	int boy;
	int girl;
};
struct student out[PI];
struct student tmp;
int len,k=0;
char s[PI];
char b,g;

void output()
{
	int i,j;
	for (i=0;i<k;i++)
	{
		for (j=i+1;j<k;j++)
		{
			if (out[i].girl>out[j].girl)
			{
				tmp.boy=out[i].boy;
				tmp.girl=out[i].girl;
				out[i].boy=out[j].boy;
				out[i].girl=out[j].girl;
				out[j].boy=tmp.boy;
				out[j].girl=tmp.girl;
			}
		}
	}
	for (i=0;i<k;i++)
		printf("%d %d\n",out[i].boy,out[i].girl);
}


void outing(int x)
{
	int l,r;
	l=1;r=0;
	int i,j;
	j=0;
	for (i=0;i<len;i++)
	{
		if (s[i]!='0')
			j++;
	}
	if (j==0)
		output();
	else
	{
	for (i=x+1;i<len;i++)
	{
		if (s[i]==b)
		{
			l++;
		}
		if (s[i]==g)
		{
			r++;
			if (r==l)
			{
				s[x]='0';
				s[i]='0';
				out[k].boy=x;
				out[k].girl=i;
//				printf("%d %d\n",out[k].boy,out[k].girl);
				k++;
				break;				
			}
		}
	}
	outing(x+1);
	}
	
}

int main()
{
	scanf("%s",s);
	int i;
	len=strlen(s);
	b=s[0];
	for (i=0;i<len;i++)
	{
		if (s[i]!=b)
		{
			g=s[i];
			break;
		}
	}
	outing(0);
	return 0;
}
//***********************************************************************
//??????? 
//??????? 
//??????
//***********************************************************************
void turn(int n, char a[]);                 //????turn 
int main()                                  //??? 
{
    char str[101], g, b;
    int c = 1, p[101] = {0};
    str[0] = cin.get();
    b = str[0];
    for(int i = 1; i < 101; i ++)
    {
            str[i] = cin.get();
            if(str[i] != str[0] && str[i] != '\n')
            { 
                      g = str[i];
                      p[i] = 1;
            } 
            if(str[i] == '\n')
                      break; 
            c++;
    }
    for(int i = 1; i < c; i++)
    {
            if(str[i] == g)
            {
                      for(int j = i - 1; j >= 0; j--) 
                      if(p[j] == 0)
                      {
                           cout<<j<<" "<<i<<endl;
                           p[j] = 1;
                           break;
                      }
            }
    }
    return 0;
}
char str[101];
int match(int n ,char a, char b)
{
    for(int i=1;i<n;i++)
    {
	    if(str[i]!=b)
		    continue;
		for(int j=i-1;j>=0;j--)
		{
		    if(str[j]==a)
			 {
					
			    cout<<j<<' '<<i<<endl;
			    str[j]='*';
			    break;
		     }  	
		}	
		
	}
	return 0;
}
int main()
{
	int i;
	char a,b;
	cin.getline(str,101);
	i=strlen(str);
	a=str[0];
	b=str[i-1];
	match(i,a,b);
	return 0;
}
int main()
{
  char c[100],sex;
  scanf("%s",c);
  int i,j,k=0,x[100],y[100],a,b,n;  
  n=strlen(c);
  sex=c[0];
  for(i=n;i>=0;i--)
  {
      a=0;b=0;
      if(c[i]!=sex)
      {
             for(j=i;j>=0;j--)
             {
                  if(c[j]==sex)
                  {
                       a++;
                  }
                  else
                  {
					  b++;
				  }
                  if(a==b)
                  {
                          x[k]=j;
                          y[k]=i;
                          k++;
                          break;
                  }
             }      
      } 
  }
  for(i=k-1;i>=0;i--)
  {
       printf("%d %d\n",x[i],y[i]);
  }
  scanf("%d",&n); 
  return 0;
}
void paidui(char str [])
{
	int i=0,k=0;
	for(i=1;i<strlen(str);i++)
	{
		if(str[i]!=str[0])
		{
			for(k=i-1;k>=0;k--)
			{
				if(str[k]==str[0])
				{
					cout<<k<<' '<<i<<endl;
					
				
				str[k]=' ';
				str[i]=' ';
				break;
				}
			
				
			}
		}
	}
}
int main()
{
	char str[100];
	cin.getline(str,101);
	paidui(str);
	return 0;
}
char c[150];
int c1[150] = {0};
int lc;
char m;

void que(int a, int b)
{
	if (c1[a])
	{
		que(a + 1, b);
	}
	else
	{
	    if (b == lc)
		    return;
	    if (c[b] == m)
	    {
		    que(a + 1, b + 1);
	    }
	    else
	    {
		    cout << a << " " << b << endl;
		    c1[a] = 1;
		    c1[b] = 1;
			while (c1[a] == 1)
			{
				a--;
			}
		    que(a, b + 1);
		}
	}
}


int main()
{
	cin >> c;
	m = c[0];
	lc = strlen(c);
	que(0, 1);
	return 0;
}
int main()
{
	int i=0,j=0,len,a,b;
	char str[101],boy;
	gets(str);
	len=strlen(str);
	boy=str[0];		
	for(i=0;i<len;i++)
	{
		if(str[i]!=boy)
		{
			str[i]='0';
			for(j=i;j>0;j--)
			{
				if(str[j]==boy)break;
			}
			str[j]='0';
			a=j;b=i;
			printf("%d %d\n",a,b);
		}
		else continue;
	}
	return 0;
}
void change(char str[],char w,char m)
{
	int ctr=0,ctr1=0;
	for (ctr=0;str[ctr+1]!='\0';ctr++)
	{   if(str[ctr]==w)continue;
		for(ctr1=ctr+1;ctr1<strlen(str);ctr1++)
		{if(str[ctr1]!=' ')break;}
		if(str[ctr1]==w)
		{
			printf("%d %d\n",ctr,ctr1);str[ctr]=str[ctr1]=' ';
			break;}
	}
		
}
main()
{
	char a[1000]={'\0'},w,m;int i=0;
	gets(a);m=a[0];
	for(i=0;i<strlen(a);i++)if(a[i]!=a[0])break;w=a[i];
	for(i=0;i<strlen(a)/2;i++)
	{change(a,w,m);}
	return 0;
}
int main()
{
	int i,j;
	char a[100], n, m;
	cin >> a;
	n=a[0];
	for ( i=1; i<strlen(a); i++ )
		if ( a[i] != n )
			{
				m=a[i];
				break;
			}
	for ( i=1; i<strlen(a); i++ )
		if ( a[i] == m )
			{
				for ( j=i-1; j >= 0; j-- )
					if ( a[j] == n )
						{
							cout << j << ' ' << i << endl;
							a[j]=' ';
							break;
						}
			}

	return 0;
}
int lefts(char *,char *);
char boy,girl;
int main()
{
	char children[105]={'\0'};
	int i,left,right,sum;
	cin>>children;
	sum=strlen(children);
	boy=children[0];
	girl=children[sum-1];
	for(i=0;i<sum;i++)
	{
		if(children[i]==girl)//??????girl???????lefts??????
		{
			right=i;
			left=lefts(children,children+i);
			if(i<sum-1)
				cout<<left<<" "<<right<<endl;
			else
				cout<<left<<" "<<right;//?????????
			children[left]=' ';
		}
	}
	return 0;
}
int lefts(char *head,char *p)
{
	int left;
	if(*p!=boy)//?????????????????
		left=lefts(head,p-1);
	else
		left=p-head;
	return left;
}
void main()
{
	void f(char c[],char,char,int);
	char c[1000],a,b,n;
	scanf("%s",c);
	n=strlen(c);
	a=c[0];
	b=c[n-1];
	f(c,a,b,n);

}


void f(char c[],char a,char b,int n)
{
	int i,nan,nv,k;
	for (i=0;i<n;i++)
	{
		if (c[i]==b)
		{
			nan=0;nv=0;
			for (k=i;k>=0;k--)
			{
				if (c[k]==a) nan++;
				else if (c[k]==b) nv++;
				if (nan==nv) 
				{
					printf("%d %d\n",k,i);
					break;
				}
			}
		}
	}
}
/*
??
??????????????????????????????????????????????????????????????????????????0????
??????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
?????????????????????????????????????????????
???????????????????????????????????????????????

????
???????????????????????????????????????????????????????????????

????
????????????????????????????????????????????????????

????
((()(())())(()))

????
2 3
5 6
4 7
8 9
1 10
12 13
11 14
0 15

??
????????????????????( ? ) ?????? ( ????????? ) ?????????????? ( ??? ) ???????????????? 

?????????????

*/


void output(char a[],char m,char f)
{
	int i=0,k,outa,outb;
	while(a[i]!='\0')
	{
		if (a[i]!=f)  i++;
		else
		{
			outb=i;
			while (a[i]!=m)   i--;
			outa=i;
			cout<<outa<<" "<<outb<<endl;
			a[outa]=' ';
			a[outb]=' ';
			output(a,m,f);
		}
	}
}

int main()
{
	char a[100],m,f;
	int t=1;
	cin>>a;
	m=a[0];
	while(1)
	{
		if (a[t]==m)   t++;
		else
		{
			f=a[t];
		    break;
		}
	}
	output(a,m,f);
	return 0;
}
int function(char* a,int m,char k)//??a[m]?'('
{
	int t=m;
	while(a[t+1]!=0)
	{
		if(a[t+1]!=k)
		{
			cout<<m<<' '<<t+1<<endl;
			return t+1;
		}
		else
		{
			t=function(a,t+1,k);
		}
	}
}

int main()
{
	char a[101],k;
	cin>>a;
	int n=-1;
	k=a[0];
	while(a[n+1]!=0)
	{
		n=function(a,n+1,k);
	}
	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]==y) break;
			else if (a[j]==x)
			{
				printf("%d %d",j,i);
				printf("\n");
				a[i]='.';a[j]='.';
				break;
			}
		}
		}
	}
    result(a);
	}
	
}
int main()
{
    char s[400],c1;
    int top=0,i,j,k,m,n,a[100];
    gets(s);
    c1=s[0];
    for (i=0;i<strlen(s);i++)
    {
        if (s[i]==c1) 
        {
           top++;
           a[top]=i;
        }
        else 
        {
             printf("%d %d\n",a[top],i);
             top--;
        }
    }
    return 0;
}
char s[100];
char a,b;
int num[100];
int n,q=0;
int main ()
{ void p();
  int i;
  gets(s);
  n=strlen(s);
  for(i=0;i<100;i++)
   num[i]=1;
  a=s[0];
  b=s[n-1];
  p();
  return 0;
}

void p ()
{   int i,j,t=0,m;
   for(i=0;i<n-1;i++)
     {for(j=i+1;j<n;j++)
      { 
	    for(m=i+1;m<j;m++)
		   if (num[m]!=0) break;
	   if(s[i]==a && s[j]==b && num[i]==1 && num[j]==1&&m==j)
       { printf("%d %d\n",i,j);
         num[i]=0;
         num[j]=0;
         t=1;
        }
        if (t==1) break;
      }
       if (t==1) break;
      }
      q++;
     if (q!=n/2) p ();
}
//Patricia.Xiao
//????????

char line[110];
char boy,girl;

int match(int i,int l)
{
	//printf("%c %c\n",boy,girl);  //debug
	//printf("%s",line);
	//debug?line????????????????????
	int j;
	if(i==l)
		return 0;   //??
	if(line[i]==girl)   //????
	{
		for(j=i-1;j>=0;j--)
		{
			if(line[j]==boy)
			{
				//printf("%d %d\n",i,j);  //debug
				printf("%d %d\n",j,i);
				line[j]=' ';
				break;   //????????????????else?????bug?
			}
		}
	}
	match(i+1,l);
	return 0;
}
int main()
{
	int l;
	int i;
	scanf("%s",line);
	l=strlen(line);
	boy=line[0];         //????????????
	for(i=1;i<l;i++)
	{
		if(line[i]!=boy)
		{
			girl=line[i];
			break;
		}
	}
	//printf("%d\n",l);  //debug
	match(0,l);  //??
    return 0;
}
void main()
{
	char a[101],boy,girl;
	int i,k,len;
	
	scanf("%s",a);
	boy=a[0];
	len=strlen(a);
	for(i=0;i<len;i++)
	{\
		if(a[i]!=boy)
		{
			girl=a[i];
			break;
		}
	}

	for(i=0;i<len;i++)
	{
		if(a[i]==girl)
		{
			for(k=i-1;k>=0;k--)
			{
				if(a[k]==' ')
					continue;
				else if(a[k]==boy)
				{
					a[i]=' ';
				    a[k]=' ';
				    printf("%d %d\n",k,i);
					break;
				}
			}
		}
	}
	return;
}
void f(char s[100]);
int main()
{
	char str[100];//??????
	cin.getline(str,100);//?????
	f(str);//????
	return 0;
}
void f(char s[100])
{
	int i,j=1;
	int l=strlen(s);//????
	for(i=0;i<l-1;i++)
	{
		j=1;
		if(s[i]!='*')//??????????
		{
			while(s[i+j]=='*'&&i+j<l)
				j++;
			if(s[i]!=s[j+i])
			{
				cout<<i<<' '<<i+j<<endl;
				s[i]='*',s[i+j]='*';
				break;
			}
		}
	}
	f(s);//??????
}