Hide

Problem E
Rock, Paper, Scissors

Rock, Paper, Scissors is a classic hand game for two people. Each participant holds out either a fist (rock), open hand (paper), or two-finger V (scissors). If both players show the same gesture, they try again. They continue until there are two different gestures. The winner is then determined according to the table below:

\[ \begin{array}{|c|c|} \hline \text{Rock} & \text{beats Scissors} \\ \hline \text{Paper} & \text{beats Rock} \\ \hline \text{Scissors} & \text{beats Paper} \\ \end{array} \]

Your task is to take a list of symbols representing the gestures of two players and determine how many games each player wins.

Input

The input contains between 1 and 20 pairs of lines, the first for Player 1 and the second for Player 2. Both player lines contain the same number of symbols from the set {‘R’, ‘P’, ‘S’}. The number of symbols per line is between 1 and 75, inclusive. A pair of lines each containing the single character ‘E’ signifies the end of the input.

Output

For each pair of input lines, output a pair of output lines as shown in the sample output, indicating the number of games won by each player.

Sample Input 1 Sample Output 1
RRSRS
SRSPS
PPP
SSS
SPPSRR
PSPSRS
E
E
P1: 1
P2: 1
P1: 0
P2: 3
P1: 2
P2: 1

Please log in to submit a solution to this problem

Log in