Save Middle Earth 
Difficulty: Hard

Frodo Baggins is on his mission to destroy The One Ring. He has entered the deadly Shelob's lair and is now challenged by the mighty spider Shelob. Both Frodo and Shelob get equal number of swords of varying lengths which are stacked behind them.

The challenge is this: Both of them pull out their topmost sword. The lengths of both their swords are compared. Whoever has a longer sword gets a point.
If the sword lengths are equal noone gets a point. Moreover, if the length of the longer sword is a prime number then the person having the longer sword gets 10 extra points. Also, if the length of the shorter sword is any root of the longer sword then the person having the longer sword gets 10 more points.

The end of the input is indicated by **2 zeroes**. After all the swords have been compared, if Frodo has higher points than Shelob, he will get to escape her lair and move on towards Mount Doom to destroy the ring.

Your job is simple. Find out who wins each round. Print the **player number**. Also print the **number of points** the winner has. If both Frodo and Shelob have equal number of points print **Tie**.

###Input 
The input consists of N pairs of numbers indicating the sword length of player 1 and 2 respectively.

###Ouput

The output should be 2 numbers separated by a space. The first number indicates the winner. Second number should be the points obtained by him.

If both the players have equal number of point then the output should be "Tie" (Quotes only for clarity).

###Constraints

- 1 <= N <= 1000
- 1 <= sword length <= 1000 

###Sample Input

12 10

2 5

6 36

19 7

0 0

###Sample Ouput 

2 22

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
    //CSI OPC
    //SIMPLE SEARCH

    #include<stdio.h>
    #include<iostream>
    #include<math.h>

    using namespace std;

    bool isprime(int n)
    {
        int c=0;

        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
                c++;

            if(c>0)
                break;
        }
        if(c>0)
            return false;

        else
            return true;
    }
    bool ispower(int x, int y)
    {
        int flag=1, j=y, num=0;
        while(j>x)
        {
            if(j%x!=0)
            {
                flag=0;
                break;
            }
            j=j/x;
            num++;
        }
        if(pow(x,num+1)==y)
        	flag=1;
        else
        	flag=0;

        if(flag)
            return true;
        else
            return false;
    }
    int main()
    {
        int a, b, flag1=0, flag2=0, pointA=0, pointB=0, flag3=0, flag4=0;

        cin>>a>>b;

        while(a!=0 && b!=0)
        {
            flag1=0;
            flag2=0;
            flag3=0;
            flag4=0;

            if(isprime(a))
                flag1=1;

            if(isprime(b))
                flag2=1;

            if(a<b)
            {
                if(a!=1 && ispower(a,b))
                    flag4=1;

                pointB+=1;

                if(flag2==1)
                    pointB+=10;

                if(flag4==1)
                    pointB+=10;
            }
            if(b<a)
            {
                if(b!=1 && ispower(b,a))
                    flag3=1;

                pointA+=1;

                if(flag1==1)
                    pointA+=10;

                if(flag3==1)
                    pointA+=10;
            }
            cin>>a>>b;
        }

        if(pointA>pointB)
            cout<<1<<" "<<pointA<<endl;
        else if(pointA<pointB)
            cout<<2<<" "<<pointB<<endl;
        else
            cout<<"Tie"<<endl;
    }