Is It a Palindrome After Cleanup?
You are given several lines of text, such as Was it a car, or a cat I saw?.
For each line, keep only its letters (a–z, A–Z) and digits (0–9), throwing away spaces, punctuation and every other character, and treat upper-case and lower-case versions of a letter as the same. The line is a palindrome after cleanup if what remains reads the same forwards and backwards.
A line with no letters or digits at all leaves nothing behind, and counts as a palindrome.
Input
The first line contains an integer n (1 ≤ n ≤ 10^5), the number of lines.
Each of the next n lines contains one line of text. A line consists of printable ASCII characters (codes 33 to 126) and spaces (code 32), contains at least one character that is not a space, and does not start or end with a space.
The total length of all n lines (not counting line breaks) is at most 10^6. A single line can be up to 10^6 characters long.
Output
Print n lines. The i-th of them is YES if the i-th text line is a palindrome after cleanup, and NO otherwise.
Notes
In the first example, Was it a car, or a cat I saw? becomes wasitacaroracatisaw, which reads the same backwards. Hello, World! becomes helloworld, which does not. The last line has no letters or digits, so the answer is YES.
In the second example, digits are kept: Race car 2 becomes racecar2, which is not a palindrome. In 0 O the first character is the digit zero and the second is the letter O, so they differ.
Lines contain spaces, so read each one as a whole line rather than word by word.