Problem:


バドミントン

 A君、Bさん、C君で久しぶりに遊ぶことになりました。 A君とBさんがプレイヤー、C君が審判になりバドミントンのシングルスのゲームをしました。3人で決めたルールは以下の通りです。

3 ゲームを行います。

11 点を先取した人が、そのゲームの勝者となります。

第 1 ゲームの最初のサーブはA君から始まりますが、次のサーブは直前のポイントを取った人が行います。

第 2 ゲーム、第 3 ゲームは前のゲームを取った人が最初のサーブを行います。

10 - 10 になって以降は 2 点差をつけた人が勝者となります。

 全てのゲームが終わり、得点を見ようとしたのですが、審判のC君が得点を記録するのを忘れていました。しかし、サーブを打った人をきちんと記録していました。サーブ順の記録から得点を計算するプログラムを作成してください。ただし、二人が打ったサーブの回数の合計は 100 以下とし、サーブ順の記録は、サーブを打った人を表す "A" または "B" の文字列で表されます。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されま
す。各データセットは以下の形式で与えられます。

record1
record2
record3

i 行目に第 i ゲームのサーブ順を表す文字列が与えられます。

データセットの数は 20 を超えません。

Output

データセット毎に、i 行目に第 i ゲームのA君の得点とBさんの得点を空白区切りで出力してください。

Sample Input

ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBBBBBB
0

Output for the Sample Input

11 8
10 12
11 7
11 8
11 0
0 11



Sample input:
ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBBBBBB
0


Sample output:
11 8
10 12
11 7
11 8
11 0
0 11

Submission status: Accepted

Solution code:
while 1:
  s = raw_input()[1:]
  if s=='': break
  a = [s.count('A'), s.count('B')]
  a[a[0]<a[1]]+=1
  print a[0], a[1]

Submission status: Accepted

Solution code:
while True:
    line = raw_input()
    if line == '0': break
    a = 0
    b = 0
    for re in line[1:]:
        if re == 'A':
            a += 1
        else:
            b += 1
    else:
        if b < a:
            a += 1
        else:
            b += 1
        print a, b

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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);

Submission status: Accepted

Solution code:
# Aizu Problem 00174: Badminton
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def badminton(game):
    a, b = 0, 0
    for x in game[1:]:
        if x == 'A':
            a += 1
        else:
            b += 1
    if a > b:
        a += 1
    else:
        b += 1
    return a, b


while True:
    game = input().strip()
    if game[0] == '0':
        break
    a, b = badminton(game)
    print(a, b)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0174

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):

    while True:
        data = input().strip()
        if data[0] == '0':
            break

        data = data[1:]
        score_A = data.count('A')
        score_B = data.count('B')

        if score_A > score_B:
            score_A += 1
        else:
            score_B += 1
        print('{} {}'.format(score_A, score_B))



if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
from collections import Counter

while True:
    input_item = input()

    if input_item == "0":
        break

    input_list = []
    input_list.append(input_item)
    input_list.append(input())
    input_list.append(input())

    for item in input_list:
        count = Counter(item)
        count[item[0]] -= 1

        if count["A"] > count["B"]:
            count["A"] += 1
        else:
            count["B"] += 1

        print(count["A"], count["B"])

Submission status: Accepted

Solution code:
while True:
    r = input()
    if r == "0":
        break

    A,B = 0,0
    for i in range(1, len(r)):
        if r[i] == "A":
            A += 1
        else:
            B += 1

    if A == 10 and B < 10:
        A += 1
    elif B == 10 and A < 10:
        B += 1
    elif A > B:
        A += 1
    else:
        B += 1

    print(A, B)

Submission status: Accepted

Solution code:
# AOJ 0174 Badminton
# Python3 2018.6.19 bal4u

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

Submission status: Accepted

Solution code:
def judge(r):
  pa = pb = 0
  for c in r[1:]:
    if c == "A":
      pa += 1
    else:
      pb += 1
  if pa < pb:
    print(pa, pb + 1)
  else:
    print(pa + 1, pb)
while True:
  r1 = input()
  if r1 == "0":
    break
  judge(r1)
  judge(input())
  judge(input())

Submission status: Accepted

Solution code:
while True:
    s=raw_input()
    if s=="0":break
    L=[s]+[raw_input() for i in range(2)]
    L[0]=L[0][1:]+L[1][0]
    L[1]=L[1][1:]+L[2][0]
    L[2]=L[2][1:]
    for i in range(3):
        ca,cb=L[i].count("A"),L[i].count("B")
        if i<>2:
            print ca,cb
        else:
            if ca>cb:
                print ca+1,cb
            else:
                print ca,cb+1

Submission status: Accepted

Solution code:
while True:
    s=raw_input()
    if s=="0":break
    L=[s]+[raw_input() for i in range(2)]
    for i in range(3):
        ca,cb=L[i][1:].count("A"),L[i][1:].count("B")
        ca,cb=(ca+1,cb) if ca>cb else (ca,cb+1)
        print ca,cb

Submission status: Accepted

Solution code:
while True:
    try:
        for i in range(3):
            line = raw_input().strip()
            if line == '0':
                raise Exception

            a = b = 0
            for i, s in enumerate(line):
                if i != 0:
                    if s == 'A':
                        a += 1
                    else:
                        b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print a, b

    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        for i in range(3):
            line = raw_input().strip()
            if line == '0':
                raise Exception

            if line[0] == 'A':
                a = -1
                b = 0
            else:
                a = 0
                b = -1
            for i, s in enumerate(line):
                if s == 'A':
                    a += 1
                else:
                    b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print a, b

    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        for i in range(3):
            line = raw_input().strip()
            if line == '0':
                raise Exception

            if line[0] == 'A':
                a, b = (-1, 0)
            else:
                a, b = (0, -1)
            for s in line:
                if s == 'A':
                    a += 1
                else:
                    b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print a, b

    except:
        break

Submission status: Accepted

Solution code:
while True:
    s = raw_input()
    if s == "0":
        break
    n = s[1:].count("A")
    m = s[1:].count("B")
    if n < m:
        print n, m+1
    else:
        print n+1, m

Submission status: Accepted

Solution code:
import sys
while True:
	for i in range(3):
		game = raw_input()
		if game == "0":sys.exit()
		game = game[1:]+game[-1]
		print game.count("A"),game.count("B")

Submission status: Accepted

Solution code:
import sys
while 1:
	for i in range(3):
		g=raw_input()
		if g=="0":sys.exit()
		g=g[1:]+g[-1]
		print g.count("A"),g.count("B")

Submission status: Accepted

Solution code:
while 1:
	g=raw_input()
	if g=="0":break
	g=g[1:]+g[-1]
	print g.count("A"),g.count("B")

Submission status: Accepted

Solution code:
while 1:
	x=input()
	if x=="0":
		break
	a=0
	b=0
	for i in range(1,len(x)):
		if x[i]=="A":
			a+=1
		else:
			b+=1
	if a>b:
		a+=1
	else:
		b+=1
	print(a,b)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n=="0":
        break
    s,t=n[1:].count('A'),n[1:].count('B')
    if s<t:
        print(s+0,t+1)
    else:
        print(s+1,t+0)

Submission status: Accepted

Solution code:
n= True
while True:
    for i in range(3):
        p = list(input())
        if p[0] == '0':
            n= False
            break
        
        a, b = 0, 0
        del p[0]
        for j in p:
            if j == 'A': a += 1
            else: b += 1
        if a > b: a += 1
        else: b += 1
        print(a, b)
    if not n: break

Submission status: Accepted

Solution code:
f=True
while True:
    for i in range(3):
        g=list(input())
        if g[0]=='0':
            f=False
            break
        a,b=0,0
        del g[0]
        for j in g:
            if j =='A':a+=1
            else:b+=1
        if a>b:
            a+=1
        else:
            b+=1
        print(a, b)
    if not f:break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    x = input()
    if x == '0': 
        break
    y = x[1:].count('A')
    z = x[1:].count('B')
    if y < z:
        print(y+0, z+1)
    else:
        print(y+1, z+0)

Submission status: Accepted

Solution code:
while True:
    s=input()
    if s=='0':
        break
    
    A=0
    B=0
    for i in range(1,len(s)):
        if s[i]=='A':
            A+=1
        else:
            B+=1
    if A==10 and B<10:
        A+=1
    elif B==10 and A<10:
        B+=1
    elif A>B:
        A+=1
    else:
        B+=1
    print(A, B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
for i in range(20) :
    n=input()
    if n=='0':
        break
    a=n[1:].count('A')
    b=n[1:].count('B')
    if a>b :
        a=a+1
    else :
        b=b+1
   
    print(a,b)

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n=='0':
        break
    a=list(n)
    A=0
    B=0
    for i in range(1,len(a)):
        if a[i]=='A':
            A+=1
        else:
            B+=1
    if A<=10 and B<=10:
        if A==10:
            A+=1
        if B==10:
            B+=1
    else:
        if A<B:
            B+=1
        else:
            A+=1
    print(A,B)

Submission status: Accepted

Solution code:
import sys
while True:
    a=[]
    for i in range(3):
        z=str(input())
        if z=="0":
            sys.exit()
        a.append(z)
    A,B,C=a[0],a[1],a[2]
    A=A[1:]+B[0]
    B=B[1:]+C[0]
    C=C[1:]
    print(A.count("A"), A.count("B"))
    print(B.count("A"), B.count("B"))
    d,e=C.count("A"),C.count("B")
    if d>e:
        d+=1
    else:
        e+=1
    print(d,e)

Submission status: Accepted

Solution code:
while True:
    s=input()
    if s=="0":
        break
    
    a,b=s[1::].count("A"),s[1::].count("B") #最後の一回以外
    if a<b:  #最後
        x,y=0,1
    else:
        x,y=1,0
    print(a+x,b+y)

Submission status: Accepted

Solution code:
while True:
    n=str(input())
    if n=='0':
        break
    B=len(n)
    N=list(n)
    a=0
    b=0
    for i in range(B-1):
        C=N[i+1]
        if C=='A':
            a=a+1
        else:
            b=b+1
    if a>b:
        a=a+1
    else:
        b=b+1
    print(a,b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
while True:
    r=str(input())
    
    if r=='0':
        break
    A,B=0,0
    for i in range(1,len(r)):
        if r[i]=='A':
            A+=1
        else:
            B+=1
    if A>B:
        A+=1
    else:
        B+=1
    
    print(A,B)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
while True:
    record = input()
    if record == "0":
        break
    
    scoreA = record[1:].count("A")
    scoreB = record[1:].count("B")
    
    if scoreA > scoreB:
        scoreA += 1
    else:
        scoreB += 1
    print(scoreA,scoreB)

Submission status: Accepted

Solution code:
while True:
    record = input()
    if record == "0":
        break
    
    scoreA = record[1:].count("A")
    scoreB = record[1:].count("B")

    if scoreA > scoreB:
        scoreA += 1
    else:
        scoreB += 1
    print(scoreA, scoreB)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n=="0":
        break
    x=list(n)
    a=0
    b=0
    for i in range(len(x)-1):
        if x[i]=="A" and x[i+1]=="A":
            a+=1
        elif x[i]=="B" and x[i+1]=="A":
            a+=1
        elif x[i]=="B" and x[i+1]=="B":
            b+=1
        else:
            b+=1
    if a>=10 and b<10:
        a+=1
    elif b>=10 and a<10:
        b+=1
    elif a>=10 and b>=10:
        if x[len(x)-1]=="A":
            a+=1
        else:
            b+=1
    print(a,b)

Submission status: Accepted

Solution code:
while True:
    record=input()
    if record=='0':
        break
    else:
        A=0
        B=0
        for i in range(1,len(record)):
            if record[i]=='A':
                A+=1
            else:
                B+=1
        if A>B:
            A+=1
        else:
            B+=1
        print(A,B)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# 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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    x = input()
    if x== '0' :
        break
    m=0
    n=1
    a=0
    b=0
    if x[0]=='B':
        (n,m)=(m,n)
    for i in range(len(x)-1):
        if x[i] == x[i+1] :
            a += n
            b += m
        else :
            (n,m) = (m,n)
            a += n
            b += m
    if a>b : a+=1
    else : b+=1
    print(a,b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

while True:
    n = input()
    if n == "0":
        break
    a = n[1:].count("A")
    b = n[1:].count("B")
    if a < b:
        (a1, b1) = (0, 1)
    else:
        (a1, b1) = (1,0)
    print(a+a1, b+b1)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    n = input()
    if n == '0': break
    a = n[1:].count('A')
    b = n[1:].count('B')
    if a < b:
        print(a+0, b+1)
    else:
        print(a+1, b+0)

Submission status: Accepted

Solution code:
while True:
   record=input()
   if record=='0':
       break
   R = record[1:]
   if R.count('A')>R.count('B'):
       print(R.count('A')+1,R.count('B'))
   else:
       print(R.count('A'),R.count('B')+1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
#62 バドミントン

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

Submission status: Accepted

Solution code:
while True:
    ten=input()
    if ten=='0':
        break
    a=ten.count('A')
    b=ten.count('B')
    if ten[0]=='A':
        a-=1
    elif ten[0]=='B':
        b-=1
    if a>b:
        a+=1
    else:
        b+=1
    print(a,b)

Submission status: Accepted

Solution code:
L=[]
A=0
B=0

try:
    while True:
        M=str(input())
        L.append(M)
        
except EOFError:
    pass

N=len(L)
L.remove(L[N-1])
N=len(L)

for i in range(N):
    P=list(L[i])

    P.remove(P[0])
    if i==N-1 or i//3==0:
        A=P.count('A')
        B=P.count('B')
        if A>B:
            A+=1
        else:
            B+=1
        print(A,B)
    
    else:
        A=P.count('A')
        B=P.count('B')
        Q=list(L[i+1])
        if Q[0]=='A':
            A+=1
        else:
            B+=1
        print(A,B)
    
    i+=1

Submission status: Accepted

Solution code:
while True:
    r = input()
    if r == "0":
        break
    m = r.count("A")
    n = r.count("B")
    if r[0] == "A":
        m -= 1
    else:
        n -= 1
    if m > n:
        m += 1
    else:
        n += 1
    print(m,n)

Submission status: Accepted

Solution code:
while True:
    n1=input()
    if n1=="0":
        break
    n2=input()
    n3=input()
    l1=len(n1)
    l2=len(n2)
    l3=len(n3)

    if n1=="0":
        break
    else:
        a1=n1.count("A",1)
        b1=n1.count("B",1)
        if n2[:1]=="A":
            a1+=1
        if n2[:1]=="B":
            b1+=1
        print(a1,b1)
        
        a2=n2.count("A",1)
        b2=n2.count("B",1)
        if n3[:1]=="A":
            a2+=1
        if n3[:1]=="B":
            b2+=1
        print(a2,b2)
        
        a3=n3.count("A",1)
        b3=n3.count("B",1)
        if a3>b3:
            a3+=1
        if a3<b3:
            b3+=1
        print(a3,b3)

Submission status: Accepted

Solution code:
while True:
    a=0
    b=0
    n=input()
    if n=='0':
        break
    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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
  
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);

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    R=str(input())
    if R=='0':
        break
    r=list(R)
    a=0
    b=0
    for i in range(len(r)-1):
        if r[i+1]=='A':
            a+=1
        else:
            b+=1
    if a>b:
        print(a+1,b)
    else:
        print(a,b+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
try:
    while True:
        x = input()
        if x=='0':
            break
        a = 0
        b = 0
        for i in range(1,len(x)):
            if x[i]=='A':
                a = a + 1
            elif x[i]=='B':
                b = b + 1
        if a > b:
            a = a + 1
        elif a < b:
            b = b + 1
        print(a,b)
except EOFError:
    pass

Submission status: Accepted

Solution code:
while True:
    r = str(input())
    if r == '0':
        break
    r = r[1:]
    ten = [r.count('A'),r.count('B')]
    if ten[0] > ten[1]:
        ten[0] += 1
    else:
        ten [1] += 1
    print(ten[0],ten[1])

Submission status: Accepted

Solution code:
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}')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    x = str(input())
    if x == '0':
        break
    x = str(x)
    a = x[1:].count('A')
    b = x[1:].count('B')
    if a < 10:
        b = b + 1
    elif b < 10:
        a = a + 1
    elif a >= 10 and b >= 10 and a > b:
        a = a + 1
    elif a >= 10 and b>= 10 and b > a:
        b = b + 1
    print(a, b)

Submission status: Accepted

Solution code:
while True:
    p = input()
    c = 0
    d = 0
    if p == '0':
        break
    a = len(p)
    for i in range(1,a):
        if p[i] == 'A':
            c += 1
        else:
            d += 1
    if c > d:
        c += 1
    else:
        d += 1
    print(c,d)

Submission status: Accepted

Solution code:
while 1:
    rec = str(input())
    if rec == '0':
        break
    #Rec = list(rec.split())
    
    Acount = rec[1:].count('A')
    Bcount = rec[1:].count('B')
    #print('*', Acount, Bcount)
    
    if Acount < Bcount:
        print(Acount, Bcount+1)
    else:
        print(Acount+1, Bcount)

Submission status: Accepted

Solution code:
while 1:
    x = list(input())
    if x[0] == "0":
        break
    x.pop(0)
    a = x.count("A")
    b = x.count("B")
    if  a > b:
        x.append("A")
    else:
        x.append("B")
    print(x.count("A"),x.count("B"))

Submission status: Accepted

Solution code:
x = 0
y = 0

while True:
    R1 = input()
    if R1 == '0':
        break
    R2 = input()
    R3 = input()
    
    R1A = R1[1:].count('A')
    R1B = len(R1)-R1A-1
    if R2[0]=='A':
        R1A += 1
    else:
        R1B += 1
        
    R2A = R2[1:].count('A')
    R2B = len(R2)-R2A-1
    if R3[0] == 'A':
        R2A += 1
    else:
        R2B += 1
        
    R3A = R3[1:].count('A')
    R3B = len(R3)-R3A-1
    if R3A > R3B:
        R3A += 1
    else:
        R3B += 1
        
    print(R1A, R1B)
    print(R2A, R2B)
    print(R3A, R3B)

Submission status: Accepted

Solution code:
while True:
    re=input()
    if re=="0":
        break
    Are,Bre=0,0
    for i in range(1,len(re)):
        if re[i]=="A":
            Are+=1
        else :
            Bre+=1
    if Are>Bre:
        Are+=1
    else :
        Bre+=1
    print(Are,Bre)

Submission status: Accepted

Solution code:
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
    print(b+d,c+e)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    re=input()
    if re=="0":
        break
    
    a=0
    b=0
    n=len(re)-1
    
    for i in range(n):
        if re[i+1]=="A":
            a+=1
        else:
            b+=1
    
    if a>b:
        a+=1
    else:
        b+=1
    
    print(a, b)

Submission status: Accepted

Solution code:
while True:
    n1=input()
    if n1=="0":
        break
    n2=input()
    n3=input()
    l1=len(n1)
    l2=len(n2)
    l3=len(n3)
    if n1=="0":
        break
    else:
        a1=n1.count("A",1)
        b1=n1.count("B",1)
        if n2[:1]=="A":
            a1+=1
        if n2[:1]=="B":
            b1+=1
        print(a1,b1)
        
        a2=n2.count("A",1)
        b2=n2.count("B",1)
        if n3[:1]=="A":
            a2+=1
        if n3[:1]=="B":
            b2+=1
        print(a2,b2)
        
        a3=n3.count("A",1)
        b3=n3.count("B",1)
        if a3>b3:
            a3+=1
        if a3<b3:
            b3+=1
        print(a3,b3)

Submission status: Accepted

Solution code:
while True:
    g1=input()
    if g1=="0":
        break
    g2=input()
    g3=input()
    r1a=g1[1:].count("A")
    r1b=g1[1:].count("B")
    if g2[0]=="A":
        r1a+=1
    if g2[0]=="B":
        r1b+=1
    print(r1a,r1b)
    r2a=g2[1:].count("A")
    r2b=g2[1:].count("B")
    if g3[0]=="A":
        r2a+=1
    if g3[0]=="B":
        r2b+=1
    print(r2a,r2b)
    r3a=g3[1:].count("A")
    r3b=g3[1:].count("B")
    if r3a>r3b:
        r3a+=1
    if r3a<r3b:
        r3b+=1
    print(r3a,r3b)