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<cstdio>
#include<cstring>
#include<stdlib.h>
#define NN 1000
using namespace std;

int main(){
  char in[NN][NN];
  int k=0,i,j,a[NN],b[NN],l=0,an=0,bn=0,count=0;

  for(i=0;;i++){
    cin >> in[i];
    if(in[i][0] != 'A'  && in[i][0] != 'B')break;
    // cout << strlen(in[i]) << endl;    

    for(l=0;l<strlen(in[i]);l++){
      if(l>0){
	if(in[i][l] == 'A'){
	an++;
	}
	else if(in[i][l] == 'B'){
	  bn++;
	}
      }
    }
    /*
    cout << "**"<< an << " " << bn << endl;
    cout << "%%0 "<< a[0]<<" "<<b[0] <<endl;
    cout << "%%1 "<< a[1]<<" "<<b[1] <<endl;
    cout << "%%2 "<< a[2]<<" "<<b[2] <<endl;
    cout << "%%3 "<< a[3]<<" "<<b[3] <<endl;
    cout << "%%4 "<< a[4]<<" "<<b[4] <<endl;
    cout << "%%5 "<< a[5]<<" "<<b[5] <<endl;
    cout << "%%6 "<< a[6]<<" "<<b[6] <<endl;
    */ 

    if(an>=9&&bn>=9){
      if(an-1 == bn){
	a[k]=an+1;
	b[k]=bn;
	k++;
	an=0;
	bn=0;
	count++;
      }
      else if(an == bn-1){
	  a[k]=an;
	  b[k]=bn+1;
	  k++;
	  an=0;
	  bn=0;
	  count++;
	}
      }
    else if(an == 10){
      a[k]=an+1;
      b[k]=bn;
      k++;
      an=0;
      bn=0;
      count++;
    }
    else if(bn == 10){
      a[k]=an;
      b[k]=bn+1;
      k++;
      an=0;
      bn=0;
      count++;
    }  
    
    
    
    if(count == 3){
      for(j=0;j<3;j++){
	cout << a[j] << " " <<b[j] <<endl;
      }
      k=0;
      count=0;
    }
    
  }
  
  
  
}

C++: #define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

int main(){
	string str;
	bool isA = true;
	while(cin >> str){
		if(str.size() == 1 && str[0] == '0') break;
		int A = isA ? count(str.begin(),str.end(),'A') - 1 : count(str.begin(),str.end(),'A');
		int B = isA ? count(str.begin(),str.end(),'B') : count(str.begin(),str.end(),'B') - 1;

		if(A > B){
			printf("%d %d\n",B < 10 ? 11 : A+1, B);
		}
		else if(B > A){
			printf("%d %d\n",A, A < 10 ? 11 : B+1);
		}
		isA = A > B ? true : false;
	}
}

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

using namespace std;

int main(){

  int a=0, b=0;
  char in;
  int i = 0;

  while(scanf("%c",&in)){
    if(in == '0') break;
    if(i == 0){
      scanf("%c",&in);
      i++;
    }
    if(in == 'A') a++;
    if(in == 'B') b++;
    if(in == '\n'){
      i = 0;
      if(a > b) a++;
      else b++;
      cout << a << " " << b << endl;
      a = 0;
      b = 0;
    }

  }
  return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  string line[3];
  while(cin>>line[0]>>line[1]>>line[2]){
    REP(i,3){
      int a=0,b=0;
      FOR(j,1,line[i].size()){
        if(line[i][j]=='A') a++;
        else b++;
      }
      if(a-b>0) a++;
      else b++;
      cout<<a<<" "<<b<<endl;
    }
  }
  return 0;
}

C++: #include<stdio.h>
int main()
{
	char s[128];
	int a,b,i;
	while(scanf("%s",s),s[0]-'0')
	{
		for(a=b=i=0; s[i+1]; ++i)
			(s[i+1]-'B'?a:b)++;
		(a<b?b:a)++;
		printf("%d %d\n",a,b);
	}
	return 0;
}

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

int main(){
	char ta[1000]="",tmp[1000];
	int a,b;

	while(true){
	for(int i=0;i<3;i++){
	cin>>ta;
	if(strcmp(ta,"0"==0)break;
	a=b=0;
		for(int j=(i>=1);ta[j]!='\0';j++){
		(ta[j]=='A')?a++:b++;
		}
		(a>b)?a++:b++;
		cout<<" "<<a<<" "<<b<<endl;
	}
	}


	return 0;
}

C++: #include<string>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    bool endFlag=false;
    while(!endFlag){
        string str;
        for(int i=0;i<3;i++){
            cin>>str;
            if(str=="0"){
                endFlag=true;
                break;
            }
            int a,b;a=b=0;
            for(int i=1;i<str.length();i++){
                if(str[i]=='A')a++;
                else b++;
            }
            if(a>b)a++;
            else b++;
            cout<<a<<" "<<b<<endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  string s;
  while(cin >> s) {
    if(s == "0") return 0;

    int a = 0, b = 0;
    rep(i, 1, s.length()) {
      if(s[i] == 'A') a++;
      else b++;
    }

    cout << (a == max(a, b) ? a + 1 : a) << " " << (b == max(a, b) ? b + 1 : b) << endl;
  }
}

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

int main()
{
while(1){
	char s[100];
	int a=0,b=0,i,j;

	cin >> s;
if(s[0]=='0'&&s[1]=='\0')break;

		if(s[0]=='A')a=a-1;
		if(s[0]=='B')b=b-1;	
for(i=0;s[i]!='\0';i++){
		if(s[i]=='A')a=a+1;
		
		if(s[i]=='B')b=b+1;
		
}
if(a>b){a=a+1;
}else{ b=b+1;}


cout<<a<<" "<<b<<endl;
}
return 0;

}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    string s;
    cin >> s;
    while(true){
	if(s == "0") break;
	int a,b;
	a = 0;
	b = 0;
	for(int i=1;i<s.size();i++){
	    if(s[i] == 'A'){
		a++;
	    }else if(s[i] == 'B'){
		b++;
	    }
	}
	cin >> s;
	if(a >= 10 && b >= 10){
	    if(a > b){
		a++;
	    }else{
		b++;
	    }
	}else{
	    if(a > b) a = 11;
	    else b = 11;
	}
	printf("%d %d\n",a,b);
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,a,b,cnt,s1[3],s2[3];
	char sabu[102];
	while(1) {
		cnt=0;
		for(i=0;i<3;i++) {
			cin>>sabu;
			if(sabu[0]=='0') {
				cnt=1;
				break;
			}
			a=b=0;
			for(j=1;j<strlen(sabu);j++) {
				if(sabu[j]=='A')a++;
				else b++;
				//if(a==b&&a>10) a=b=10;					
			}
			if(a>b)s1[i]=a+1,s2[i]=b;
			else s1[i]=a,s2[i]=b+1;

		}
		if(cnt==1) break;
		for(i=0;i<3;i++) cout<<s1[i]<<" "<<s2[i]<<endl;
	}
	return 0;
}

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

int main(){
  int a,b;
  char tmp;

  while(1){
    tmp = getchar();
    if(tmp=='0')break;

    for(int i=0;i<3;i++){
      a = 0;
      b = 0;
      while(1){
	tmp = getchar();
	if(tmp=='\n')break;
	else if(tmp == 'A')a++;
	else b++;
      }
      if(i==2)break;
      tmp = getchar();;
      if(tmp == 'A')a++;
      else b++;
      cout << a << " " << b << endl;
    }
    if(a<10 && b==10)b++;
    else if(b<10 && a==10)a++;
    else if(a>b)a++;
    else b++;
    cout << a << " " << b << endl;
  }
}