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<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++)s[i]=='A'?a++:b++;
		a>b?a++:b++;
		cout<<a<<" "<<b<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){

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

    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int) 1e9 : (int) 1e18)
#define EPS 0.0000000001
using namespace std;
template <class T, class S> void cmin(T &a, const S &b) {
    if (a > b) a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
    if (a < b) a = b;
}
template <typename Head, typename Value>
auto vectors(const Head &head, const Value &v) {
    return vector<Value>(head, v);
}
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
    auto inner = vectors(tail...);
    return vector<decltype(inner)>(x, inner);
}
template <class T> void join(T a) {
    for (auto itr : a) {
        if (itr != *a.begin()) cout << " ";
        cout << itr;
    }
}
int W, H;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool valid(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); }
auto out(int a, int b) {
    (a > b ? a += 1 : b += 1);
    cout << a << " " << b << endl;
}
main() {
    string s;
    while (cin >> s, s != "0") {
        int a = 0, b = 0;
        rep(i, (int) s.size()) {
            if (i == 0) continue;
            (s[i] == 'A' ? a += 1 : b += 1);
        }
        out(a, b);
    }
}

C++: #include<iostream>

char service[3][101];
int point[2];

void solve(int n){
	point[0]=0;
	point[1]=0;
	for(int i=1; service[n][i]!='\0'; i++){
		if(service[n][i]=='A')
			point[0]++;
		else
			point[1]++;
	}
	if(service[(n+1)%3][0]=='A')
		point[0]++;
	else
		point[1]++;
}

int main(){
	while(true){
		for(int i=0; i<3; i++){
			std::cin >> service[i];
			if(service[0][0] == '0')
				return 0;
		}
		for(int i=0; i<3; i++){
			solve(i);
			std::cout << point[0] << ' ' << point[1] << std::endl;
		}
	}
}

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  bool f = true;
  while(f) {
    string s;
    int hoge = 0;
    REP(i,3) {
      cin >> s;
      if (s == "0") {
        f = false;
        break;
      }
      int a = count(ALL(s),'A');
      int b = count(ALL(s),'B');
      if (hoge == 0)
        a--;
      else
        b--;
      if (a>b) {
        a++;
        hoge = 0;
      } else {
        b++;
        hoge = 1;
      }
      cout << a << " " << b << endl;
    }
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
string S; int a, b;
int main() {
	while (cin >> S) {
		a = 0; b = 0;
		if (S == "0") { break; }
		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 <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
  while (true){
    string s;
    int a=0,b=0;
    cin >> s;
    if (s=="0") break;
    for (int i=0;i<s.size();i++){
      if (i==0) continue;
      if (s.at(i)=='A') a++;
      if (s.at(i)=='B') b++;
    }
    if (a>b) a++;
    else b++;
    cout << a << " " << b << endl;
  }
}

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>
using namespace std;
 
int main()
{
	string a;
	while(cin>>a)
	{
		if(a=="0")break;
		int p[2]={};
		for(int i=0;i<a.size();i++)
		{
			p[a[i]=='B']++;
		}	
		cout<<p[0]<<" "<<p[1]<<endl;
	}
}

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

bool isFinish(int a, int b) {
  return (abs(a-b) >= 2 && (a >= 11 || b >= 11));
}

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

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

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


	for(int i=0;i<3;i++){
	cin>>ta;
	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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string str;
	while(cin>>str,str!="0"){
		int i;
		int a,b;
		a=b=0;
		for(i=1;i<str.size();i++){
			if(str[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(){
 string c;
 while(true){
 cin>>c;
 if(c=="0")
 break;
 int a=0,b=0;
 for(int i=1;i<c.size();i++){
  if(c[i]=='A')
  a++;
  if(c[i]=='B')
  b++;
 }
 if(a>b)
 a++;
 if(b<a)
 b++;
 cout<<a<<" "<<b<<endl;
 }
 return 0;   
}