#C2349. Anagram Checker

    ID: 45655 Type: Default 1000ms 256MiB

Anagram Checker

Anagram Checker

In this problem, you are given several pairs of strings. For each pair, determine if the two strings are anagrams of each other. Two strings are considered anagrams if, after converting both strings to lowercase and removing all spaces, the sorted sequences of their characters are identical. Note that digits and other characters are also considered.

For example, the strings "listen" and "silent" are anagrams, and "a gentleman" and "elegant man" are also anagrams. However, "hello" and "world" are not.

Mathematical Formulation:

Let \( f(s) \) be a function that converts string \( s \) to lowercase and removes all spaces. Then, two strings \( a \) and \( b \) are anagrams if and only if:

[ sorted(f(a)) = sorted(f(b)) ]

Your task is to process multiple test cases and, for each case, output "YES" if the given strings are anagrams, or "NO" otherwise.

inputFormat

The first line of input contains an integer \( T \) representing the number of test cases.

Each test case consists of two consecutive lines. The first line contains the string \( a \) and the second line contains the string \( b \). The strings may contain spaces and can include any visible characters.

outputFormat

For each test case, output a single line containing YES if the two strings are anagrams according to the criteria described, or NO otherwise.

## sample
3
listen
silent
triangle
integral
hello
world
YES

YES NO

</p>