input을 통해 받은 단어를 슬라이싱을 통해 거꾸로 나열했을 때 원래 단어와 같을 때 1을 출력하고 같지 않을 때 0을 출력한다.
T = int(input()) for tc in range(1, T+1): word = input() if word == word[::-1]: print(f'#{tc} 1') else: print(f'#{tc} 0')