T = int(input())
result = 0
for t in range(1, T + 1):
word = input()
h = len(word) // 2
for i in range(len(word)):
if word[i] == word[len(word) - i - 1]:
result = 1
else:
result = 0
break
print(f"#{t} {result}")