import scala.io.StdIn.readLine

object Main {
  def play(s:String) = {
    val r = (0 until s.length).foldLeft((0,0)){ (x,y) =>
      if(s(y)=='A') (x._1+1,x._2) else (x._1,x._2+1)
    }
    r._1 + " " + r._2
  }

  def main(args:Array[String]) = {
    var s1 = "0"
    while({s1=readLine.trim;s1} != "0") {
      val s2 = readLine.trim
      val s3 = readLine.trim
      println(play(s1.drop(1)+s2(0)))
      println(play(s2.drop(1)+s3(0)))
      val a = s3.drop(1).count(_=='A')
      val b = s3.drop(1).count(_=='B')
      val c = if(a>b) 'A' else 'B'
      println(play(s3.drop(1)+c))
    }
  }

}