for tc in range(1, int(input())+1):
word = list(input())
check = ['0']*(len(word)//2)
for i in range(len(word)//2):
check[i] = word[-(i+1)]
if check == word[:len(word)//2]:
print('#{} 1'.format(tc))
else:
print('#{} 0'.format(tc))
def check(arr):
N = len(arr)
i = 0
while i < N//2:
if arr[i] != arr[-(i+1)]:
return 0
i += 1
return 1
for tc in range(1, int(input())+1):
word = list(input())
print('#{} {}'.format(tc, check(word)))
t = int(input())
for tc in range(1, t + 1):
s = input()
result = 0
for i in range(len(s)//2):
if s[i] != s[len(s)-1-i]:
break
else:
result = 1
print("#{} {}".format(tc, result))