#K47337. Reorder to Palindrome

    ID: 28176 Type: Default 1000ms 256MiB

Reorder to Palindrome

Reorder to Palindrome

You are given a string s and your task is to determine whether the characters of s can be rearranged to form a palindrome.

A string is a palindrome if it reads the same forwards and backwards. For a given string s, a necessary and sufficient condition for it to be rearrangable into a palindrome is that at most one character has an odd frequency. Formally, let \( f(c) \) be the frequency of character \( c \) in s. Then, s can be rearranged into a palindrome if and only if

[ \sum_{c \in s} [f(c) \bmod 2 \neq 0] \leq 1 ]

You will be given several queries. For each query, output YES if the corresponding string can be rearranged into a palindrome, and NO otherwise.

Example:

Input:
5
 aabb
 abc
 civic
 ivicc
 hello

Output: YES NO YES YES NO

</p>

inputFormat

The first line contains an integer Q (\(1 \leq Q \leq 10^5\)) representing the number of queries. Each of the next Q lines contains a non-empty string s consisting of lowercase English letters. The length of each string is at least 1 and at most 103.

outputFormat

For each query, print a line containing YES if the characters of the string can be rearranged to form a palindrome, or NO otherwise.

## sample
5
aabb
abc
civic
ivicc
hello
YES

NO YES YES NO

</p>