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 <vector>
#include <string>
using namespace std;

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

C++: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	vector<P> vec;
	while(1){
		string s;
		cin >> s;
		if(s=="0")break;
		if(s[0]=='A'&&!vec.empty())vec.back().fi++;
		else if(s[0]=='B'&&!vec.empty())vec.back().sec++;
		int a = 0,b = 0;
		for(int i=1;i<s.size();i++){
			if(s[i]=='A')a++;
			else b++;
		}
		vec.pb(P(a,b));
	}
	if(vec.back().fi>=10&&vec.back().sec>=10){
		if(vec.back().fi>vec.back().sec)vec.back().fi++;
		else vec.back().sec++;
	}
	else{
		if(vec.back().fi>vec.back().fi)vec.back().fi++;
		else vec.back().sec++;
	}
	for(int i=0;i<vec.size();i++){
		printf("%d %d\n",vec[i].fi,vec[i].sec);
	}
	return 0;
}

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

while(true){
		char g1[101],a;
		cin>>g1;
	if(strcmp(g1,"0")==0){
		break;
	}
	int As=0,Bs=0;
		for(int i=1;g1[i]!='\0';i++){
			a=g1[i];
			if(a=='A'){
				As++;
			}
			else{
				Bs++;
			}
		}
		if(As>Bs){
			As++;
		}
		else{
			Bs++;
		}
		cout<<As<<" "<<Bs<<endl;
		As=0;
		Bs=0;
}

return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void){
	int acnt,bcnt,i,len;
	char str[101];
	while(1){
		acnt=0; bcnt=0;
		cin>>str;
		if(str[0]=='0') break;
		len=strlen(str);
		for(i=1;i<len;i++){
			if(str[i]=='A') acnt++;
			if(str[i]=='B') bcnt++;
		}
		if(acnt>bcnt) acnt++;
		if(acnt<bcnt) bcnt++;
		cout<<acnt<<' '<<bcnt<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  char c;
  string str;
  int cnt = 0;

  while(cin >> str , str != "0"){
    cnt++;
    if(cnt == 4) cnt = 1;

    int len = (int)str.size();
    int a = 0, b = 0;

    for(int i = 1 ; i < len ; i++){
      if(str[i] == 'A'){
	a++;
      }else{
	b++;
      }
    }
    if(a < b){
      cout << a << " " << b+1 << endl;
    }else{
      cout << a+1 << " " << b << endl;
    }
  }

  return 0;
}

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

string r;

int a = 0;
int b = 0;

int main(){
	
	for(int i = 0; i < 20; i++){
		cin >> r;
		if(r != "0"){
			for(int j = 1; j < r.size(); j++){
				if(r[j] == 'A'){
					a++;
				}else{
					b++;
				}				
			}
			
			if(a > b){
				a++;
			}else{
				b++;
			}
			
			cout << a << " " << b << endl;
			a = 0;
			b = 0;
		}else{
			return 0;
		}
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
  
  string game;
  while(cin >> game) {
    if(game == "0") break;
    
    int cntA = 0;
    int cntB = 0;
    
    int const N = game.size();
    for(int i=0; i<N; i++) {
      cntA += game[i] == 'A';
      cntB += game[i] == 'B';
    }
    
    cout << cntA << ' ' << cntB << endl;
    
    for(int I=0; I<2; I++) {
      cin >> game;

      cntA = 0, cntB = 0;

      game = game.substr(1);
      
      int const N = game.size();
      for(int i=0; i<N; i++) {
	cntA += game[i] == 'A';
	cntB += game[i] == 'B';
      }
      
      if(cntA > cntB) cntA++;
      else cntB ++;
      
      /*
      if(game[N-1] == 'A') cntA ++;
      if(game[N-1] == 'B') cntB ++;
      */
      cout << cntA << ' ' << cntB << endl;
      
    }
  }
  
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string save;
	int A = 0, B = 0;
	while (1){
		cin >> save;
		int s = save.size();
		if (save[0] == '0') break;
		for (int i = 1; i < s; i++){
			if (save[i] == 'A') A++;
			else B++;

		}
		if (A > B) A++;
		else B++;
		cout << A << ' ' << B << endl;
		A = B = 0;
	}
	return 0;
}

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

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

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

int main()
{
	string str;
	while(cin >> str){
		if(str[0]=='0')
			break;
		int Ap=0,Bp=0;
		for(unsigned i=1;i<str.size();i++){
			if(str[i] == 'A')
				Ap++;
			else if(str[i] == 'B')
				Bp++;
		}
		if(Ap > Bp)
			Ap++;
		else
			Bp++;
		cout << Ap << " " << Bp << 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>

using namespace std;

int main(){
  char c;
  string str;
  int cnt = 0;

  while(cin >> str , str != "0"){
    cnt++;
    if(cnt == 4) cnt = 1;

    int len = (int)str.size();
    int a = 0, b = 0;

    if(cnt != 1){
      if(c == 'B'){
	a++;
      }else{
	b++;
      }
    }else{
      a = 1;
    }

    for(int i = 1 ; i < len ; i++){
      if(str[i] == 'A'){
	a++;
      }else{
	b++;
      }
    }
    if(a == 10 && b == 1){
      cout << a+1 << " " << b-1 << endl;
    }else if(a == 1 && b == 10){
      cout << a-1 << " " << b+1  << endl;
    }else{
      cout << a << " " << b << endl;
    }
    c = str[len-1];
  }

  return 0;
}

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

using namespace std;
 
int main()
{
    string str;
   
    for (;;) {
	int cntA = 0, cntB = 0;
   
	cin >> str;
	if (str == "0") break;
     
	for (int i = 1; i < (int)str.size(); i++) {
	    if (str[i] == 'A') cntA++;
	    else cntB++;    
	}
     
	if (cntA > cntB) cntA++;
	else cntB++;
     
	cout << cntA << ' ' << cntB << endl;
    }
    return 0;
}

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

while(true){
		string g;
		cin>>g;
	if(g=="0"){
		break;
	}
	int As=0,Bs=0;
		for(int i=1;i<g.size();i++){
			if(g[i]=='A'){
				As++;
			}
			else{
				Bs++;
			}
		}
		if(As>Bs){
			As++;
		}
		else{
			Bs++;
		}
		cout<<As<<" "<<Bs<<endl;
		As=0;
		Bs=0;
}

return 0;
}