#C11830. Anagram Checker
Anagram Checker
Anagram Checker
You are given a set of pairs of strings. For each pair, determine whether the two strings are anagrams of each other. Two strings are considered anagrams if, after removing all non-alphanumeric characters and converting all letters to lowercase, the sorted sequence of characters in each string is identical.
Note: Spaces, punctuation, and other non-word characters should be ignored during the comparison. Formally, for two strings \( s_1 \) and \( s_2 \), let \( f(s) \) be the string obtained by removing all characters that are not in \( [A-Za-z0-9] \) and converting all letters to lowercase. Then \( s_1 \) and \( s_2 \) are anagrams if and only if
\[
sorted( f(s_1) ) = sorted( f(s_2) )
\]
where sorted( f(s) )
represents the string after sorting its characters in non-decreasing order.
Your task is to implement a program that reads multiple test cases and for each pair outputs "Yes" if they are anagrams and "No" otherwise.
inputFormat
The input is read from the standard input and consists of multiple lines. The first line contains a single integer \( T \) indicating the number of test cases. For each test case, there are two lines: the first line contains the first string and the second line contains the second string.
outputFormat
For each test case, print a single line to standard output containing either "Yes" or "No" (without quotes) depending on whether the two strings are anagrams of each other.
## sample5
listen
silent
hello world
ohlle orlwd
anagram
nag a ram
abc
def
a
b
Yes
Yes
Yes
No
No
</p>