while true
    record1 = gets.chomp
    break if record1 == "0"
    record2 = gets.chomp
    record3 = gets.chomp
    game1 = record1[1..-1] + record2[0]
    game2 = record2[1..-1] + record3[0]
    game3 = record3[1..-1] + (record3[1..-1].count("A") > record3[1..-1].count("B") ? "A" : "B")

    puts "#{game1.count("A")} #{game1.count("B")}"
    puts "#{game2.count("A")} #{game2.count("B")}"
    puts "#{game3.count("A")} #{game3.count("B")}"
end
