# Arup Guha
# 1/27/2026
# Solution to Anya written in COP 4516
# Used to show how to use cop4516.ucfprogrammingteam.org.

# Returns true iff s is a palindrome, case sensitive.
def ispal(s):

    # See if opposite characters don't match.
    for i in range(len(s)):
        if s[i] != s[-1-i]:
            return False

    # If we get here, we're good.
    return True

# Process cases.
nC = int(input())
for loop in range(nC):

    # List of words.
    sentence = input().split()

    # Removes spaces.
    strSentence = ""
    for x in sentence:
        strSentence += x

    # Check the whole sentence first.
    likes = False
    if ispal(strSentence):
        likes = True

    # Count # of words that are palindromes of length 3 or more.
    cnt = 0
    for x in sentence:

        # Skip.
        if len(x) < 3:
            continue

        # Count it.
        if ispal(x):
            cnt += 1

    # Other way we can succeed.
    if cnt >= 2:
        likes = True

    # Output accordingly.
    if likes:
        print("Ay")
    else:
        print("Nap")
