for test in range(int(input())):
a = list(map(str,input().split()))
seto = set(a)
dicto = {}
for i in range(len(a)):
if a[i] == "s":
dicto["s"] += -1
else:
if ((a[i-1] == "m") and (a[i] == "m") and (a[i+1]) == "m"):
dicto["m"] += 1
else:
dicto["m"] += 2
if dicto["m"] > dicto["s"] :
print("mongooses")
elif dicto["m"]< dicto["s"]:
print("snakes")
else:
print("tie")