#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    string Player1Move,Player2Move;
    cin >> Player1Move;
    cin >> Player2Move;
    transform(Player1Move.begin(),Player1Move.end(),
             Player1Move.begin(), ::tolower);
    transform(Player2Move.begin(),Player2Move.end(),
             Player2Move.begin(), ::tolower);    
    if((Player1Move != "rock" && Player1Move != "paper" && Player1Move != "scissors")||
       (Player2Move != "rock" && Player2Move != "paper" && Player2Move != "scissors"))
       {
           cout << "Invalid input";
       }
       else if((Player1Move == (Player2Move)
       {
           cout << "Tie";
       }
       else if((Player1Move == "rock" && Player2Move == "scissors")||
               (Player1Move == "scissors" && Player2Move == "paper")||
               (Player1Move == "paper" && Player2Move == "rock"))
               {
                   cout << "Player 1 wins";
               }
               else 
               {
                   cout << "player 2 wins";
               }
               return 0;
}