test = int(input())
for i in range(test):
s = input()
ate = 0
snakes = 0
mongoose = 0
count = 0
for i in s:
if s[count] == 'm':
mongoose += 1
if(s[count-1] == 's'):
ate+= 1
elif (s[count+1] == 's'):
ate +=1
else:
snakes +=1
count += 1
snakes -= ate
if snakes > mongoose:
print("snakes")
elif mongoose > snakes:
print("mongooses")
else:
print("tie")