Badminton Match Score

Given a rally-by-rally scoring string, replay a best-of-three badminton match and print each completed game's score plus the match winner.

Easy3SimulationStringImplementationInterviewNo attempts yetTime limit1sMemory limit64 MB

Problem

Anisa (player A) and Ben (player B) play a singles badminton match. The rules are:

  • The first player to win 2 games out of 3 wins the match.
  • The first player to reach 21 points wins the game. A different rule applies once both players reach 20 points, but assume that situation never comes up.
  • Either player can score on any rally, no matter who served.
  • When a game ends, the score resets to 0 to 0 and the next game starts.

Input

The first line holds a string made only of A and B. It lists the player who scored on each rally, in order, and it ends with the rally that finished the match.

The length of the string is between 42 and 120. In every game the losing player scores at most 19 points.

Output

Print the score of each game on its own line, in the order the games finished. Each line holds Anisa's points and Ben's points joined by -. For example, print 21-18 when Anisa has 21 points and Ben has 18.

On the last line print the winner of the match, A or B.