// editor3
#include <iostream>
#include <string>
using namespace std;

bool check(string sa, string sb)
{
    bool f1 = false, f2 = false;
    if(sa == "rock" || sa == "paper" || sa == "scissors")
    f1 = true;
    if(sb == "rock" || sb == "paper" || sb == "scissors")
    f2 = true;
    
    return f1&&f2;
}

int win(string sa, string sb)
{
    int x = 0;
    if(sa == sb)
    {
        return 0;
    }
    if(sa == "rock" && sb == "paper")
    x = 2;
    if(sb == "rock" && sa == "paper")
    x = 1;
    if(sa == "paper" && sb == "scissors")
    x = 2;
    if(sb == "paper" && sa == "scissors")
    x = 1;
    if(sa == "paper" && sb == "rock")
    x = 1;
    if(sb == "paper" && sa == "rock")
    x = 2;
    
    return x;
    
}

int main()
{
    string s1, s2;
    
    cin >> s1;
    cin >> s2;
    
    s1.tolowercase();
    s2.tolower();
    bool f = check(s1, s2);
    
    if(f)
    {
        int x = win(s1, s2);
        if(x == 0)
        cout << "TIE";
        else if(x == 1)
        cout << "Player 1 wins";
        else if(x == 2)
        cout << "Player 2 wins";
        
    }
    else
    cout << "Invalid input";
    
    return 0;
}