#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" && player2Move != "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") 
    || (palyer1Move == "paper" && player2Move == "rock"))
    {
        cout<< "Player 1 wins";
    }else
    {
        cout << "Player 2 wins";
    }
    return 0;
}