#C10756. Alphanumeric Palindrome Checker

    ID: 39996 Type: Default 1000ms 256MiB

Alphanumeric Palindrome Checker

Alphanumeric Palindrome Checker

Given a string S, determine whether it is a palindrome by considering only alphanumeric characters and ignoring cases. In other words, first transform S into a cleaned string by removing all characters that are not letters or digits and converting all letters to lower-case. Then check if the cleaned string is the same as its reverse.

The mathematical condition to verify is: $$\text{cleaned_str} = \text{reverse(cleaned_str)}.$$

Your program should be able to handle multiple test cases as described in the input section.

inputFormat

The first line contains an integer T representing the number of test cases. Each of the following T lines contains a string S which may include spaces, punctuation, and other characters.

Formally, the input format is:

T
S1
S2
...
ST

outputFormat

For each test case, print one line containing YES if the string S is a palindrome after cleaning, and NO otherwise.

Each output should be printed on a new line.

## sample
6
A man, a plan, a canal: Panama
race a car
No lemon, no melon
Was it a car or a cat I saw?
Not a palindrome
1a2
YES

NO YES YES NO NO

</p>