#C2280. Anagram Transformation

    ID: 45579 Type: Default 1000ms 256MiB

Anagram Transformation

Anagram Transformation

You are given two strings A and B consisting only of digits. Your task is to determine whether it is possible to transform A into B by rearranging the digits of A. In other words, check if A is an anagram of B.

Formally, let the frequency of each digit in a string be represented by a multiset. We want to verify whether \[ \forall d \in \{0,1,2,\dots,9\}, \quad \text{count}_A(d) = \text{count}_B(d), \] where \(\text{count}_A(d)\) and \(\text{count}_B(d)\) denote the frequency of digit \(d\) in A and B respectively.

If the condition holds, print YES; otherwise, print NO.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
A₁
B₁
A₂
B₂
... 
Aₜ
Bₜ

Where:

  • T is a positive integer denoting the number of test cases.
  • For each test case, two lines follow: the first containing the string A and the second containing the string B.

outputFormat

For each test case, output a single line containing either YES or NO (without quotes) to indicate whether it is possible to transform string A into string B by rearranging its digits.

## sample
5
123
321
001
110
4567
4567
1234567890
0987654321
1111111111
2222222222
YES

NO YES YES NO

</p>