import sys
sys.stdin = open("D3_4522_input.txt", "r")

T = int(input())
for test_case in range(T):
    data = str(input())
    result = "Exist"
    for i in range(int(len(data) / 2)):
        if data[i] == "?" or data[len(data) - 1 - i] == "?":result
        elif data[i] != data[len(data) - 1 - i]:result = "Not exist"
    print("#{} {}".format(test_case + 1, result))
411de74beb38e499191e18d32efa50d2236faa14
<mask token>

<mask token>
for test_case in range(T):
    data = str(input())
    result = 'Exist'
    for i in range(int(len(data) / 2)):
        if data[i] == '?' or data[len(data) - 1 - i] == '?':
            result
        elif data[i] != data[len(data) - 1 - i]:
            result = 'Not exist'
    print('#{} {}'.format(test_case + 1, result))

<mask token>
sys.stdin = open('D3_4522_input.txt', 'r')
T = int(input())
for test_case in range(T):
    data = str(input())
    result = 'Exist'
    for i in range(int(len(data) / 2)):
        if data[i] == '?' or data[len(data) - 1 - i] == '?':
            result
        elif data[i] != data[len(data) - 1 - i]:
            result = 'Not exist'
    print('#{} {}'.format(test_case + 1, result))

import sys
sys.stdin = open('D3_4522_input.txt', 'r')
T = int(input())
for test_case in range(T):
    data = str(input())
    result = 'Exist'
    for i in range(int(len(data) / 2)):
        if data[i] == '?' or data[len(data) - 1 - i] == '?':
            result
        elif data[i] != data[len(data) - 1 - i]:
            result = 'Not exist'
    print('#{} {}'.format(test_case + 1, result))

import sys
sys.stdin = open("D3_4522_input.txt", "r")

T = int(input())
for test_case in range(T):
    data = str(input())
    result = "Exist"
    for i in range(int(len(data) / 2)):
        if data[i] == "?" or data[len(data) - 1 - i] == "?":result
        elif data[i] != data[len(data) - 1 - i]:result = "Not exist"
    print("#{} {}".format(test_case + 1, result))