import java.util.*;
public class Main{
public static void main(String [] args)
{
Scanner cin = new Scanner( System.in);
int test;
test = cin.nextInt();
while ( test > 0)
{
test -- ;
String s = cin.next();
String t = cin.next();
char a[] = s.toCharArray();
int hp1 = 0 , hp2 = 0 , str1 = 1 , str2 = 1 , spd1 = 0 , spd2 = 0 ;
for ( int i = 0 ; i < s.length(); i ++ )
{
hp1 = ( hp1 + (83 - (int)s.charAt(i))*(83 - (int)s.charAt(i))) % 97 ;
str1 = ( str1 * (int)s.charAt(i) ) % 79 ;
for ( int j = i + 1 ; j < s.length() ; j ++ )
{
spd1 = ( spd1 + (int)a[j] * (int)a[i])%11 ;
}
}
str1 += 22 ;
hp1 = 300 - hp1 ;
for ( int i = 0 ; i < t.length(); i ++ )
{
hp2 = ( hp2 + (83 - (int)t.charAt(i))*(83 - (int)t.charAt(i))) % 97 ;
str2 = ( str2 * (int ) t.charAt(i))%79;
for ( int j = i + 1 ;j < t.length() ; j ++ )
{
spd2 = ( spd2 + (int ) t.charAt(j) * (int ) t.charAt(i))%11 ;
}
}
str2 += 22;
hp2 = 300 - hp2 ;
int t1 = hp2 / str1 ;
if ( hp2 % str1 != 0 )
t1 ++ ;
int t2 = hp1 / str2 ;
if ( hp1 % str2 != 0 )
t2 ++ ;
t1 *= ( 20 - spd1 );
t2 *= ( 20 - spd2 );
if ( t1 == t2 )
System.out.println("tie");
else
System.out.println((t1<t2?"win":"lose"));
}
}
}
posted on 2009-08-18 19:33
Huicpc217 阅读(193)
评论(0) 编辑 收藏 引用 所属分类:
JAVA