#C1110. Palindromic Strings Checker

    ID: 40379 Type: Default 1000ms 256MiB

Palindromic Strings Checker

Palindromic Strings Checker

This problem requires you to check whether each given string is a palindrome. A string is considered a palindrome if it reads the same forwards and backwards after removing all non-alphanumeric characters and ignoring case differences.

For example, the string "A man a plan a canal Panama" is a palindrome when ignoring spaces, punctuation, and capitalization.

Your program must read input from standard input (stdin) and output the result to standard output (stdout). For every input string, output YES if it is a palindrome and NO otherwise.

Note: When cleaning the string, remove all characters that are not letters or digits. Then, convert the string to lowercase and compare it with its reverse.

The palindrome condition can be mathematically expressed as:

$$ \text{cleaned}(s) = \overline{\text{cleaned}(s)} $$

inputFormat

The first line of input contains a single integer T (1 ≤ T ≤ 100), representing the number of strings.

Each of the following T lines contains a string s which may include spaces, punctuation, and mixed case letters.

outputFormat

For each input string, output a single line containing YES if the string is a palindrome (ignoring spaces, punctuation, and capitalization), or NO otherwise.

## sample
3
A man a plan a canal Panama
Hello, World!
Madam, in Eden, I'm Adam
YES

NO YES

</p>