#include<iostream>
#include<string>
using namespace std;

bool check(string a,string b){
    bool f1,f2 = false;
    if (a == "rock" || a == "paper" || a == "scissors")
    f1 = true;
    if (b == "rock" || b == "paper" || b == "scissors")
    f2 = true;
    
    return f1 && f2;
}
int win(string a,string b){
    int x = 0;
    if(a == b){
        return 0;
    }
    if(a=="rock" && b == "paper")x=2;
    if(a=="rock" && b == "scissors")x=1;
    if(a=="scissors" && b == "paper")x=1;
    if(a=="scissors" && b == "rock")x=2
    if(a=="paper" && b == "rock")x=1;
    if(a=="paper" && b == "scissors")x=2;
    
    return x;
}
int main(){
    string p1,p2;
    
    cin>>p1;
    cin>>p2;
    
    bool f = check(p1,p2);
    
    if(f){
        int x=win(p1,p2);
        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;
}