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>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007




int main(){
	vector<string> s(3);
	while(cin>>s[0]){
		if(s[0]=="0")break;
		cin>>s[1]>>s[2];
		vector<pair<int,int> > v(3,pii(0,0));
		for(int i=0; i<3; i++){
			if(i>0){
				if(s[i][0]=='A')v[i-1].fi+=1;
				else v[i-1].se+=1;
			}
			for(int j=1; j<s[i].size(); j++){
				if(s[i][j]=='A')v[i].fi+=1;
				else v[i].se+=1;
			}
			if(i==2){
				if(v[i].fi>v[i].se)v[i].fi+=1;
				else v[i].se+=1;
			}
		}
		for(int i=0; i<3; i++){
			cout<<v[i].fi<<" "<<v[i].se<<endl;
		}
	}
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
    char game[2000];
    while(cin>>game){
        int A=0,B=0;
        if(game[0]=='0')break;
        for(int i=1;i<strlen(game);i++){
            if(game[i]=='A')A++;
            else if(game[i]=='B')B++;
        }
        if(A>B)cout<<A+1<<" "<<B<<endl;
        else if(A<B)cout<<A<<" "<<B+1<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string s[3];
	while(cin >> s[0] , s[0] != "0"){
		cin >> s[1] >> s[2];
		rep(j,3){
			int a[2] ={0};
			rep(i,s[j].size()-1){
				a[s[j][i+1]!='A']++;
			}
			cout << a[0] + (a[0]>a[1]) << " " << a[1] + (a[1]>a[0]) << endl;
		}
	}
}

C++: # define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	string a[3];
	while (cin >> a[0] >> a[1] >> a[2])
	{
		FOR(i, 3)
		{
			a[i] += a[i].back();
			int ans[2] = {};
			FORI(j, 1, a[i].size())
			{
				ans[a[i][j] == 'B']++;
			}
			cout << ans[0] << " " << ans[1] << endl;
		}
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
  int as,bs;
  char s[101],sf,f;
  cin >> sf;
  while(cin>>s>>f){
    as = 0;
    bs = 0;
    for(int i=0;i<strlen(s);i++){
      if(s[i]=='A') as++;
      else bs++;
    }
    if(f=='0'){
      if(as>bs) as++;
      else bs++;
    }
    else if(f=='A') as++;
    else bs++;
    cout << as << ' ' << bs << endl;
  }
  return 0;
}

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

int main() {
  string s;
  while(cin >> s && s!="0") {
    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 <iostream>
#include <string>
using namespace std;

int main(){

	while(true){
		string point;
		cin>>point;

		if(point=="0")
			break;
	
		int A=0,B=0;
	
		for(int i=1;i<point.size();i++){
			if(point[i]=='A'){
				A++;
			}
			else{
				B++;
			}
		}
		if(A>B){
			A++;
		}
		else{
			B++;
		}
		cout<<A<<' '<<B<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  string s;
  while(cin >>s && s != "0"){
    int t = 0;
    REP(g, 3){
      if(g) cin >>s;
      int a = 0, b = 0;
      FOR(i, 1, s.length()){
        if(s[i] == 'A') ++a;
        else ++b;
      }
      if(a > b) ++a;
      else ++b;
      t = (a > b ? 0 : 1);
      cout <<a <<" " <<b <<endl;
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int main(){
	string s;
	while(cin>>s,s != "0"){
		int a = 0,b = 0;
		for(int i = 1; i < sz(s); i++){
			if(s[i]=='A') a++; else b++;
		}
		if(a>b) a++; else b++;
		printf("%d %d\n",a,b);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

char c;
string s;

int main(){
	while(cin>>s){
		if(s=="0")return 0;
		int h=3,f=0;
		while(h--){
			if(f)cin>>s;
			int cur=1,a=0,b=0;
			while(cur<s.size()){
				if(s[cur++]=='A')a++;
				else b++;
			}
			if(a>b)a++;
			else b++;
			cout<<a<<" "<<b<<endl;
			f=1;
		}
	}
}