semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
    char p,s[101];
    int b[101]={0};
    int i,j,l;
    gets(s);
    p=s[0];
    l=strlen(s);
    for(i=0;i<l;i++)
    {
       if(s[i]==p) b[i]=1;
       else 
       {   for(j=i-1;j>=0;j--)
             if(b[j]==1) {b[j]=0;break;}
           printf("%d %d\n",j,i);
       }
    }

}
int main()
{
    int stack[100], top = 0, count = 0;
    char boy, c;
    cin >> boy;
    stack[top++] = count++;
    while ((c = cin.get()) != '\n')
    {
        if (c == boy)
        {
            stack[top++] = count++;
        }
        else
        {
            printf("%d %d\n", stack[--top], count++);
        }
    }
  
    return 0;
}
int main()
{
	char ch[200],t[2];
	int i,j,l,g,b;
	gets(ch);
    l=strlen(ch);
    t[0]=ch[0];
    t[1]=ch[l-1];
    for(i=1;i<l;i++)
    {
        g=1;
        b=0;
        if(ch[i]!=0)
        {
        if(ch[i]==t[1])
        {
            for(j=i-1;j>=0;j--)
            {
                if(ch[j]==t[1])
                {
                    g++;
                }
                else if(ch[j]==t[0])
                {
                    b++;
                }
                if(g==b)
                {
                    ch[i]=0;
                    ch[j]=0;
                    printf("%d %d\n",j,i);
                    break;
                }

            }
        }
        }
    }

	return 0;
}
char a[110]={0};
int x[110][2]={0};
int i,j,l,k=0;
int f()
{
	for(i=0;i<l-1;i++)
	{
			for(j=1;i+j<l;j++)
			{
				if(a[i]==a[0]&&a[i+j]==' ') {continue;}
				if(a[i]==a[0]&&a[i+j]==a[0]) {break;}
				if(a[i]==a[0]&&a[i+j]==a[l-1]) 
				{
					x[k][0]=i;x[k][1]=i+j;k++;a[i+j]=' ';a[i]=' ';
				}
			}  
	}
	if(k!=l/2) {f();}
	if(k==l/2) {return 0;}
}
int main()
{
	cin.getline(a,110,'\n');
	l=strlen(a);
	f();
	for(i=0;i<l/2-1;i++)
	{
		for(j=0;j<l/2-1-i;j++)
		{
			if(x[j][1]>x[j+1][1])
			{
				k=x[j][1];x[j][1]=x[j+1][1];x[j+1][1]=k;
				k=x[j][0];x[j][0]=x[j+1][0];x[j+1][0]=k;
			}
		}
	}
	for(i=0;i<l/2;i++)
	{
		cout<< x[i][0] <<" "<< x[i][1] <<endl;
	}
	return 0;
}
int main()
{
	char c[100],boy,girl;
	int i,j,len,end=0;

	scanf("%s",c);
	len = strlen(c);
	boy = c[0];
	for(i=1;i<len;i++)
	{
		if(c[i]!=boy)
		{
			girl = c[i];
		}
	}


	while(1)
	{
		for(i=0;i<len;i++)
		{
			if(c[i]==boy)
			{
				for(j=i+1;j<len;j++)
				{
					if(c[j]==' ')continue;
					if(c[j]==girl)
					{
						printf("%d %d\n",i,j);
						c[i] = ' ';
						c[j] = ' ';
						i=0;
						break;
					}
					if(c[j]==boy)break;
				}
			}
		}
		for(i=0;i<len;i++)
		{
			if(c[i]==' ')
			{
				end++;
					if(end==len)
					{
						return 0;
					}
			}
			if(i==len-1&&end<len)
			{
				end = 0;
			}
		}
	}
	return 0;

}
int couple(int);
char a[100];
int len, b[100] = {0};

int main()
{
	cin >> a;
	len = strlen(a);
	couple(0);
	return 0;
}

int couple(int i)
{
	int j;
	for(int k = i; k < len; k++)
	{
		while(b[i] == 1)
		{
			i++;
		}
		if(a[i] == a[0])
		{
			b[i] = 1;
			j = couple(i+1);
			cout << i << " " << j << endl;
		}
		else
		{
			b[i] = 1;
			return i;
		}
	}	
}
//***********************************************************************
//??????? 
//??????? 
//??????
//***********************************************************************
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 ++)          // for???????? 
    {
            str[i] = cin.get();
                                           //??????????????????????????????? 
            if(str[i] != str[0] && str[i] != '\n')
            { 
                      g = str[i];
                      p[i] = 1;
            } 
            if(str[i] == '\n')
                      break; 
            c++;                         //????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;                              //????? 
}
int main()
{
    int n=0,a[1000]={0},b[1000],d[1000],count=0,i,j,zongshu;
    char c,nanhai;
    c=getchar();
    nanhai=c;
    while (c!='\n')
    {
          if (c==nanhai) a[n]=1;     //??? 
          else
          {
              a[n]=2;                 //??? 
              d[count]=n;             //??????? 
              count++;                //????? 
          }
          n++;
          c=getchar();
    } 
    zongshu=n;     //??? 
    while (n!=0)
    {
          for (i=0;i<zongshu-1;i++)
          {
              if (a[i]==1)        //?? 
              {
                          j=i+1;
                          while (a[j]==0) j++;     //???????????? 
                          if (a[j]==2)            //?????? 
                          {
                                      a[i]=0;
                                      a[j]=0;      //???? 
                                      b[j]=i;      //??????????? 
                                      n=n-2;       //?????2 
                          }
              }
          }
    }
    for (i=0;i<count;i++) 
    {
        cout<<b[d[i]]<<' '<<d[i];    //????? 
        if (i!=count-1) cout<<endl;
    }
    return 0;
}
//****************************
//???????
//?????
//???2011-11-22
//****************************
char a[10000];            //??????
int function(int);          //????
int main()
{
	int i, j;
	cin.getline(a, 10000);           //?????
	for(i = 0;a[i] != '\0';i++)
	{
		if(a[i] != a[0])                  //???????
		{
			j = function(i - 1);          //??????????????
			cout << j << " " << i << endl;           //?????????????
			a[j] = a[i];           //???????????
		} 
	}
	return 0;
}
int function(int j)
{
	if(a[j] == a[0])
	{
		return j;
	}
	else
	{
		return function(j - 1);
	}
}
char queue[100];
char boy,girl;
int stop=0;
int length;
int main()
{
   
   cin>>queue;
   boy=queue[0];
   length=strlen(queue);
   int number;
   for(int i=0;i<length;i++)
   {
     if(queue[i]!=boy)
		 {
			 girl=queue[i];
			 number=i;
			 break;
	    }   
   }
   void handinhand(int);
   handinhand(number);
}


void handinhand(int number)
{
     if(stop==length)
		 return;

	 int theotherside=0;
	 for(int a=1;;a++)
	 {
	     if(queue[number-a]==boy)
			 {
				 theotherside=number-a;
				 break;
		 }
	 
	 }
	 cout<<theotherside<<' '<<number<<endl;
	 queue[number]=' ';
	 queue[theotherside]=' ';
	 stop=stop+2;
	
	 for(int i=number+1;;i++)
	 {
	         if(queue[i]==girl)
			 {
			      handinhand(i);
			      break;
			 }
	 
	 }


}
int main()
{
   int i,j,k=1,a[110]={0},p=1,x=0;
   char c,h;
   h=getchar();
   a[0]=a[0]+2;
   while(c=getchar())
   {
      if(c==h)
      {
        a[p]=a[p]+2;
        p=p+1;
        }
      if(c!=h&&c!='\n')
      {
         a[p]=a[p]+1;
         p=p+1;
         }
      if(c=='\n')
      break;
      }
   for(j=0;j<p;j++)
   {
   for(i=0;i<p-1;i++)
   {   
      if(a[i]==2)
       for(k=1;k<p-i;k++)
       {
          if(a[i+k]==1)
          {
             cout<<i<<" "<<i+k<<endl;
             a[i]=0;
             a[i+k]=0;
             i=0;
             break;
             }
          if(a[i+k]==2)
          break;
          }
          }
       x=0;
      for(i=0;i<p;i++)
      {
         if(a[i]==0)
         x=x+1;
         }
      if(x==p)
      break;
      }
      return 0;
      }
void main()
{
    char a[101],c;
    gets(a);
    c=a[0];
    int i,n,j,k;
    n=strlen(a);
    for(j=1;j<n/2+1;j++)
    {
        for(i=0;i<n;i++)
        {
            if(a[i]!=c&&a[i]!=0)
            {
                for(k=i-1;k>=0;k--)
                {
                    if(a[k]!=0)
                    {
                        printf("%d %d\n",k,i);
                        a[i]=0;a[k]=0;
                        break;
                    }
                }
                break;
            }
        }
    }
}
/*
 * paiduiyouxi.cpp
 *
 *  Created on: 2011-1-8
 *      Author: lz
 */

int main()
{
	char c[1000];
	int s[1000];
	int top=-1;
	cin>>c;
	char a;
	char b;
	a=c[0];
	int len=strlen(c);
	int i;
	for(i=0;i<len;i++)
		if(c[i]!=a)
		{
			b=c[i];
			break;
		}
	for(i=0;i<len;i++)
	{
		if(c[i]==a)
			s[++top]=i;
		else
			cout<<s[top--]<<" "<<i<<endl;
	}
	return 0;
}
void  change(char a[1001],int i,int j,int k,char boy,char girl)
{
	
	int l,m,n;
	if(j-i==k-1)
	{
		cout<<"0 "<<k-1;
	    return;
	}
	else
	{
		cout<<i<<" "<<j<<endl;
		a[i]='A';
		a[j]='A';
		for(l=0;l<k;l++)
		{
			if(a[l]==boy)
				{
					for(m=l+1;m<k;m++)
					{	
						if(a[m]=='A')
							continue;
					     if(a[m]==boy)
							{
								l=m-1;
								break;
							}

						 if(a[m]==girl)
							return change(a,l,m,k,boy,girl);
					}
				}
		}
	}
}
int main()
{
	char xpy[1001]={0};
	int i,j;
	cin.getline(xpy,1001);
	char boy=xpy[0],girl=xpy[strlen(xpy)-1];
	for(i=0;i<strlen(xpy);i++)
		if(xpy[i]==boy&& xpy[i+1]==girl)
			change(xpy,i,i+1,strlen(xpy),boy,girl);
	
	return 0;
}
int main() 
{
	int a[101],n=0;     //a[101]?????????
	char s[101];
	cin >> s;
	for (int i = 0; s[i]; ++i)   //??????
	{
		if (s[i] == s[0])        //?????????
			a[++n] = i;
		else                     //?????????????????????????????
			cout << a[n--] << " " << i << endl;
	}
	return 0;
}
char a[100], p, q;

void solve()
{
	int i=0, b, g;
	while(a[i] != '\0')
	{
		if(a[i] == p)
			b = i;
		else if (a[i] == q)
		{
			g = i; 
			a[b] = '0';
			a[g] = '0';
			cout << b << ' ' << g << endl;
			solve();
			break;
		}
		i++;
	}
	return;
}
		
	
int main()
{
	
	cin.get(a,100);
	p = a[0];
	int i=0;
	while(1)
	{
		if(a[i] != p)
		{
			q = a[i];
			break;
		}
		i++;
	}
	solve();

	return 0;
}
int main()
{
	char a[100], girl, boy;
	cin.getline( a, 100 );
	boy = a[0];
	int i, j;
	for ( i = 0; a[i] != '\0'; i++ )
	{
		if ( a[i] != boy )
		{
			girl = a[i];
			break;
		}
	}
	for ( i = 0; a[i] != '\0'; i++ )
	{
		if ( a[i] == girl )
		{
			for ( j = i - 1; j >= 0; j-- )
			{
				if ( a[j] == boy )
				{
					cout << j << " " << i << endl;
					a[j] = ' ';
					a[i] = ' ';
					break;
				}

			}
		}
	}
	return 0;
}
int sum ;
void change(int t, char s[],char a, char b)
{
	if (sum == 0)
		return;
	int i, j;
	for (i = 0;i < t;i++)
	{
		if (s[i] == a)
		{
			for (j = i + 1;s[j] == '0' && j < t;j++);
			if (s[j] == b)
			{
				cout << i << " " << j << endl;
				sum = sum - 2;
			    s[i] = s[j] = '0';
				change(t, s,a, b);
				
			  
			}
		}
	}
}


int main()
{
	char s[105], a, b;
	cin.getline(s, 105);
	int l = strlen(s);
	sum = l;
	a = s[0];
	for (int i = 1;i < l;i++)
	{
		if (s[i] != s[0])
			b = s[i];
	}
	change(l, s, a, b);
	
	return 0;
}
int c[100]={0};//?????????????
char boy,girl;
char a[100];
void f()
{
	int k=1,i;
	for(i=0;i<strlen(a);i++)
	{	if(a[i]==boy&&c[i]==0)//?????????
		{ while(c[i+k]==1) {k++;} //?????
		  if(a[i+k]==girl) {cout<<i<<' '<<i+k<<endl;c[i]=1;c[i+k]=1;break;}//???????????????????break
		  else {k=1;continue;}//??????k?????1?????
		  
		}
	}
	if(i+k<strlen(a)-1) f();//???????????????????f
}

int main()
{	
	cin.getline(a,100);//??
	boy=a[0];//??????
	girl=a[strlen(a)-1];//???????
	f();
	return 0;
}
/*************************************************************************************************************
* @file .cpp
* @author ????
* @date 
* @description
*		????        
*/


char b[100];
int a[100], i, j;
void peidui( int l)
{
	int flag = 0;
	if(l == 0)
		return;
	for(i = 0; i < l - 1; i++)
	{
		if((b[i] == b[0]) && (b[i + 1] != b[0]))//????????????????
		{
			cout << a[i] << " " << a[i + 1] << endl;
			for(j = i; j < l - 2; j++)
			{
				a[j] = a[j + 2];
				b[j] = b[j + 2];
			}
			break;
		}
	}
	peidui(l - 2);
}
int main()
{
	int l;
	cin >> b;
	l = strlen(b);
	for (i = 0; i < l; i++)
		a[i] = i;
	peidui(l);
	return 0;
}
//????
int main()
{
	char a[102];
	cin.getline(a,102);
	char boy=a[0];
	char girl;
	int length=strlen(a);
   for(int i=1;i<length;i++)
   {
     if(a[i]==boy) continue;
	 else {girl=a[i];break;}
   }
   int t=0;
   int placeofboy[55];
   for(int i=0;i<length;i++)
   {
     if(a[i]==boy) placeofboy[++t]=i;
	 else 
	 {
	    cout<<placeofboy[t]<<' '<<i<<endl;
		t--;
	 }
   }
   
   return 0;
}
void qianshou(int a[], int len)
{
	int i,j, flag = 0;
	for(i = 1; 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;
				}
			}
		}
	}

}
int main()
{
	char str[100];
	int a[100];
	int i = 0;
	cin.getline(str,100);
	int len;
	len = strlen(str);
	for(i = 0; i < len; i++)
	{
		if(str[0] - '0' == str[i] - '0')
			a[i] = 1;
		else
			a[i] = 2;
	}
	qianshou(a, len);
	return 0;
}
int main()
{
	char str[101],p,q;
	int b[50],g[50],i,l,j=0,e,k,r;
	scanf("%s",str);
	l=strlen(str);
	p=str[0];
	for(i=1;i<l;i++)
	{
		if(str[i]!=p)
		{
			q=str[i];
			break;
		}
	}
	for(r=1;;r++)
	{
		if(j==l/2) break;
		else
		{
			for(i=0;i<l;i++)
			{
				if(str[i]==p&&str[i+r]==q)
				{
					str[i]='0';
					str[i+r]='0';
					b[j]=i;
					g[j]=i+r;
					j++;
				}
			}
		}
	}
	for(i=0;i<j;i++)
	{
		for(k=j-1;k>=i;k--)
		{
			if(g[k]<g[k-1])
			{
				e=g[k];
				g[k]=g[k-1];
				g[k-1]=e;
				e=b[k];
				b[k]=b[k-1];
				b[k-1]=e;
			}
		}
	}
	for(i=0;i<j;i++)
	{
		printf("%d %d\n",b[i],g[i]);
	}
	return 0;
}
void cool(int n ,char A[100],char a)
{
	int i,j;
	for (i=0;i<n-1;i++)
	{
		if(A[i]!=-1)
		{
		for (j=i+1;j<n;j++)
		{
	        if(A[j]==-1)
				goto loap1;
			if (A[i]==A[j])
				break;
			if (A[i]!=A[j] && A[i]==a)
			{
				printf("%d %d\n",i,j);
				A[i]=-1;
				A[j]=-1;
				goto loap2;
loap1:;
			}
		}
		}
	}
loap2:;
	for (i=0;i<n;i++)
	{
		if (A[i]!=-1)
		{
			cool(n,A,a);
			break;
		}
	}
	return;
}
int main()
{
	char A[100],a;
	int n;
	gets(A);
	n=strlen(A);
	a=A[0];
	cool(n,A,a);
	return 0;
}
int main () {
	char c[1111] ;
	char b , g ;
	int B[1111] , G[1111] ;
	int i , j , k , L , order = 1 ;
	cin >> c ;
	b = c[0] ;
	for ( i = 1 ; ; i ++ ) {
		if ( c[i] != b ) {
			g = c[i] ;
			break ;
		}
	}
	L = strlen(c) ;
	for ( i = 0 ; i < L ; i ++ ) {
		if ( c[i] == b ) {
			for ( j = i+1 ; ; j ++ ) {
				if ( c[j] == ' ' )
					continue ;
				else if ( c[j] == b )
					break ;
				else if ( c[j] == g ) {
					B[order] = i ;
					G[order] = j ;
					c[i] = ' ' ;
					c[j] = ' ' ;
					order ++ ;
					i = -1 ;
					break ;
				}
			}
		}
	}
	for ( i = 1 ; i < order ; i ++ )
		cout << B[i] << " " << G[i] << endl ;
	return 0 ;
}
int main()
{
	
	char s[1000];
	scanf("%s",s);
	char boy=s[0];
	int m[1000]={0};
	int i,j=0;
	for(i=0;s[i];i++)
	{
		if(s[i]==boy)
		m[j++]=i;
		else if(s[i]!=boy)
			printf("%d %d\n",m[--j],i);
	}
	return 0;
}
char a[109];
char boy;
char girl;
int l;
void Match()
{
	if( a[0] != boy )
		return;
	int i = 0;
	while( a[i] != girl )
		i++;
	int j = i-1;
	while( a[j] == '0' )
		j--;
	cout<< j << ' ' << i << endl;
	a[i] = a[j] = '0';
	Match();
}
int main()
{
	cin.getline( a , 109 );
	l = strlen( a );
	boy = a[0];
	girl = a[l-1];
	Match();
	return 0;
}
//****************************************
//*???????                       **
//*????? 1100012873                **
//*???2011.11.16                     **
//****************************************
char t[100];//??????
int pd (int, int);
int main ()
{
	int l;
    cin >> t;
    l = strlen (t);
    pd (0, l);
    return 0;
}
int pd (int x, int length)
{
	int i;
    for (i = 1;x + i < length;)  
	{
		if (t[x] == t[x + i] && t[x] != 'o')//??????????
			return pd (x + i, length);
        else if (t[x+i] != t[x] && t[x+i] != 'o')//???????????????
        {
			t[x] = 'o';
		    t[x+i] = 'o';
		    cout << x << " " << x+i << endl;
            return pd (x - 1, length);
        }
	    else if (t[x+i] != t[x] && t[x+i] == 'o')//????????????
	        i++;
	    else if (t[x] == 'o' && t[x+i] == 'o')//???????
			return pd (x - 1, length);
	} 
}
int hands(int n);
int c[200]={0},b[100];
int main()
{
        char a[100];
        int i=0,num=0,j=1;
        cin>>a;//?????
        c[0]=0;
        for(i=1;i<strlen(a);i++)//????c???????????1???????0
        {
        if(a[i]==a[0]){c[j]=0;j++;num++;}
        else {c[j]=1;j++;num++;}
        }
        for(i=0;i<strlen(a);i++)b[i]=i;//??b???????????????
        hands(num + 1);//????
        return 0;

}
int hands(int n)
{
        int i,j,temp=0;
        for(i=0;i<n;i++)
        {
                if(c[i]==0&&c[i+1]==1)//???????????????
                {cout<<b[i]<<" "<<b[i+1]<<endl;break;}//????????????
        }
        for(j=i+2;j<n;j++)
                {c[j-2]=c[j];b[j-2]=b[j];}//???c???b?????????????
        if(n>2)return hands(n-2);//?n>2????
        else
        {
            
        return 0;
        }
}//hands??
struct chil
{
	int sex;
	int num;
}child[100];
struct student
{
	int b;
	int g;
}girl[100];
void bubble(struct student a[],int len)
{
	int i, j;
	struct student temp;
	for(j=1; j<len; j++)
	{
		for(i=0; i<len-j; i++)
		{
			if(a[i].g>a[i+1].g)
			{
				temp=a[i];
				a[i]=a[i+1];
				a[i+1]=temp;
			}
		}
	}
}
void main()
{
	int i, j, k, n;
	char s[101];
	gets(s);
	n=strlen(s);
	child[0].sex=1; child[0].num=0;
	for(i=1; i<n; i++)
	{
		if(s[i]==s[0])
		{
			child[i].sex=1; child[i].num=i;
		}
		else
		{
			child[i].sex=0; child[i].num=i;
		}
	}//??????
	for(i=0, j=0; i<n; i++)
	{
		if(child[i].sex==1 && child[i+1].sex==0)
		{
			girl[j].b=child[i].num;
			girl[j].g=child[i+1].num;
			j++;
			for(k=i; (k+2)<n; k++)
				child[k]=child[k+2];
			n=n-2;
			i=-1;
		}
	}
	bubble(girl,j);
	for(i=0; i<j; i++)
		printf("%d %d\n",girl[i].b,girl[i].g);
}
int main()
{
	char bra[100];
	void together(char bra[100]);

	cin.getline(bra,101,'\n');
	together(bra);

	return 0;
}

void together(char bra[100])
{
	int len;
	char ch;							//ch stores the character of boy
	ch=bra[0];
	int k=0,i,j,s;						//s flags the match case of boy and girl
	int bg[50][2];
	len=strlen(bra);
	for (i=1;i<len;i++)					//bra[0] can't be ')'
		if ( bra[i]!=ch )				//for a certain girl,find the boy next to her(loop to left)
		{
			s=1;
			for (j=i-1;j>=0;j--)
			{
				if (bra[j]!=ch)
					s++;
				else 
					s--;
				if (s==0)				//if find , s should be 0;
				{
					bg[k][0]=j;			//bg[k][0] is the boy,while bg[k][1] is the girl
					bg[k][1]=i;
					k++;
					break;
				}
			}
		}
	for (i=0;i<k;i++)					//print the result
		cout << bg[i][0] << " " <<bg[i][1] << endl;
}
int f(int i,int j,char a[101])
{
	int p=0;    
	if ((i-j)==1)
		return 1;
	else 
	{  for (int k=j+1;k<i;k++)
	{
		if (a[k]!='0')
			p++;
	}                   
	if (p==0)
		return 1;
	if (p!=0)
		return 0;
	}
}        
int main()
{
	char a[101];
	cin>>a;
	char c,d;
	int m=0;
	c=a[0];
	for (int i=0;i<101;i++)
	{
		if (a[i]=='\0')
			break;
		m++;
	}
	for (int i=0;i<m;i++)  
		if (a[i]!=a[0])
			d=a[i];

	for (int j=0;j<m;j++)
		for (int i=0;i<j;i++) 
		{
			if (a[j]==d&&a[i]==c&&f(j,i,a)==1)
			{
				a[i]='0';
				a[j]='0';
				cout<<i<<" "<<j<<endl;

			}
		}                      
		return 0;
}
char line[100],male;
int len;
void hand();
int main()
{
	cin>>line;
	len=strlen(line);
	male=line[0];
	hand();
	return 0;
}
void hand()
{
	int i,j;
	for(i=0;i<len;i++)
	{
		if(line[i]!=male && line[i]!='\0')
		{
			for(j=i-1;j>=0;j--)
			{
				if(line[j]==male)
				{
					cout<<j<<' '<<i<<endl;
					line[i]='\0';
					line[j]='\0';
					break;
				}
			}
		}
	}
}
struct dui
{int nannv;
int weizhi;
}a[100];
void shuchu(struct dui a[100],int n)
{
	int i=1,j,h=1;
	do
	{
		if(a[i].nannv ==0)
		{
			printf("%d %d\n",a[i-1].weizhi-1 ,a[i].weizhi-1 );
			if(i<n)
			{
				for(j=i;j<=n;j++)
				{
					a[j-1]=a[j+1];
					a[j]=a[j+2];
					j++;
				}
				n=n-2;
			}
			else
				n=0;
			i=1;
		}
		else
			i++;
	}while(n!=0);
}
int main()
{
	int i,n,j=0,k=0;
	char s[100],nan;
	scanf("%s",s);
	n=strlen(s);
	nan=s[0];
	for(i=1;i<=n;i++)
	{
		if(s[i-1]==nan)
		{
			a[i].nannv =1;
			a[i].weizhi =i;
		}
		else
		{
			a[i].nannv =0;
			a[i].weizhi =i;
		}
	}
	shuchu(a,n);
}
int main()
{
	char s[101];
	int i,a[100],c,j;
	scanf("%s",s);
	i=c=0;
	while(s[i]!='\0')
	{
		if(s[i]!=s[0])a[c++]=i;
		i++;
	}
	for(i=0;i<c;i++)
	{
		for(j=a[i];j>=0;j--)
		{
			if(s[j]==s[0])
			{
				s[j]=' ';
				printf("%d %d\n",j,a[i]);
				break;
			}
		}
	}
		return 0;
}
int main()
{
    int c,std,a=0,i=0,flag=1;
    int boy[100]={0};
    while((c=getchar())!='\n')
    {    if(flag==1)
	{
		std=c;
		flag=0;
	}
	if(c==std)
	{
		boy[i]=a;
		i++;
	}
	else
	{
		printf("%d %d\n",boy[--i],a);
	}
	a++;
    }
	return 0;
}
char	chi[200];
char	boy, gir;
int	pep;

void	zhaoren(int);

int main()
{
	cin.getline(chi, 200);
	pep = strlen(chi);
	boy = chi[0];
	gir = chi[pep - 1];

	zhaoren(pep);

return 0;
}
void	zhaoren(int n)
{
	if(n == 0)
	{return ;}
	
	for (int i = 0; i < pep; i ++)
	{
		if(chi[i] == gir)
		{
			for (int j = i; j >= 0; j --)
			{
				if(chi[j] == boy)
				{
					cout << j << " " << i << endl;
					chi[j] = '#';
					chi[i] = '#';
					zhaoren(n - 2);
					return;
				}
			}

		}
	}
return;
}
char boy; char girl;
int mark[10000];int currentmark;

void f(int p) //P????????
{
	char temp;
	if (p==0) //??????? ????????
	{	cin>>boy;mark[0]=-1;f(1);} //?????? ???????
	else
	{
		cin>>temp;
		if(temp!=boy) girl=temp; //????????????????????
	

		if (temp==boy)  //??????
		{
			mark[p]=p; //???P???????
			currentmark=mark[p]; //???????????????
			f(p+1); //???????
		}
		else if(temp==girl)  //??????
		{
			cout<<currentmark<<" "<<p<<endl; //??????????????????
			int i=p; 
			while(1)
			{
				if (mark[i]==0) i--;  //???????????0
				else break;
			}
			mark[i]=0;
			while(1)
			{
				if (mark[i]==0) i--; 
				else break;
			}
			currentmark=mark[i];//????????????
			if (currentmark==-1) currentmark=0;
			if(i>=0) f(p+1);
			
		}
	}
}

int main()
{
	f(0);
	return 0;
}
int main()
{
	void row(char x[],int num[],int l,char a,char b);
	char a,b;
	int l,m,n,t,i,q;
	int num[101]={0};
	char x[101];
	gets(x);
	l=strlen(x);
	a=x[0];
	b=x[l-1];
	row(x,num,l,a,b);
	for(m=0;m<l-1;m=m+2)
	{
		for(n=0;n<l-4-m;n=n+2)
		{
			if(num[n+1]>num[n+3])
			{
				t=num[n+1];
				num[n+1]=num[n+3];
				num[n+3]=t;
				q=num[n];
				num[n]=num[n+2];
				num[n+2]=q;
			}
		}
	}
	for(i=0;i<l-1;i=i+2)
	{
		printf("%d %d\n",num[i],num[i+1]);
	}
}

void row(char x[],int num[],int l,char a,char b)
{
	int i,j,t=0,count=0,flag=0;
	for(;count<l/2;)
	{
	for(i=0;i<l;i++)
	{
		if(x[i]!=a)
			continue;
		for(j=i+1,flag=0;j<l;j++)
		{
			if(x[j]==a)
				flag++;
			if(x[j]==b&&flag==0)
			{
				num[t]=i;
				num[t+1]=j;
				x[i]=32;
				x[j]=32;
				count++;
				t=t+2;
				break;
			}
		}
	}
	}
}
/**
*@file		1000012767_2.cpp
*@author	??
*@date		2010.12.28
*@description
*			???????????
*/
int main()
{
	char a[1000];									//a ??????
	int m = 0, n = 0, i = 0, j, judge = 0, len;		
					//m, n ??????i, j ?????judge ????len ????
	char x, y;
					//x, y ?????
	cin >> x;		//??????
	a[0] = x;		//????????
	m++;			//????
	i++;			//????????
					//?????????
	while (m!=n)					//?????????????
	{
		cin >> a[i];
		if (a[i] != x && !judge)	//??????????
		{
			y = a[i];
			judge++;
			n++;
		}
		else if (a[i] == x)			//???????????? 1
			m++;
		else
			n++;
		i++;
	}
	len = i++;			//????
										//????????
	for (i = 1; i <= len / 2; i++)
	{									//???
		for (j = 0; j <= len - 1; j++)
		{								//???
			if (a[j] == x)				//?????????
			{
				n = j;
				n++;
										//???????????
				while(a[n] != x && a[n] != y)
					n++;
										//???????????
										//????????
				if (a[n] == y)
				{
					cout<< j << " " << n << endl;
					a[n] = ' ';
					a[j] = ' ';
					break;
				}
										//??????????
			}		
		}	
	}
	return 0;
}
int b[100];
int fe(int n)
{
	int i,t=0;
	for(i=0;;i++)
	{
		if(b[i]==0)t++;
		if(t==n)break;
	}
	return i;
}
int m(int n)
{
	int i;
	for(i=fe(n)-1;i>=0;i--)
	{
		if(b[i]==1)break;
	}
    return i;
}
void hands(int n)
{
	if(n>1)
	{
		hands(n-1);
		cout<<m(n)<<" "<<fe(n)<<endl;
		b[m(n)]=-1;
	}
	else
	{	
		cout<<m(1)<<" "<<fe(1)<<endl;
        b[m(1)]=-1;
	}
}


int main()
{
	char a[100];
	int i,j;
	cin>>a;
    for(i=0;a[i]!='\0';i++)
	{
		if(a[i]==a[0])b[i]=1;
		else b[i]=0;
	}
	hands(i/2);
	return 0;
}