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 <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int apoint[3],bpoint[3];
string data[3];
int main(void)
{
  while(cin >> data[0] && data[0]!="0")
    {
      memset(apoint,0,sizeof(apoint));
      memset(bpoint,0,sizeof(bpoint));
      data[0]+='C';
      cin >> data[1];
      data[1]+='C';
      cin >> data[2];
      data[2]+='C';
      for(int i=0;i<3;i++)
	{
	  for(int j=0;j<int(data[i].size()-1);j++)
	    {
	      if(data[i][j+1]!='C')
		{
		  if(data[i][j+1]=='A')
		    {
		      apoint[i]++;
		    }
		  else bpoint[i]++;
		}
	      else
		{
		  if(i!=2)
		    {
		      if(data[i+1][0]=='A') apoint[i]++;
		      else bpoint[i]++;
		    }
		  else
		    {
		      if((apoint[i]+1-bpoint[i])>=2) apoint[i]++;
		      else bpoint[i]++;
		    }
		}
	    }
	}
      for(int i=0;i<3;i++)
	{
	  cout << apoint[i] << ' ' << bpoint[i] << endl;
	}
    }
  return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
int main(){
char bad[101];
cin >> bad;
int a,b;
while(bad[0]!=0&&bad[1]!='\0'){
 a=0;b=0;
 for(int i=1;i<101;i++){
      if(bad[i]=='A'){
            a++;
       }else if(bad[i]=='B'){
            b++;
        }
  }
  if(bad[0]=='A'){
    a++;
  }else if(bad[0]=='B'){
    b++;
  }
  cout << a << ' ' << b << endl;
  for(int k=0;k<101;k++){
      bad[k]='\0';
  }
  cin >> bad;
}

return 0;
}

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

using namespace std;


int main() {
	int len,sumA,sumB;
	string r;

	while (1) {
		cin >> r;
		len = r.size();
		if (len == 1) {
			break;
		}

		sumA = sumB = 0;
		for (int index = 1; index < len; index++) {
			if (r[index] == 'A') {
				sumA++;
			}
			else {
				sumB++;
			}
		}

		if (sumA > sumB) {
			sumA++;
		}
		else {
			sumB++;
		}
		cout << sumA << " " << sumB << endl;
	}

	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()
{
	auto cur = read<string>();
	while (true)
	{
		auto next = read<string>();
		auto a = count(cur.begin() + 1, cur.end(), 'A');
		auto b = count(cur.begin() + 1, cur.end(), 'B');

		char c = next[0];
		if (c == 'A') { a++; }
		else if (c == 'B') { b++; }
		else { (a > b ? a : b)++; };
		write(a, b);
		cur = next;
		if (c == '0') { break; }
	}
}

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'==0){
      if(as>bs) as++;
      else bs++;
    }
    else if(f=='A') as++;
    else bs++;
    cout << as << ' ' << bs << endl;
  }
  return 0;
}

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++: #include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  string l[22];
  int count=0;
  for(int i=0;i<20;i++){
    string s;
    cin>>s;
    if(s=="0"){
      break;
    }
    else{
      l[i]=s;
      count++;
    }
  }
  char is='x';
  rep(i,count){
    int a,b;
    a=stringcount(l[i],'A');
    b=stringcount(l[i],'B');
    if(a>b) is=a;
    if(a<b) is=b;
    if(a==b){
      string e=l[i];
      reverse(all(e));
      if(e[0]=='A') {
        a++;b--;
      }
      else{
        b++;a--;
      } 
    }
    if(a<11&&b<11){
      if(a>b){
        a++;b--;
      }
      else{
        b++;a--;
      }
    }
    cout<<a<<" "<<b<<endl;
  }
  return 0;

}