In Snakeland, there are some snakes and mongooses. They are lined up in a row. The information about how exactly they are lined up it is provided to you by a string of length n. If the i-th character of this string is 's', then it means that there is a snake at the i-th position, whereas the character 'm' denotes a mongoose.
You might have heard about the age-old rivalry between hares and tortoises, but in Snakeland, the rivalry between snakes and mongooses is much more famous. The snakes and the mongooses want to hold a final poll in which the ultimate winner of this age-old battle will be decided. If the snakes get more votes than the mongooses, they will be the ultimate winners. Similarly, if the mongooses get more votes than snakes, they will be the ultimate winners. Obviously, each animal is loyal to their species, i.e. each snake will vote for the snakes to be the ultimate champions and each mongoose for the mongooses.

Tomorrow's the election day. Before the elections, the mongooses decided to cheat. They planned that each mongoose will eat at most one of its neighbor snakes. Two animals are said to be neighbors of each other if they are consecutive to each other in the row. After this, the elections will be held. The mongooses planned in such a way that the number of snakes eaten is maximized. Can you find out who will win the final poll? Output "snakes", "mongooses" or "tie" correspondingly.

-----Input-----
First line of the input contains an integer T denoting the number of test cases. The description of T test cases follow.
The only line of each test case contains a string consisting of characters 's' and 'm'. 

-----Output-----
For each test case output a single line containing "snakes", "mongooses" or "tie" correspondingly (without quotes).

-----Constraints-----
- 1 ≤ T ≤ 100
- 1 ≤ |s| ≤ 100

-----Example-----
Input
4
sm
ssm
sms
ssmmmssss

Output
mongooses
tie
tie
snakes

-----Explanation-----
Example 1. The mongoose will eat the snake. Only the mongoose will be left. So, on the election day, there is one mongoose and zero snakes. So mongooses will win.
Example 2. The mongoose will eat the snake at position 2 (1-based indexing). One mongoose and one snake will be left. Hence, there will be a tie.
Example 3. The mongoose can eat either the snake to its left or to the right. But, it can eat only one of them. Afterwards, there will be a single snake and mongoose. So, it will result in a tie. 
Example 4. The mongooses can eat at max two snakes. For example, s*mmm*sss, where * denotes the snakes that were eaten by mongooses. After this, we have four snakes and three mongooses. So, the snakes win.

Difficulty: interview

Starter code:

Solutions:
for i in range(int(input())):
 a=input()
 c=a.count('m')
 d=a.count('s')
 t=0
 while t<len(a)-1:
  if (a[t]=='m' and a[t+1]=='s') or (a[t]=='s' and a[t+1]=='m'):
   d=d-1
   t=t+2
  else:
   t=t+1
 if c>d:
  print('mongooses')
 elif d>c:
  print('snakes')
 else:
  print('tie')


for t in range(int(input())):
 s=input()
 x=s.count('m')
 y=s.count('s')
 i=0
 while i<len(s)-1:
  if (s[i]=='m' and s[i+1]=='s') or (s[i]=='s' and s[i+1]=='m'):
   y=y-1
   i=i+2
  else:
   i=i+1
 if x>y:
  print("mongooses")
 elif y>x:
  print("snakes")
 else:
  print("tie")

for t in range(int(input())):
 s=input()
 x=s.count('m')
 y=s.count('s')
 i=0
 while i<len(s)-1:
  if (s[i]=='m' and s[i+1]=='s') or (s[i]=='s' and s[i+1]=='m'):
   y=y-1
   i=i+2
  else:
   i=i+1
 if x>y:
  print("mongooses")
 elif y>x:
  print("snakes")
 else:
  print("tie")

# cook your dish here
for i in range(int(input())):
 x=input()
 c=x.count('s')
 d=x.count('m')
 i=0
 while i<len(x)-1:
  if x[i]=='s' and x[i+1]=='m' or x[i]=='m' and x[i+1]=='s':
   i+=2
   c-=1
  else:
   i+=1
 if c>d:
  print("snakes")
 elif d>c:
  print("mongooses")
 else:
  print("tie")

# cook your dish here
for i in range(int(input())):
 a=str(input())
 s=a.count('s')
 m=a.count('m')
 j=0
 while j<len(a)-1:
  if a[j]=='s' and a[j+1]=='m' or a[j]=='m' and a[j+1]=='s':
   j+=2
   s-=1
  else:
   j+=1
 if s>m:
  print("snakes")
 elif m>s:
  print("mongooses")
 else:
  print("tie")

T=int(input())
for i in range(T):
 S=str(input())
 c=S.count('s')
 d=S.count('m')
 j=0
 while j<len(S)-1:
  if S[j]=='s' and S[j+1]=='m' or S[j]=='m' and S[j+1]=='s':
   j+=2
   c-=1
  else:
   j+=1
 if c>d:
  print("snakes")
 elif d>c:
  print("mongooses")
 else:
  print("tie")


T=int(input())
for i in range(T):
 S=str(input())
 c=S.count('s')
 d=S.count('m')
 j=0
 while j<len(S)-1:
  if S[j]=='s' and S[j+1]=='m' or S[j]=='m' and S[j+1]=='s':
   j+=2
   c-=1
  else:
   j+=1
 if c>d:
  print("snakes")
 elif d>c:
  print("mongooses")
 else:
  print("tie")

for t in range(int(input())):
 s=input()
 x=s.count('m')
 y=s.count('s')
 i=0
 while i<len(s)-1:
  if (s[i]=='m' and s[i+1]=='s') or (s[i]=='s' and s[i+1]=='m'):
   y=y-1
   i=i+2
  else:
   i=i+1
 if x>y:
  print("mongooses")
 elif y>x:
  print("snakes")
 else:
  print("tie")

for t in range(int(input())):
 s=input()
 x=s.count('m')
 y=s.count('s')
 i=0
 while i<len(s)-1:
  if (s[i]=='m' and s[i+1]=='s') or (s[i]=='s' and s[i+1]=='m'):
   y=y-1
   i=i+2
  else:
   i=i+1
 if x>y:
  print("mongooses")
 elif y>x:
  print("snakes")
 else:
  print("tie")

for _ in range(int(input())):
 a = list(input())
 
 for i in range(len(a)-1):
  if a[i]=='s':
   if a[i+1]=='m':
    a[i] = 'd'
    a[i+1] = 'e'
  elif a[i]=='m':
   if a[i+1]=='s':
    a[i+1] = 'd'
    a[i] = 'e'
 
 votes = 0
 for creature in a:
  if creature == 'm' or creature == 'e':
   votes += 1
  elif creature == 's':
   votes -= 1
  
 if votes>0:
  print("mongooses")
 elif votes<0:
  print("snakes")
 else:
  print("tie")

for h in range(int(input())):
 s=input()
 mc=s.count('m')
 l=list(s)
 k=0
 for i in range(len(l)):
  if(l[i]=='m'):
   if l[i-1]=='s' and i>0:
     l[i-1]='0'
     
   elif(i<(len(s)-1))and l[i+1]=='s': 
    l[i+1]='0'
  
 sc=l.count('s')

 if mc>sc:
  print('mongooses')
 elif sc>mc:
  print('snakes')
 else:
  print('tie')

# cook your dish here
# T = int(input())
# while T>0:
#     s = list(input())
#     l = len(s)
#     for i in range(l):
#       if s[i]=='m' and i>0 and s[i-1]=='s':
#           s[i-1]='*'
#       elif s[i]=='m' and i<l-1 and s[i+1]=='s':
#           s[i+1]='*'
#     a=s.count('s')
#     b=s.count('m')
#     if a>b:
#         print("snakes")
#     elif b>a:
#         print("mangooses")
#     else:
#         print("tie")
#     T-=1

for h in range(int(input())):
 s=input()
 mc=s.count('m')
 l=list(s)
 k=0
 for i in range(len(l)):
  if(l[i]=='m'):
   if l[i-1]=='s' and i>0:
     l[i-1]='0'
     
   elif(i<(len(s)-1))and l[i+1]=='s': 
    l[i+1]='0'
  
 sc=l.count('s')

 if mc>sc:
  print('mongooses')
 elif sc>mc:
  print('snakes')
 else:
  print('tie')

t = int(input())
for _ in range(t):
 string = input()
 string = list(string)
 for i in range(len(string)):
  if string[i]=='m' and i>0 and string[i-1]=='s':
   string[i-1] = 'x'
  elif string[i]=='m' and i<len(string)-1 and string[i+1]=='s':
   string[i+1] = 'x'
 s_count = 0
 m_count = 0
 for i in range(len(string)):
  if string[i] == 's':
   s_count += 1
  elif string[i] == 'm':
   m_count += 1
 if s_count > m_count:
  print('snakes')
 elif m_count > s_count:
  print('mongooses')
 else:
  print('tie')

# cook your dish here
t=int(input())
while t>0:
 s=list(input())
 l=len(s)
 for i in range(l):
  if s[i]=='m' and i>0 and s[i-1]=='s':
   s[i-1]='*'
  elif s[i]=='m' and i<l-1 and s[i+1]=='s':
   s[i+1]='*'
 c=s.count('s')
 d=s.count('m')
 if c>d:
  print("snakes")
 elif d>c:
  print("mongooses")
 else:
  print("tie")
 t-=1

t=int(input())
for i in range(t):
 a=list(input())
 for i in range(len(a)):
  if a[i]=='m' and i>0 and a[i-1]=='s':
   a[i-1]='*'
  elif a[i]=='m' and i<len(a)-1 and a[i+1]=='s':
   a[i+1]='*'
 d=a.count('s')
 c=a.count('m')
 if c>d:
  print("mongooses")
 elif d>c:
  print("snakes")
 else:
  print("tie")

# cook your dish here
for h in range(int(input())):
 s=input()
 mc=s.count('m')
 l=list(s)
 k=0
 for i in range(len(l)):
  if(l[i]=='m'):
   if l[i-1]=='s' and i>0:
     l[i-1]='0'
     
   elif(i<(len(s)-1))and l[i+1]=='s': 
    l[i+1]='0'
  
 sc=l.count('s')

 if mc>sc:
  print('mongooses')
 elif sc>mc:
  print('snakes')
 else:
  print('tie')


for _ in range(int(input())):
 string = list(input())
 s = string.count('s')
 m = string.count('m')
 for i in range(len(string)-1):
  if (string[i],string[i+1]) in (('m','s'),('s','m')):
   string[i]='d'
   string[i+1]='d'
   s-=1
 print('mongooses') if m>s else print('snakes') if s>m else print('tie')

# cook your dish here
t=int(input())
for i in range(t):
 a=list(input())
 for i in range(len(a)):
  if a[i]=='m' and i>0 and a[i-1]=='s':
   a[i-1]='*'
  elif a[i]=='m' and i<len(a)-1 and a[i+1]=='s':
   a[i+1]='*'
 d=a.count('s')
 c=a.count('m')
 if c>d:
  print("mongooses")
 elif d>c:
  print("snakes")
 else:
  print("tie")



# cook your dish here
try:
 for _ in range(int(input())):
  S=list(input())
  for i in range(len(S)):
   if S[i]=="m" and i>0 and S[i-1]=="s":
    S[i-1]=""
   elif S[i]=="m" and i<len(S)-1 and S[i+1]=="s":
    S[i+1]=""
  m=S.count("m")
  sn=S.count("s")
  if m>sn:
   print("mongooses")
  elif m<sn:
   print("snakes")
  else:
   print("tie")
except:
 pass

for _ in range(int(input())):
 S=list(input())
 for i in range(len(S)):
  if S[i]=="m" and i>0 and S[i-1]=="s":
   S[i-1]=""
  elif S[i]=="m" and i<len(S)-1 and S[i+1]=="s":
   S[i+1]=""
 m=S.count("m")
 sn=S.count("s")
 if m>sn:
  print("mongooses")
 elif m<sn:
  print("snakes")
 else:
  print("tie")

for _ in range(int(input())):
 s=list(input())
 for i in range(len(s)):
  if s[i]=="m" and i>0 and s[i-1]=="s" :
   s[i-1]=""
  elif s[i]=="m" and i<len(s)-1 and s[i+1]=="s":
   s[i+1]=""
 m=s.count("m")
 sn=s.count("s")
 if m>sn:
  print("mongooses")
 elif m<sn:
  print("snakes")
 else:
  print("tie")

for _ in range(int(input())):
 s=list(input())
 for i in range(len(s)):
  if s[i]=="m" and i>0 and s[i-1]=="s" :
   s[i-1]=""
  elif s[i]=="m" and i<len(s)-1 and s[i+1]=="s":
   s[i+1]=""
 m=s.count("m")
 sn=s.count("s")
 if m>sn:
  print("mongooses")
 elif m<sn:
  print("snakes")
 else:
  print("tie")

# cook your dish here
for _ in range(int(input())):
 s = list(input())
 c = 0
 for i in range(len(s)):
  if s[i] == 'm' and i>0 and s[i-1]=="s":
   s[i-1]=""
  elif s[i] == 'm' and i<len(s)-1 and s[i+1]=="s":
   s[i+1]=""
 sc = s.count('s')
 mc = s.count('m')
 if sc>mc:
  print('snakes')
 elif mc>sc:
  print('mongooses')
 else:
  print('tie')

t=int(input())
for i in range(t):
 s=input()
 list1=list(s)
 n=0
 n=len(s)
 c=0
 if(n==1):
  if(s[0]=="m"):
   print("mongooses")
  if(s[0]=="s"):
   print("snakes")
 elif(n==2):
  if(s!="ss"):
   print("mongooses")
  elif(s=="ss"):
   print("snakes")
   
 
 else:
  if(list1[0]=="m" and list1[1]=="s"):
   list1[1]=0
   c+=1
  for i in range(1,len(s)-1):
   if(list1[i]=="m" and list1[i-1]=="s"):
    c+=1
    list1[i-1]=0
   elif(list1[i]=="m" and list1[i+1]=="s"):
    c+=1
    list1[i+1]=0
   else:
    pass
  if(list1[n-1]=="m" and list1[n-2]=="s"):
   c+=1
   list1[n-2]=0
  if(s.count("m")>s.count("s")-c):
   print("mongooses")
  if(s.count("m")==s.count("s")-c):
   print("tie")
  if(s.count("m")<s.count("s")-c):
   print("snakes")
  
   


t=int(input())
for _ in range(t):
 s=input()
 if len(s)==1:
  if s[0]=='m':
   print("mongooses")
  else:
   print("snakes")
 else:
  sc=0
  mc=0
  for i in range(len(s)):
   if s[i]=='m':
    mc+=1
  s=list(s)
  n=len(s)
  for i in range(len(s)):
   if s[i]=='s':
    if i>0 and i<n-1:
     if s[i-1]!='m' and s[i+1]!='m':
      sc+=1
     elif s[i-1]=='m':
      s[i-1]='b'
     elif s[i+1]=='m':
      s[i+1]='b'
    elif i==0:
     if s[i+1]!='m':
      sc+=1
     else:
      s[i+1]='b'
    elif i==n-1:
     if s[i-1]!='m':
      sc+=1
     else:
      s[i-1]='b'
  if sc>mc:
   print("snakes")
  elif sc<mc:
   print("mongooses")
  else:
   print("tie")