#C482. Ignored Palindrome Checker

    ID: 48400 Type: Default 1000ms 256MiB

Ignored Palindrome Checker

Ignored Palindrome Checker

Problem Description:

Given a string S, ignore all non-alphanumeric characters and consider letters case-insensitively. You need to determine whether the filtered string is a palindrome. Formally, let ( f(S) ) be the string obtained by removing all characters from S that are not letters or digits and converting all letters to lowercase. You must check if ( f(S) = f(S)^R ), where ( f(S)^R ) denotes the reverse of ( f(S) ).

For example, for S = "A man, a plan, a canal: Panama", after filtering and converting, we get "amanaplanacanalpanama" which is the same forwards and backwards, so the output is "YES".

Print "YES" if the string is a palindrome according to the defined rules; otherwise, print "NO".

inputFormat

The input is read from standard input. The first line contains a single integer T, representing the number of test cases. Each of the following T lines contains a string S.

outputFormat

For each test case, output a single line to standard output containing "YES" if the filtered string is a palindrome or "NO" otherwise.## sample

3
A man, a plan, a canal: Panama
race a car
No 'x' in Nixon
YES

NO YES

</p>