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
		}
	}
}

Python: def calc(S):
    p = q = 0
    for c in S[1:]:
        if c == 'A':
            p += 1
        else:
            q += 1
    return p, q
def check(p, q):
    if q < 10:
        return p == 11
    return p - q == 2

while 1:
    S1 = input()
    if S1 == "0":
        break
    S2 = input()
    S3 = input()

    p1, q1 = calc(S1)
    if S2[0] == 'A':
        p1 += 1
    else:
        q1 += 1
    print(p1, q1)

    p2, q2 = calc(S2)
    if S3[0] == 'A':
        p2 += 1
    else:
        q2 += 1
    print(p2, q2)

    p3, q3 = calc(S3)
    if check(p3+1, q3):
        print(p3+1, q3)
    else:
        print(p3, q3+1)

Python: while True:
    a = input()
    if a == '0':
        break
    b, c = a[1:].count('A'), a[1:].count('B')
    if b < c:
        d, e = 0, 1
    else:
        d, e = 1, 0
    Ap = b+d
    Bp = c+e
    print(Ap,Bp)

Python: while 1:
    a=input()
    if a=='0':break
    d=a[1:].count('A')
    e=a[1:].count('B')
    if d<e:
        b=0
        c=1
    else:
        b=1
        c=0
    print(d+b,e+c)

Python: while True :
    score = input()
    if score == "0" :
        break
    
    score_a = score.count("A")
    score_b = score.count("B")
    if score[0] == "A" :
        score_a -= 1
    elif score[0] == "B" :
        score_b -= 1
    if score_a > score_b :
        score_a += 1
    else :
        score_b += 1
    print(score_a, score_b)

Python: while True :
    d1 = input()
    
    if d1 == "0" :
        break
    else :
        d2 = input()
        d3 = input()
        
        d1A = d1[1 : len(d1)].count("A")
        d1B = len(d1) - d1A - 1
        if d2[0] == "A" :
            d1A += 1
        else :
            d1B += 1
            
        d2A = d2[1 : len(d2)].count("A")
        d2B = len(d2) - d2A - 1
        if d3[0] == "A" :
            d2A += 1
        else :
            d2B += 1
            
        d3A = d3[1 : len(d3)].count("A")
        d3B = len(d3) - d3A - 1
        if d3A >= 10 and d3B >= 10 :
            if d3A > d3B :
                d3A += 1
            else :
                d3B += 1
        else :
            if d3A > d3B :
                d3A += 1
            else :
                d3B += 1
        
        print(d1A, d1B)
        print(d2A, d2B)
        print(d3A, d3B)

Python: while True:
    s = input()
    if s == '0': break
    s = [s] + [input() for _ in range(2)]
    for i, m in enumerate(s):
        a=b=0
        for n in m[1:]:
            if n == 'A':
                a += 1
            else:
                b += 1
        if i != 2:
            ab = s[i+1][0]
            if ab == 'A':
                a += 1
            else:
                b += 1
            A, B = ('A', a), ('B', b)
            AB = sorted([A, B])
            A, B = AB[0][1], AB[1][1]
            print(A, B)
        else:
            A, B = ('A', a), ('B', b)
            AB = sorted([A, B], key=lambda x: x[1])
            if AB[1][0] == 'A':
                A, B = AB[1][1] + 1, AB[0][1]
            else:
                A, B = AB[0][1], AB[1][1] + 1
            print(A, B)

Python: while True:
    d = input()
    if d == '0':
        break
    D = list(d)
    A_t = 0
    B_t = 0
    for i in range(1,len(D)):
        if D[i] == "A":
            A_t += 1
        elif D[i] == "B":
            B_t += 1
    if A_t > B_t:
        A_t += 1
    elif A_t < B_t:
        B_t += 1
    print(A_t, B_t)

Python: while True:
    l=str(input())
    if l=="0": break
    A,B = 0,0
    for i in range(1,len(l)):
        if l[i]=="A":
            A+=1
        else:
            B+=1
    if A>B:
        A+=1
    else:
        B+=1
    print(A,B)

Python: while True:
    s=input()
    if s=='0':
        break
    else:
        s2=input()
        s3=input()
        p=[s,s2,s3]
        for i in range(3):
            a=0
            b=0
            for k in range(1,len(p[i])):
                if p[i][k]=='A':
                    a+=1
                else:
                    b+=1
            if i==2:
                if a>b:
                    a+=1
                else:
                    b+=1
            
            else:    
                if p[i+1][0]=='A':
                    a+=1
                else:
                    b+=1
            print(a,b)

Python: while 1:
  a = input()
  if a == '0': break
  m = a[1:].count('A')
  n = a[1:].count('B')
  (r,s) = (0,1) if m < n else (1,0)
  print(m+r, n+s)

Python: while True:
    record=input()
    if record=="0":
        break
    a=record.count('A')
    b=record.count('B')
    if record[0]=='A':
        a-=1
    elif record[0]=='B':
        b-=1
    if a>b:
        a+=1
    else:
        b+=1
    print(f'{a} {b}')

Python: while True:
    n=input()
    if n=='0':
        break

    m=input()
    l=input()
    
    x=[]
    x.append(n)
    x.append(m)
    x.append(l)
    
    for i in range(3):
        if i==0:
            a=-1
            b=0
        elif i==1:
            if n[-1]=='A':
                a=-1
                b=0
            elif n[-1]=='B':
                a=0
                b=-1
        elif i==2:
            if m[-1]=='A':
                a=-1
                b=0
            elif m[-1]=='B':
                a=0
                b=-1
        
        for j in x[i]:
            if j=='A':
                a+=1
            elif j=='B':
                b+=1
        if a>b:
            a+=1
        elif b>a:
            b+=1
            
        print(a,end=' ')
        print(b)

Python: while True:
    a = input()
    if a == '0':
        break
    A = a[1:].count('A')
    B = a[1:].count('B')
    if  A<B:
        c = 0
        e = 1
    else:
        c = 1
        e = 0
    print(A+c,B+e)

Python: f = True
while True:
	for k in range(3):
		p = list(input())
		if p[0] == '0':
			f = False
			break
		a, b = 0, 0
		del p[0]
		for x in p:
			if x == 'A': a += 1
			else: b += 1
		if a > b: a += 1
		else: b += 1
		print(a, b)
	if not f: break

Python: while True:
	str = input();
	if (str == '0'):
		break;
	
	scorea = 0;
	scoreb = 0;
	for i in range(1, len(str)):
		if (str[i] == 'A'):
			scorea += 1;
		else:
			scoreb += 1;
	
	if (scorea > scoreb):
		scorea += 1;
	else:
		scoreb += 1;
	
	print(scorea, scoreb);

Python: # coding: utf-8
# Your code here!
while True:
    x=str(input())
    if x=="0":
        break
    xx=len(x)
    a=0
    b=0
    for i in range(1,xx):
        if x[i]=='A':
            a+=1
        else:
            b+=1
    if a>b:
        a+= 1
    else:
        b+= 1    
    print(a,b)

Python: while True:
    r=input()
    if r=='0':
        break
    a=0
    b=0
    a=r[1:].count('A')
    b=r[1:].count('B')
    if a>b:
        a+=1
    else:
        b+=1
    print(a,b)

Python: while True:
    score=input()
    if score=='0':
        break
    
    score_a=score.count('A')
    score_b=score.count('B')
    if score[0]=='A':
        score_a-=1
    elif score[0]=='B':
        score_b-=1
    if score_a>score_b:
        score_a+=1
    else:
        score_b+=1
    print(score_a,score_b)

Python: while True:
    n=input()
    if n=='0': break
    a,b=0,0
    for i in range(1,len(n)):
        if n[i]=='A':
            a+=1
        else:
            b+=1
    if a>b:
        a+=1
    else:
        b+=1
    print(a,b)

Python: while True:
    r = input()
    
    if r =="0":
        break
    
    a = r[1:].count('A')
    b = r[1:].count('B')
    
    if a > b:
        print(a+1,b)
        
    else:
        print(a,b+1)