#C2369. Rearrange to Palindrome

    ID: 45677 Type: Default 1000ms 256MiB

Rearrange to Palindrome

Rearrange to Palindrome

You are given a list of words. Your task is to determine whether at least one word in the list can be rearranged to form a palindrome.

A string is a palindrome if it reads the same forwards and backwards. A word can be rearranged to form a palindrome if and only if the number of characters that appear an odd number of times is at most one. In mathematical terms, if we let \( f(c) \) denote the frequency of character \( c \) in the word, then the word can be rearranged into a palindrome if and only if

[ \sum_{c}\mathbf{1}_{{f(c) ;%; 2 \neq 0}} \leq 1 ]

where (\mathbf{1}_{{\cdot}}) is the indicator function.

If at least one word meets the above condition, print YES. Otherwise, print NO.

inputFormat

The input is given via standard input (stdin) and has the following format:

n
word1
word2
... 
wordn

Where the first line contains an integer n that represents the number of words in the list, and the following n lines each contain a word.

outputFormat

Output a single line to standard output (stdout): YES if there exists at least one word that can be rearranged to form a palindrome, otherwise NO.

## sample
5
civic
rotor
level
kayak
dekay
YES