Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	flag := true
	for {
		for i := 0; i < 3; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), "")
			if buf[0] == "0" {
				flag = false
				break
			}
			a, b := 0, 0
			buf = buf[1:]
			for _, v := range buf {
				if string(v) == "A" {
					a++
				} else {
					b++
				}
			}
			if a > b {
				a++
			} else {
				b++
			}
			fmt.Println(a, b)
		}
		if !flag {
			break
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  while(cin>>str,str!="0"){
    int a[2]={};
    for(int i=1;i<str.size();i++){
      if(str[i]!=str[i-1]){
	a[str[i]-'A']++;
      }else{
	a[str[i]-'A']++;
      }
    }
    if(a[0]>a[1])
      a[0]++;
    else
      a[1]++;
    cout<<a[0]<<" "<<a[1]<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;

int main(){
	string s;
	while(cin>>s,s!="0"){
		int a,b;
		a=b=0;
		for(int i=1;i<s.size();i++){
			if(s[i]=='A') a++; else b++;
		}
		if(a>b) a++; else b++;
		cout<<a<<" "<<b<<endl;
		
	}
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	while(true){
		int A = 0, B = 0;
		for(int g=0;g<3;g++){
			A = 0; B = 0;
			for(int i=0;;i++){
				char c; scanf("%c",&c);
				if(c=='0') return 0;
				if(i==0) continue;
				if(c=='\n'){
					if(A>B) A++;
					else B++;
					printf("%d %d\n",A,B); break;
				}
				if(c=='A') A++;
				else if(c=='B') B++;
			}
		}
	}
	return 0;
}

C++: 
#include <iostream>
using namespace std;
int main(){
 char S[101];
 int a,b; 
 while(1){
  cin>>S;
  if(S[0]=='0') break;
  for(int i=1;i<=101;i++){
   if(S[i]=='A') a++;
   if(S[i]=='B') b++; 
   }
  if(a>b) a++;
  else b++;
  cout<<a<<' '<<b<<endl;
  a=0;b=0;
 }  

 return 0;

}

C++: #include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int i,j,counta=0,countb=0,bx;
    string str;
bool bo=false;
void duce();
int main(){
    for(i=1;;i++){
            getline(cin,str);
        if(str[0]=='0'){
            break;
        }
            for(j=1;j<str.size();j++){
           // if(counta==10 && countb==10){
            //    duce();
              //  bo=true;
                //break;
            //}
            if(str[j]=='A'){
                counta++;
            }
            else if(str[j]=='B'){
                countb++;
            }
        }
        if(bo){
            bo=false;
        }
        else if(counta<countb){
            countb++;
        }
        else if(counta>countb){
            counta++;
        }
        cout<<counta<<" "<<countb<<endl;
        counta=0;
        countb=0;
    }
    return 0;
}
void duce(){
    counta=0;countb=0;
        for(;j<str.size();j++){
            if(str[j]=='A'){
                counta++;
            }
            else{
                countb++;
            }
        }
    
    return;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,a,b;
  string str;
  while(1){
    getline(cin,str);
    if(str[0] == '0') break;

    a = 0;
    b = 0;
    for(i=1;i<str.size();i++){
      /*     if(a >= 11 && b < 10 || a >= 10 && b >= 10 && a-b >=2){
	  a++;
	  break;
	}
	else if(b >= 11 && a < 10 || a >= 10 && b >= 10 && b-a >=2){
	  b++;
	  break;
	  }*/
	 if(str[i] == 'A') a++;
	 else if(str[i] == 'B') b++;
	}

    if(a>b) a++;
    else b++;

      cout << a << " " << b << endl;

  }
  return 0;
}

C++: #include<stdio.h>
#include<string.h>

int main(){
	char ss[40];
	int i,j,a,b;
	
	while(~scanf(" %s ",ss)){
		if(ss[0]=='0')break;
		i=1;
		a=0;
		b=0;
		while(1){
			if(ss[i]=='\0')break;
			if(ss[i]=='A')++a;
			if(ss[i]=='B')++b;
			++i;
		}
		if(a>b){
			++a;
		}else{
			++b;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string A;
    auto f = [&](string &s){
        int a = 0, b = 0;
        for (int i = 1; i < s.size(); ++i) {
            if(s[i] == 'A') a++;
            else b++;
        }
        if(a < b) b++;
        else a++;
        cout << a << " " << b << "\n";
    };
    while(cin >> A, A != "0"){
        string B, C;
        cin >> B >> C;
        f(A); f(B); f(C);
    }
    return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

int main(){
while(1){
	string s;
	cin>>s;
	if(s=="0"){
		break;
	}
	int a=0,b=0;
	for(int i=1;i<s.size();i++){
		if(s[i]=='A'){
			a++;
		}else{
			b++;
		}
	}
	if(a>b){
		a++;
	}else{
		b++;
	}
	cout<<a<<' '<<b<<endl;
}
	return 0;
}

C++: #include <string>
#include <iostream>
#include <vector>
using namespace std;

int solve() {
  vector<string> vs(3);
  cin >> vs[0];
  if(vs[0] == "0") return 1;
  cin >> vs[1] >> vs[2];

  for(int k=0; k<3; k++) {
    int N = vs[k].length();
    int sa = 0, sb = 0;
    for(int i=1; i<N; i++) {
      if(vs[k][i] == 'A') sa++;
      if(vs[k][i] == 'B') sb++;
    }
    if(k < 2) {
      if(vs[k+1][0] == 'A') sa++;
      if(vs[k+1][0] == 'B') sb++;
    }
    else {
      if(sa >= 10 and sb >= 10) {
        if(sa > sb) sa++;
        else sb++;
      }
      else {
        if(sa == 10) sa++;
        if(sb == 10) sb++;
      }
    }
    printf("%d %d\n", sa, sb);
  }
  return 0;
}

int main() {
  while(!solve());
}

C++: #include<stdio.h>


int main( void )
{
	while( 1 )
	{
		char AB[ 101 ] ;
		scanf( "%s" ,AB ) ;

		if( AB[ 0 ] == '0' )
		{
			return 0 ;
		}

		int a = 0 ;
		int b = 0 ;

		int i ;
		for( i = 1 ; AB[ i ] > 0 ; ++i )
		{
			a += 1 * ( AB[ i ] == 'A' ) ;
			b += 1 * ( AB[ i ] == 'B' ) ;
		}

		if( a > b )
		{
			++a ;
		}

		else
		{
			++b ;
		}

		printf( "%d %d\n" ,a ,b ) ;
	}

	return 0 ;
}

C++: #include <iostream>
#include <string>

using namespace std;

int main()
{
	string inp[3];
	
	while (cin >> inp[0], inp[0] != "0")
	{
		cin >> inp[1] >> inp[2];

		for (int i = 0; i < 3; i++)
		{
			int a_ten = 0, b_ten = 0;

			for (int j = 0; j < inp[i].length(); j++)
			{
				if (j == 0) continue;
				if (inp[i][j] == 'A')
				{
					a_ten++;
				}
				else if (inp[i][j] == 'B')
				{
					b_ten++;
				}
			}

			if (a_ten > b_ten)
			{
				a_ten++;
			}
			else
			{
				b_ten++;
			}

			cout << a_ten << " " << b_ten << endl;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    string s[3];
    while(cin >> s[0])
    {
        if(s[0] == "0") return 0;
        cin >> s[1];
        cin >> s[2];

        int a[3] = {}, b[3] = {};

        int l;
        rep(j,3)
        {
            l = s[j].size();
            if(j>0)
            {
                if(s[j][0] == 'A')a[j-1]++;
                else b[j-1]++;
            }

            REP(l - 1)
                if(s[j][i + 1] == 'A') a[j]++;
                else b[j]++;
        }
        if(a[2] < b[2]) b[2]++; else a[2]++;

        REP(3)cout << a[i] << " " << b[i] << endl;
    }
    return 0;
}