#K4271. Palindromic Concatenation

    ID: 27148 Type: Default 1000ms 256MiB

Palindromic Concatenation

Palindromic Concatenation

Given two strings s1 and s2, determine if the concatenation of these two strings can be rearranged to form a palindrome. A palindrome is a string that reads the same forward and backward. A necessary and sufficient condition for a string to be rearranged into a palindrome is that at most one character has an odd frequency. In mathematical terms, if we let \( f(c) \) be the frequency of character \( c \) in the concatenated string \( s = s_1 + s_2 \), then \( s \) can be rearranged into a palindrome if and only if

[ \sum_{c} \mathbf{1}_{{f(c) \text{ is odd}}} \le 1. ]

Your task is to implement a program that reads multiple test cases from standard input, processes each one according to the above rule, and outputs "YES" if the concatenation can form a palindrome and "NO" if it cannot.

inputFormat

The input is read from standard input. The first line contains an integer T representing the number of test cases. Each test case consists of two subsequent lines:

  • The first line contains the string s1.
  • The second line contains the string s2.

Both strings contain only lowercase English letters.

outputFormat

For each test case, output a single line to standard output containing either "YES" if it is possible to rearrange the concatenation of s1 and s2 to form a palindrome, or "NO" otherwise.

## sample
3
aabb
ccdd
abc
def
ab
ba
YES

NO YES

</p>