#K95637. Rearrange Bouquets
Rearrange Bouquets
Rearrange Bouquets
You are given several pairs of bouquets. Each bouquet is represented as a string consisting of lowercase letters. Two bouquets can be rearranged to form each other if one is an anagram of the other. In other words, after reordering the characters of one bouquet, if it becomes exactly the same as the second bouquet, then they are considered rearrangements of each other.
Your task is to determine for each given pair whether the two bouquets can be rearranged to form each other. The answer should be YES
if they can and NO
otherwise.
Note: The checking is case-sensitive and only involves rearrangement, not modifications of any letters.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer T (1 ≤ T ≤ 105) indicating the number of test cases.
- Each of the following T lines contains two non-empty strings separated by a space, representing the two bouquets.
It is guaranteed that the length of each string does not exceed 1000 characters.
outputFormat
For each test case, output one line to standard output (stdout). The line should contain YES
if the two bouquets can be rearranged to form each other or NO
otherwise.
3
rose sore
lily ylli
tulip tulips
YES
YES
NO
</p>