#K94097. Taco Palindrome Checker

    ID: 38565 Type: Default 1000ms 256MiB

Taco Palindrome Checker

Taco Palindrome Checker

Your task is to determine whether a given string is a palindrome. A string is considered a palindrome if it reads the same backward as forward after removing non-letter characters and ignoring case differences. In other words, if you filter out all characters except letters (a-z and A-Z) and convert them to lower case, the resulting string should be the same when reversed.

Mathematically, given a string \(s\), define its filtered version \(s'\) as:

[ s' = { c \in s : c \text{ is a letter} }, \text{ with each } c \text{ transformed to lower case}, ]

The string is a palindrome if \(s' = (s')^R\) where \((s')^R\) is the reverse of \(s'\).

You need to process multiple test cases. For each test case, output palindrome if the string meets the criteria, and not a palindrome otherwise.

inputFormat

The first line of input contains an integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a string that may include letters, numbers, spaces, and special characters.

Example:

5
A man, a plan, a canal, Panama!
No 'x' in Nixon
This is not a palindrome
123Abc-!cbA321
Aba

outputFormat

For each test case, output a single line containing palindrome if the filtered string is a palindrome, otherwise output not a palindrome.

Example output for the sample input:

palindrome
palindrome
not a palindrome
palindrome
palindrome
## sample
5
A man, a plan, a canal, Panama!
No 'x' in Nixon
This is not a palindrome
123Abc-!cbA321
Aba
palindrome

palindrome not a palindrome palindrome palindrome

</p>