semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void bubble(int x[][2],int n)          //&Ecirc;&yacute;×é&Atilde;°&Aring;&Yacute; &pound;&not;n&Icirc;&ordf;&Ecirc;&yacute;×é&sup3;¤&para;&Egrave;
{
    int i,j,y;
    for(i=1;i<n;i++)
    {
        for(j=0;j<n-i;j++)
        {
            if(x[j][1]>x[j+1][1])
            {
                y=x[j][0];
                x[j][0]=x[j+1][0];
                x[j+1][0]=y;
				y=x[j][1];
                x[j][1]=x[j+1][1];
                x[j+1][1]=y;
				
            }                  
        }                
    }     
} 

int main()
{
    int i,j,k,t,x[100][2],n=0;
	char s[150],a,b;

	scanf("%s",s);

	a=s[0];
	for(i=1;s[i];i++)
	{
	   if(s[i]!=a)
	   {
	       b=s[i];
		   break;
	   }
	}
	if(s[0]==a)
	{
	    for(j=0;s[j];j++)
		{
		   
     	    for(k=0;s[k];k++)
			{
			//	sign=0;
			   if(s[k]==a)
			   {
			       for(t=k+1;s[t];t++)
				   {
				       if(s[t]==b)
					   {
					       s[k]='a';
						   s[t]='a';
					       x[n][0]=k;
						   x[n][1]=t;
						   n++;
						   break;
					   }
					   else if(s[t]==a)
						   break;
				   }
			   }
			   

			}
			
		}
	}
/*	else
	{
	    for(j=0;s[j];j++)
		{
		   
     	    for(k=0;s[k];k++)
			{
			//	sign=0;
			   if(s[k]==')')
			   {
			       for(t=k+1;s[t];t++)
				   {
				       if(s[t]=='(')
					   {
					       s[k]='a';
						   s[t]='a';
						   printf("%d %d\n",k,t);
						   break;
					   }
					   else if(s[t]==')')
						   break;
				   }
			   }
			   

			}
			
		}
	}*/
 
	bubble(x,n);
	for(i=0;i<n;i++)
	{
	    printf("%d %d\n",x[i][0],x[i][1]);
	}

	return 0;
}
int main()
{
	char ch[101];
	cin.getline(ch,101);
	char b = ch[0];
	char g = ch[0];
	for (int i=0;g==b;i++)
		g = ch[i];
	int length = strlen(ch);
	int gnum = 0;
	for (int i=0;i<(length/2);i++)
	{
		for (gnum++;ch[gnum]==b;gnum++) ;
		int k=1;
		int j;
		for (j=gnum-1;k>0;j--)
		{
			if (ch[j]==b) k--;
			else k++;
		}
		cout<<j+1<<" "<<gnum<<endl;
	}
	return 0;
}
int main ()
{
    char a[101],flag[2];
    int t, i, j, k;
    cin.getline(a, 101);
    flag[0] = a[0];
    j = strlen(a);
    for (i = 0; i < j; i++)
    {
        if (a[i] != flag[0] && a[i]!= '0')
        {
            for (k = i - 1; k >= 0; k--)
            {
                if (a[k] == flag[0])
                {
                    cout << k << " "<< i << endl;
                    a[i] = '0';
                    a[k] = '0';
                    break;
                }
            }
        }
    }
    return 0;
}
int main()
{
	int n,a[100]={0},flag,i,j;
	char c[100],b[2];
	cin>>c;
	n=strlen(c);
	b[0]=c[0];
	b[1]=c[n-1];
	for(int k=1;k<=n/2;k++)
	{
		flag=0;
		for(i=0;i<n;i++)
		{
			if(a[i]==0&&c[i]==b[0])
			{
				for(j=i+1;;j++)
				{
					if(c[j]==b[0]&&a[j]==0)
						break;
					if(a[j]==0&&c[j]==b[1])
					{
						a[j]=1;
						a[i]=1;
						flag=1;
						cout<<endl<<i<<" "<<j;
						break;
					}
				}
				if(flag)
					break;
			}
		}
	}
	return 0;
}
int main(int argc, char* argv[])
{
	char s[N], e[N], b, g;
 int i,k;
 gets(s);
 b = s[0];
 for(i=1;s[i];i++)
 {
	 if(s[i]!=b)
	 {
		 g = s[i];
		 break;
	 }
 }
 for(i=0;s[i];i++)e[i]='\x1';

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++;
  }
}
return 0;
}
int main()
{
    int n,i,j,k[101];
    char a[101],b,g;
    scanf("%s",a);
    n=strlen(a);
    for(i=0;i<n;i++) k[i]=i;
    b=a[0];
    for(i=0;;i++)
    {
        if(a[i]!=b) {g=a[i];break;}
    }
    while(n>0)
    {
        for(i=0;i<n;i++)
        {
            if(a[i]==g)
            {
                printf("%d %d\n",k[i-1],k[i]);
                for(j=i-1;j<n;j++)
                {
                    k[j]=k[j+2];
                    a[j]=a[j+2];
                }
                n=n-2;
                i=i-2;
            }
        }
    }
    return 0;
}
char s[1000];
int a[1000],l;
char x,y;

void f(int i,int k)
{
    if (k==l-1) return;
    if (s[k+1]==x)
    {
        a[i+1]=k+1;
        f(i+1,k+1);
    }
    else
    {
        cout << a[i] << " " << k+1 << endl;
        i--;
        f(i,k+1);
    }
}

int main()
{
    cin.getline(s,1000);
    l=strlen(s);
    x=s[0];
    f(0,0);
    return 0;
}
char m, f, flag;

void paidui(char *p, int n)
{    
	int i;
	
	for (i = 1; p[n + i] != '\0'; i++)
	{
		if (p[n + i] == m)
			paidui(p, n + i);
		else
			if(p[n + i] == f)
			{
				p[n] = flag;
				p[n + i] = flag;
				cout << n << " " << (n + i) << endl;
				return;
			}
	}
}      


int main()
{  
	
	 char str[100];
	 cin >> str;

	 m = str[0];
	 
	 int i = 0;
	 while(str[i] == m)
		 i++;
	 f = str[i];
     for (i = 'A' ; i <= 'z'; i++)
		 if (i != m && i != f)
		 {
			 flag = i;
			 break;
		 }
	 paidui(str, 0);
	 return 0;
}
void main()
{
	char a[100];
	int x,i,j,p;
	scanf("%s",a);
	x=strlen(a);
	p=0;
	while(p<x/2)
	{
		i=0;
		while(a[i]!=a[x-1]) {i++;j=i;} 
		j--;
		while(a[j]!=a[0]) {j--;}
		printf("%d %d\n",j,i);
		a[i]=a[j]=0;
	    p++;
	}
}
char dui[1000];
void rankgame(int left, int right, char male, char female)
{
	if(left == -1)return;
	if(dui[right] == male)
	{
		left = right;
		right++;
		rankgame(left, right, male, female);
	}
	if(dui[left] == 0)
	{
		left --;
		rankgame(left, right, male, female);
	}
	if(dui[left] == male && dui[right] == female)
	{
		cout << left << ' ' << right << endl;
		dui[left] = 0;dui[right] = 0;
		left --;
		right ++;
		rankgame(left, right, male, female);
	}
}
int main()
{
	cin.getline(dui, 1000, '\n');
	char male = dui[0], female = dui[strlen(dui) - 1];
	rankgame(0, 1, male, female);
	return 0;
}
char ch[1000];
char a , b ;
int len;
void pick( int m , int n )
{
     if( n - m == 1 )//???????????????? 
         cout << m << " " << n << endl;
     else
     {
		 int len1 = 0 , len2 = 0;
		 int i = 0;
		 int k;
		 for( i = m ; i <= n ; i ++ )
		 {
			  k = i;
			  if( ch[i] == a ) len1 ++;
			  else len2 ++;
			  if( len1 == len2 )
			  {
				  if( k < n )//??len1?len2???k < n??k???k?????? 
				  {
					  pick( m , m + 2 * len1 - 1);//?????????? 
					  pick( m + 2 * len1 , n );
				  }
				  else if( k = n )//??len1?len2???k = n???????????? 
				  {
					   pick( m + 1 , n - 1 );//?????????????????????? 
					   cout << m << " " << n << endl;
				  }
				  break;
			  }
		 }
     }
}
int main()
{
    cin >> ch;
    len = strlen(ch);
    a = ch[0] ;
    b = ch[len - 1];
    pick( 0 , len - 1 );
    return 0;
}
int main()
{
    char a[100];
    void peidui(char a[],int n);
    int i=1;
    a[0]=cin.get();
    while((a[i]=cin.get())!='\n')i++;//?????
    peidui(a,0);                     //????????
    return 0;                        //????????
}                                    //????????????
void peidui(char a[],int n)
{

    while(a[n]==a[0]||a[n]==0)n++;
    int i;i=n;                        //????????????
    do{i--;}while(a[i]==0);           //???????????
    cout<<i<<' '<<n<<endl;
    a[n]=0;a[i]=0;
    if(i!=0)peidui(a,n+1);
}
int main()
{
	int n,p,num[255];
	char ch,boy;
	num[0]=0;
	scanf("%c",&boy);
	for(n=p=1;p>0;n++){
		scanf("%c",&ch);
		if(ch==boy){
			num[p]=n;
			p++;
		}
		else{
			printf("%d %d\n",num[p-1],n);
			p--;
		}
	}
	return 0;
}
//?????????????????????????????????????????????????????????0??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

int n=0;
char ch;

void fun(int left)                //??????left???
{
	ch=getchar();n++;
	while ((ch=='(')||(ch=='{')||(ch=='[')||(ch=='<'))
	{
		fun(n);
		ch=getchar();
		n++;
	}
	cout<<left<<' '<<n<<endl;
}

int main()
{
	ch=getchar();
	fun(n);
	return 0;
}
int main()
{
	char a[101] = {'\0'};
	cin.getline(a, 101, '\n');
	int len = strlen (a);
	char boy = a[0], girl = a[len -1];
	int i = 0, j = 0, k = 0;
	for (i = 1; i < len; i ++)
	{
		if(a[i] == girl)
		{
			for (j = i - 1; j >= 0; j --)
			{
				if(a[j] == boy)
				{
					cout << j << " " << i << endl;
					a[j] = '1';
					break;
				}
			}
		}
	}
	return 0;
}
//*******************
// 1.cpp 
// ??  1200018415
// 2012 11 27
//*******************

char str[101], b, g;
int match(int, char, char);

int main()
{
	
	int len, i;
	cin >> str;   
	len = strlen(str);
	b = str[0];
	g = str[len - 1];
	match(0, b, g);                 // ????
	return 0;
}

int match(int n, char b, char g)
{
	for (int i = n; str[i] != '\0'; i++)
	{
		while (str[n] == '*')                // ???????
		{
			n++;                             // ????
		}
		if (str[i] == b)                     // ?????
		{
			str[i] = '*';                    // ????
			int k = match(n + 1, b, g);      // ??????
			cout << n << " " << k << endl;
		}
		else
			if (str[i] == g)                // ?????
			{
				str[i] = '*';               // ??
				return n;                   // ?????
			}
	}
}
void main()
{
	char str[100],c;
	int i,j,p,n,b[100],a[100];
	scanf("%s",str);
    for(i=j=0;(c=str[i])!='\0';i++)
	{
         if(c!=str[0])b[j++]=i;
	}
	n=j;
	for(j=0;j<n;j++)
	{
		if(str[b[j]-1]==str[0])a[j]=b[j]-1;
        else 
		{
			for(i=b[j]-1;;i--)
		{   for(p=0;p<j;p++)
		{if(i!=a[p]&&i!=b[p])continue;else break;}
        if(p!=j)continue;
		else if(str[i]==str[0]){a[j]=i;break;}
		}
		}
	}
	for(j=0;j<n;j++)
		printf("%d %d\n",a[j],b[j]);
}
//**********************************
//*????.cpp                    *
//*??????                    *
//*???2011-11-18                *
//**********************************


char m[100];                                 //???????????????
int num = 0;                                 //???????????
char boy, girl;                              //?????????????
int len;                                     //???????

void search(int start)                       //start?????????????
{
	if (num == len / 2)
	{
		return;                              //?????????????????
	}
	int i, t;
	for (i = start; i < len; i++)
	{
		if (m[i] == girl)                    //????????????????????????????
		{
			for (t = i - 1; t >= 0; t--)
			{
				if (m[t] == boy)
				{
					num ++;
					m[t] = '.';              //?????????????????.
					break;
				} 
			}
			break;
		}
	}
	cout << t << " " << i << endl;           //??????????
	search(i + 1);                           //??????????????????????
}

int main()
{ 
	cin >> m;                                //??????
	len = strlen(m);                         //???????
	boy = m[0];                              //????????
	girl = m[len - 1];                       //????????
	search(0);                               //????search
	return 0;
}
void main()
{
	char c[100]={0},c1,c2;
	int p[100]={0},i,n=0,j,m;
	gets(c);
	i=0;
    c1=c[0];
	c2=c[1];
	while (c[i]!=0)
	{
		if(c[i]==c1) p[i]=1;
		else p[i]=-1;
		i++;
        n++;
	}
	do
	{
        m=0;
		for(i=0;i<n-1;i++)
		{
            j=i+1;
			while(p[j]==0) j++;
			if(p[i]*p[j]==-1)
            {
				p[i]=p[j]=0;
				printf("%d %d\n",i,j);
				m=1;
				break;
			}
		}
	}while(m==1);
}
int len;
char boy,girl;
void paidui(char[]);
int main()
{
	char kids[100];
	cin>>kids;
	len=strlen(kids);
	boy=kids[0];
	girl=kids[len-1];
	paidui(kids);
	return 0;
}
void paidui(char kids[])
{
	int i=0,j;
	while(kids[i]!=girl)
		i++;
	j=i;
	while(kids[j]!=boy)
		j--;
	cout<<j<<" "<<i<<endl;
	kids[i]=kids[j]=1;
	if(kids[len-1]==girl)
		paidui(kids);
}
char a[100], b;
int w;
int find(int);
int main()
{
	cin >> a;
	b = a[0];
	find(0);
	cin.get();
	cin.get();
	return 0;
}

int find(int j)
{
	w = j;
	if(a[j] != b)
		return j;
	else
	{
		cout << j << " " << find(j+1) << endl;
		return find(w+1);
	}
	return 0;
}
int main()
{
    int i,j,p;
    char a[100],m,n;
    scanf("%s", a);
    p=strlen(a);
    m=a[0];
    for(i=1;i<=p/2;i++) if(a[i]!=m) {n=a[i]; break;}
    for(i=i;i<=p-1;i++) if(a[i]==n) for(j=i;j>=0;j--) if(a[j]==m)
    {
    printf("%d %d\n", j, i);
    a[j]=' ';
    break;
    }
    return 0;
}
void function( char (*p)[101] , int num , int num1 , char a , char b )
{
	if( num1==num/2-1 )
	{
		cout<<0<<' '<<num-1<<endl;
	}
	else
	{
		for( int i=0 ; i<num ; i++ )
		{
			if( *(*p+i)==b )
			{
				for( int j=i-1 ; j>=0 ; j-- )
				{
					if( *(*p+j)==a )
					{
						cout<<j<<' '<<i<<endl;
						*(*p+i)=' ';
						*(*p+j)=' ';
						break;
					}
				}
				break;				
			}
		}
		function( p , num , num1+1 , a , b );
	}
}
int main()
{
	char c[2][101];
	char (*p)[101];
	char a,b;
	int num;
	cin>>c[0];
	a=c[0][0];
	b=c[0][strlen(c[0])-1];
	for( int i=0 ; i<strlen(c[0]) ; i++ )
	{
		c[1][i]=i;
	}
	p=c;
	num=strlen(c[0]);
	function( p , num , 0 , a , b );

}
int main()
{
	int s[100] = {0}, sum = 0, top = 0;
	char b, a;
	s[0] = 0;
	cin >> b;
	while(top >= 0)
	{
		cin >> a;
		sum++;
		if(a == b)
		{
			s[++top] = sum;
		}
		else
		{
			cout << s[top] << " " << sum<< endl;
			top--;
		}
	}
	return 0;
}
char dui[1000], male, female;
void rankgame(int left, int right)
{
	if(left == -1)return;
	if(dui[right] == male)
	{
		left = right;
		right++;
		rankgame(left, right);
	}
	if(dui[left] == 0)
	{
		left --;
		rankgame(left, right);
	}
	if(dui[left] == male && dui[right] == female)
	{
		cout << left << ' ' << right << endl;
		dui[left] = 0;dui[right] = 0;
		left --;
		right ++;
		rankgame(left, right);
	}
}
int main()
{
	cin.getline(dui, 1000, '\n');
	male = dui[0], female = dui[strlen(dui) - 1];
	rankgame(0, 1);
	return 0;
}
int main()
{
    int i,j;
    char x,y;
    int a[100];
    char s[100];
    scanf("%s",s);
    j=0;
    for(i=0;i<100;i++)
        a[i]=-1;
    x=s[0];
    for(i=0;i<strlen(s);i++)
        if (s[i]==x)
        {
            a[j]=i;
            j++;
        }
        else
        {
            printf("%d %d\n",a[j-1],i);
            j--;
            a[j]=-1;
        }
    return 0;
}
void pipei(char a[]){
	int i,j,p=0;
	char q=a[0];
	int len=strlen(a);
	for(i=p;i<len;i++)
		if(a[i]!=q&&a[i]!='+') {
			p=i;
			break;
		}
	if(i==len) return;
	for(j=i-1;j>=0;j--)
		if(a[j]==q) break;
	cout<<j<<' '<<i<<endl;
	a[j]=a[i]='+';
	pipei(a);
}
int main(){
	char a[100];
	cin>>a;
	pipei(a);
}
int kiss(char ch[], char b, char g, int l, int i){
	int boy;
	int j;
	if(ch[i]!=g) boy=-1;
	else{
		for(j=i-1; j>=0; j--){
			if(ch[j]==b){
				boy=j;
				ch[i]='\0';
				ch[j]='\0';
				break;
			}
			else;
		}
	}
	return(boy);
}



main(){
	char ch[5000], b, g;
	int i, l, girl, boy;
	scanf("%s", ch);
	l=strlen(ch);
	b=ch[0];
	for(i=1; i<l; i++){
		if(ch[i]!=b){
			g=ch[i];
			break;
		}
		else;
	}
	for(i=1; i<l; i++){
		boy=kiss(ch, b, g, l, i);
		if(boy==-1) continue;
		else{
			girl=i;
			printf("%d %d\n", boy, girl);
		}
	}
}
char A[110]={'\0'},b,g;      //??????:??A?????,b`g????????????
int i,j,l,a;                 //??????:????i`j`a,????l,
void outcome()               //????
{
     for (i=a;i<l;i++)
     {
         if (A[i]==g)
         {
             A[i]='\0';
             break;
         }
     }
     for (j=i-1;j>=0;j--)
     {
         if (A[j]==b)
         {
             A[j]='\0';
             break;
         }
     }
     cout<<j<<" "<<i<<endl;
     if (i!=l-1)
     {
         outcome();
     }
}
int main()
{
    cin>>A;
    b=A[0];
    l=strlen(A);
    for (a=1;a<l;a++)         //??????????????????????
    {
        if (A[a]!=b)
        {
            g=A[a];
            break;
        }
    }
    outcome();
    return 0;
}
int main()
{
	char str[500],a,b;
	int i,j,len,t,p;
	gets(str);
	len=strlen(str);
	a=str[0];
	b=str[len-1];
	t=2;
	while(t==2){
	for(i=0;i<len-1;i++){
		for(j=i+1;j<len;j++){
			if(str[j]==a)break;
			if(str[j]==b){
				printf("%d %d\n",i,j);
				str[i]='$';
				str[j]='$';
				t=1;
				p=j;
				break;
			}
		}
		if(p==len-1){t=0;break;}
		if(t==1){t=2;break;}
	}
	}
	return 0;
}
char kid[100];
int f(int x)
{
	if (kid[x] == 'g') return x;
	if (kid[x] == 'b') {int g = f(x+1); cout << x << " " << g << endl; return f(g+1);}
}
int main()
{
	int i=0,sum;
	char c,first;
	c=getchar();
	first=c;
	while (c!='\n')
	{
		if (c==first)
		{
			c='b';
		}
		else
		{
			c='g';
		}
		kid[i]=c;
		i+=1;
		c=getchar();
	}//??????????????????i??????
	f(0);
return 0;
}
int main()
{
	char children[101];
	char boy, girl, left;
	cin.getline(children, 101);
	int l = strlen(children), cnt = 0;
	boy = children[0];
	girl = children[l - 1];
	left = boy > girl? (girl - 1) : (boy - 1);
	do
	{
		for(int i = 1; i < l; i++)
		{
			if(children[i] == left)
			{
				i++;
				continue;
			}
			if(children[i] == girl)
			{
				for(int j = i - 1; j >= 0; j--)
				{
					if(children[j] == left)
					{
						j--;
						continue;
					}
					if(children[j] == girl)
						break;
					else
					{
						cout << j << " " << i << endl;
						children[i] = left;
						children[j] = left;
						cnt += 2;
						break;
					}
				}
			}
		}
	}while(cnt != l);
	return 0;
}
void a(char t[],int k)
{int i,j;
if(t[0]!=0)
{for(i=0;i<k-1;i++)
{if(t[i]==0)
continue;
j=i+1;
while(t[j]==0)
{j++;}
if(t[i]!=t[j])
{cout<<i<<" "<<j<<endl;
t[i]=0;
t[j]=0;
break;}
}
a(t,k);
                }


     }
int main()
{char t[100];
int i,k;
for(i=0;i<100;i++)
t[i]=0; 
cin>>t;
for(i=0;i<100;i++)
{if(t[i]==0)
break;} 
k=i;
a(t,k);

return 0;

    
    }
char m[100],boy,girl;
int len;
void C();
int findgirl(int);
int main(){
	int i=0;
	cin>>m;
	boy=m[0];
	while(m[i]!='\0'){
		if(m[i]!=boy){
			girl=m[i];
			break;
		}
		else
			i++;
	}
	len=strlen(m);
	for(i=0;i<len/2;i++)
		C();
	return 0;
}
void C(){
	int i,g;
	for(i=0;i<len;i++){
		if(m[i]==boy){
			g=findgirl(i);
			if(g!=0){
				cout<<i<<" "<<g<<endl;
				m[i]='`';m[g]='`';
				break;
			}
		}
	}
}
int findgirl(int i){
	int a;
	if(m[i+1]=='`'){
		a=findgirl(i+1);
		return a;
	}
	else if(m[i+1]==girl)
		return i+1;
	else
		return 0;
}
char a[1000];
int match(char a[1000],char m,char f)
{   int i,j;
	for(i=0;a[i]!='\0';i++)
	{
		if(a[i]==f)
		{
		   break;
		}
	}
	if(a[i]=='\0')
	   return 0;
	for(j=i;j>=0;j--)
	{
		if(a[j]==m)
		{
			cout<<j<<' '<<i<<endl;
		    break;
		}
	}
	a[j]='*';a[i]='*';
	match(a,m,f);
}
int main()
{
	char m,f;
	cin>>a;
	m=a[0];
	int i;
	for(i=0;i<=999;i++)
	{
		if(a[i]!=m)
		{
			f=a[i];
			break;
		}
	}
	match(a,m,f);
	return 0;
}
int main()
{
	char a[1000];
	int n,x,m;
	gets(a);
	for(n=0,x=1;a[n]!='\0';n++)
	{
		if(a[n]==a[0])x=0;
		else if(a[n]!=' ')
		{
			for(m=n-1;m>=0;m--)
				if(a[m]==a[0])
				{
					printf("%d ",m);
					a[m]=' ';
					break;
				}
			printf("%d\n",n);
			a[n]=' ';
			n=0;
			x=1;
		}
		if(a[n+1]=='\0')break;
	}
	return 0;
}
int main()
{
	char s[222];
	int i=1,j,k,len;
	gets(s);
	len=strlen(s);
	char a,b;
	a=s[0];
	b=s[len-1];
	for (i;i<=len-1;i++)
	{
		k=i;
		if (s[k]==b)
		{
			j=i;
			for (i=j-1;i>=0;i--)
			{	
				if(s[i]==a)
				{
					s[i]='0';s[j]='0';
					printf("%d %d\n",i,j);
					break;
				}
			}
		}
	}
}
int main()
{
	char a[100];
	int b[100],c[100];
	int i,n,j=0,k=0;
	scanf("%s",a);
	for(i=0;i<strlen(a);i++){
		if((a[i]=='(')||(a[i]=='{')||(a[i]=='[')||(a[i]=='<'))
			b[j++]=i;
		else if((a[i]==')')||(a[i]==']')||(a[i]=='}')||(a[i]=='>')){
			c[k++]=b[j-1];
			c[k++]=i;
			j--;
		}
	}
	for(i=0;i<strlen(a);i++){
		if(!(i%2))
			printf("%d ",c[i]);
		else
			printf("%d\n",c[i]);
	}
	return 0;
}
int main()
{
	char boy, girl;
	char p[100];
	scanf("%s", p);
	
	boy = p[0];
	int i, j, k = 0;
	for(i = 1; i < strlen(p); i++)
	{
		if(p[i] != boy)
		{
			girl = p[i];
			break;
		}
	}

	struct
	{
		int id;
		char c;
	}
	a[100], t;
	
	for(i = 0; i < strlen(p); i++)
	{
		a[i].id = i;
		a[i].c = p[i];
	}

	for(i = 0; i < strlen(p) - k; i++)
	{
		if(a[i].c == boy && a[i + 1].c == girl)
		{
			printf("%d %d\n", a[i].id, a[i + 1].id);
			k += 2;
			for(j = i; j < strlen(p) - k; j++)
			{
				a[j] = a[j + 2];
			}
			i = -1;
		}
	}

	return 0;
}
char temp[1000000];
char a,b;

void find (void);

int main (void)
{
	cin.getline(temp,1000000);
	a = temp[0];
	b = temp[strlen(temp)-1];
	find ();

	return 0;
}

void find (void)
{
	int i, index_1, index_2;
	for (i = 0; temp[i] != '\0'; i++)
	{
		if (temp[i] == b)
		{
			index_1 = i;
			temp[i] = ' ';
			break;
		}
	}
	if (temp[i] == '\0')
		return;

	for ( i = index_1; ;i--)
	{
		if (temp[i]==a )
		{
			index_2 = i;
			temp [i] = ' ';
			break;
		}
	}
	cout << index_2<<' '<<index_1 << endl;
	find();
	return;
}
int main()
{
    char a[200];
    scanf("%s",a);
    int i,j,k;
    int len=strlen(a);
    char b=a[0];
    for(i=0;i<len;i++)
    {
        if(a[i]!=b&&a[i]!=0)
        {
            for(j=i;j>=0;j--)
            {
                if(a[j]!=a[i]&&((i-j-1)%2)==0&&a[j]!=0)
                {
                    a[j]=0;
                    a[i]=0;
                    printf("%d %d\n",j,i);
                    break;
                }
            }
        }
    }


}
struct children
{
	char bracket;
	int code;
};
char boy,girl;

void main()
{
	void func(struct children chd[],int n);
	int scan(struct children *p,char string[100]);
	struct children chd[100]={'\0',0};
	struct children *p;
	p=chd;
	char str[100];
	scanf("%s",str);
	int len=scan(p,str);
    boy=str[0];
    int point=0;
	for(point=0;point<len;point++)
	{
		if(str[point]!=boy)
		{
			girl=str[point];
			break;
		}
	}
	func(chd,len);	
}

void func(struct children chd[],int n)
{
	void exile(struct children chd[],int friendcode,int lenx);
	int j=0;
	for(j=0;j<n;j++)
	{
		if(chd[j].bracket=='\0') break;
	    if(chd[j].bracket==boy && chd[j+1].bracket==girl)
		{
			printf("%d %d\n",chd[j].code,chd[j+1].code);
			exile(chd,j,n);
		    j=j-1;
			n=n-2;
		}
		else
		{
			if(chd[j].bracket==boy &&chd[j+1].bracket==boy) func(chd+1,n-1);
			else 
			{
			    if(chd[j].bracket==girl)
				{   
				    func(chd-1,n+1);
				}
			}
		}
	}
}

int scan(struct children *p,char string[100])
{
	int i=0;
	while(string[i]!='\0')
	{
        p->bracket=string[i];
		p->code=i;
		p+=1;
		i+=1;
	}
	return(i);
}
void exile(struct children chd[],int friendcode,int lenx)
{
	int k=0;
	for(k=friendcode;k<lenx-1;k++)
	{
		chd[k]=chd[k+2];
	}
}
/************************************
3.cpp
???Nov 15, 2011
??(15.2) ????
?? 1100012886
************************************/


char queue[100], boy, girl; //??????????????????
int length = 0;

void process() //???????????
{
	int i, j;
	for (i = 0; i <= length - 2; i++)
	{
		//????????????????????????????
		if (queue[i] == boy)
		{
			j = i;
			do
			{
				j++;
			} while (queue[j] == ' '); //????????????
			if (queue[j] == girl)
			{
				//???????????????
				queue[i] = ' ';
				queue[j] = ' ';
				cout << i << " " << j << endl;
				if (j < length - 1) process(); //????????????????????
			}
		}
	}
}

int main()
{
	int i;
	cin >> queue;
	do
	{
		length++;
	} while (queue[length] != '\0'); //??????
	boy = queue[0];
	i = 0;
	do
	{
		i++;
	} while (queue[i] == boy);
	girl = queue[i]; //???????????
	process(); //????
	return 0;
}
int i;
int num;
char s[102];
	char c1 ;
	char c2;
int sol()
{
	if(i >= num)
		return -1;
	int n = i;
	char b = s[i++];
	if(b == c1)
	{
		cout<<n<<" "<<sol()<<endl;
		return sol();
	}
	else if(b == c2)
		return n;
}
int main()
{
	
	cin>>s;
	num = strlen(s);
	c1 = s[0];
	for(int i = 1;i<num;i++)
	{
		if(s[i] != c1)
		{
			c2 = s[i];
			break;
		}
	}
	sol();
}
int main()
{
	char a[101];
	cin >> a;
	char b = a[0];
	int l = strlen(a);
	char g = a[l - 1];
	for (int i = 0; i < l && a[i] != '*'; i++)
	{
		if (a[i] == g)
		{
			a[i] == '*';
			for (int j = i; j >= 0;j--)
			{
				if (a[j] == b && a[j] != '*') 
				{
					a[j] = '*';
					cout << j << " " << i << endl;
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
    char a[100][100];
    scanf("%s",a[0]);
    int n;
    n=strlen(a[0]);
    int b[100][100];
    int i,j,k;
    for(i=0;i<n;i++)
    {
        b[0][i]=i;
    }
    for(i=0;i<=n/2-1;i++)
    {
        for(j=0;j<n;j++)
        {
            if(a[i][j]!=a[i][j+1])
            {
                printf("%d %d\n",b[i][j],b[i][j+1]);
                for(k=0;k<j;k++)
                {
                    a[i+1][k]=a[i][k];
                    b[i+1][k]=b[i][k];
                }
                for(k=j+2;k<n;k++)
                {
                    a[i+1][k-2]=a[i][k];
                    b[i+1][k-2]=b[i][k];
                }
               break;
            }
        }
    }
    //scanf("%d",i);
    return 0;
}