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 <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

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

	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
char in[100]={0};
while(cin>>in,in[0]-'0'){
int a=0,b=0;
loop(i,1,strlen(in)){
if(in[i]=='A')a++;
if(in[i]=='B')b++;
}
if(a>b)cout<<a+1<<" "<<b<<endl;
else cout<<a<<" "<<b+1<<endl;
}
}

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

void dec(string s){
    int a = 0, b = 0;
    for(int i = 1; i < s.length(); i++){
        if(s[i] == 'A')     a++;
        if(s[i] == 'B')     b++;
    }

    if(a > b)   a++;
    else        b++;
    
    cout << a << " " << b << endl;
}

int main(){
    while(1){
        string s;
        cin >> s;

        if(s == "0")    break;

        dec(s);
        for(int i = 0; i < 2; i++){
            cin >> s;
            dec(s);
        }
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

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

        int a = 0;
        int 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 << endl;
    }
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main(void){
	int A,B,len,i;
	char str[1000];

	while(1){
		A=0; B=0;
		fgets(str,sizeof(str),stdin);
		if(str[0]=='0') break;
		len=strlen(str)-1;
		for(i=1;i<len;i++){
			if(str[i]=='A')
				A+=1;
			else if(str[i]=='B')
				B+=1;
		}
		if(A>B)
			printf("%d %d\n",A+1,B);
		else if(B>A)
			printf("%d %d\n",A,B+1);
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }


/// template end ///



void solve()
{
	while (true)
	{
		auto cur = read<string>();
		if (cur[0] == '0') { break; }
		auto a = count(cur.begin() + 1, cur.end(), 'A');
		auto b = count(cur.begin() + 1, cur.end(), 'B');
		(a > b ? a : b)++;
		write(a, b);
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
    char ser[102];
    int a=0,b=0;
    while(1){
        scanf("%s",ser);
        if(ser[0]=='0')break;
        for(int i=1;;i++){
            if(ser[i]=='\0'&&a>b)ser[i]='A';
            else if(ser[i]=='\0')ser[i]='B';
            if(i==21)i++;
            if(ser[i]=='A')a++;
            else b++;
            if((a==11||b==11)&&(a<10||b<10))break;
            else if((a-b==2||a-b==-2)&&(a>=10&&b>=10))break;
        }
        cout<<a<<" "<<b<<endl;
        a=0;b=0;
    }
}

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

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

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
   string s;
	while(cin>>s){
		if(s[0]=='0')break;
		int a=0,b=0;
		r(i,0,s.size()){
			if(s[i]=='A')a++;
			else b++;
		}
		cout<<a<<' '<<b<<endl;
	}
}