Most people probably know the game rock-paper-scissors where two players count down and simultaneously form either a rock (fist), a pair of scissors (two outstretched fingers) or a piece of paper (outstretched hand) with their hands. Rock beats scissors, scissors beat paper and paper beats rock. If both players make the same choice, the game ends in a draw.

Sam Kass and Karen Bryla invented an extension of the classic selection game, and called it rock-paper-scissors-lizard-Spock. It operates on the same basic principle, but includes two additional weapons: the lizard (formed by the hand as a sock-puppet-like mouth) and Spock (formed by the Vulcan salute1 from the Star Trek series). This reduces the chances of a round ending in a tie (from 1/3 to 1/5). The game was mentioned in four episodes of television series The Big Bang Theory2.

In the game rock-paper-scissors-lizard-Spock each player picks a hand-shape, then both players reveal their choices at the same time. The winner is the one who defeats the other. The rules of rock-paper-scissors-lizard-Spock are:

There are fifteen possible pairings of the five gestures. Each gesture beats two of the other gestures and is beaten by the remaining two. In a tie, the process is repeated until a winner is found. The original rules (rock beats scissors, scissors beats paper, paper beats rock) remain the same in the extended version of the game.

Graphical representation of the rules of rock-paper-scissors-lizard-Spock, displaying clockwise from top: scissors, paper, rock, lizard and Spock.


The input consists of two lines that each contain the name of a hand gesture that is respectively shown by player1 and player2 in a game of rock-paper-scissors-lizard-Spock: paper, rock, lizard, Spock or scissors.


The output consists of a single line that indicates which player wins the game. This line must contain one of the following descriptions:

Try to restrict the number of conditions that must be checked when deciding which player wins the game.





player2 wins