Under construction

Still being built. Things may change

Two Hands

Interview

Time limit0.1sMemory limit128 MB

Summary
Given two players' left and right hand gestures, determine which player can guarantee a win with a well-chosen hand, or output '?' if neither can force a win.
Level

Easy3 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Problem

Minsung and Taekyung are the best rock-paper-scissors players at Korea University. Tired of the ordinary game, they have reached the level of playing rock-paper-scissors with both hands.

First, the two shout "rock, paper, scissors" at the same time and reveal both hands, each set to one of rock, paper, or scissors. Right there they take 3 seconds to steady their breathing, then simultaneously decide whether to play the left hand or the right hand. Because of the pressure of a match between top players, Minsung and Taekyung sometimes lose their judgment and may accidentally make the same gesture with the left and right hands.

Given the states of Minsung's and Taekyung's left and right hands, you want to determine whether Minsung or Taekyung can choose the left or right hand appropriately and win the rock-paper-scissors match no matter what.

Input

The first line gives ML, MR, TL, TR separated by spaces. They represent, in order, the states of Minsung's left hand, Minsung's right hand, Taekyung's left hand, and Taekyung's right hand.

Each of the 4 values is one of "S", "R", "P", meaning scissors, rock, and paper respectively.

Output

On the first line, print "MS" if Minsung can win no matter what, "TK" if Taekyung can win no matter what, or "?" if it cannot be determined who will win, without the double quotes.

In rock-paper-scissors, scissors beats paper, rock beats scissors, and paper beats rock. The same gesture does not produce a winner (it is a tie).

Examples3

  1. Example 1

    Input
    R S P R
    
    Expected output
    ?
    
  2. Example 2

    Input
    R R S S
    
    Expected output
    MS
    
  3. Example 3

    Input
    P P S R
    
    Expected output
    TK