Chef has learned a new technique for comparing two recipes. A recipe contains a list of ingredients in increasing order of the times they will be processed. An ingredient is represented by a letter 'a'-'z'. The i-th letter in a recipe denotes the i-th ingredient. An ingredient can be used multiple times in a recipe.

The technique is as follows. Compare two recipes by comparing their respective lists. If the sets of ingredients used in both recipes are equal and each ingredient is used the same number of times in both of them (processing order does not matter), they are declared as granama recipes. ("granama" is the Chef-ian word for "similar".)

Chef took two recipes he invented yesterday. He wanted to compare them using the technique. Unfortunately, Chef forgot to keep track of the number of times each ingredient has been used in a recipe. He only compared the ingredients but NOT their frequencies. More precisely, Chef considers two recipes as granama if there are no ingredients which are used in one recipe and not used in the other recipe.

Your task is to report whether Chef has correctly classified the two recipes (as granama or not granama) although he forgot to keep track of the frequencies.

------ Input ------ 

The first line of the input contains a single integer T denoting the number of test cases. The description for T test cases follows. Each test case consists of a single line containing two space-separated strings R and S denoting the two recipes.

------ Output ------ 

For each test case, output a single line containing "YES" (quotes for clarity) if Chef correctly classified the two recipes as granama or not granama. Otherwise, output a single line containing "NO" (quotes for clarity) if Chef declared two recipes as granama when they actually are not.

------ Constraints ------ 

1 ≤ T ≤ 100
1 ≤ |R|, |S| ≤ 1000

----- Sample Input 1 ------ 
3
alex axle
paradise diapers
alice bob
----- Sample Output 1 ------ 
YES
NO
YES
----- explanation 1 ------ 
Example case 1: Chef declared them as granama recipes. They are actually granama because the sets of ingredients and the number of times each ingredient has been used are equal. The Chef got it right!

Example case 2: Chef declared them as granama recipes because both sets of ingredients are equal. But they are NOT granama since ingredient 'a' has been used twice in the first recipe but only once in the second. The Chef was incorrect!

Example case 3: Chef declare them as not granama. They are not granama as the sets of ingredients are different. Hence, the Chef was right!

Difficulty: EASY
Tags: String algorithms

Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
for i in range(int(input())):
	(r, s) = input().split()
	p = list(set(r))
	q = list(set(s))
	p.sort()
	q.sort()
	a = []
	b = []
	for i in range(len(p)):
		a.append(r.count(p[i]))
	for i in range(len(q)):
		b.append(s.count(q[i]))
	if p != q:
		print('YES')
	elif p == q and a == b:
		print('YES')
	elif p == q and a != b:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	sa = list(set(a))
	sb = list(set(b))
	sa.sort()
	sb.sort()
	ac = []
	bc = []
	for i in range(len(sa)):
		ac.append(a.count(sa[i]))
	for i in range(len(sb)):
		bc.append(b.count(sb[i]))
	if sa != sb:
		print('YES')
	elif sa == sb and ac == bc:
		print('YES')
	elif sa == sb and ac != bc:
		print('NO')


t = int(input())
for _ in range(0, t):
	(x, y) = input().split()
	l1 = sorted(list(x))
	l2 = sorted(list(y))
	if l1 == l2:
		print('YES')
	else:
		i = 0
		while i < len(l1) - 1:
			if l1[i + 1] == l1[i]:
				l1.pop(i + 1)
			else:
				i += 1
		i = 0
		while i < len(l2) - 1:
			if l2[i + 1] == l2[i]:
				l2.pop(i + 1)
			else:
				i += 1
		if l1 == l2:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(s, t) = map(str, input().split(' '))
	s1 = set(s)
	s2 = set(t)
	if s1 == s2:
		if sorted(list(s)) == sorted(list(t)):
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


from collections import Counter
for _ in range(int(input())):
	(r, s) = map(str, input().split())
	s1 = set(r)
	s2 = set(s)
	l1 = Counter(r)
	l2 = Counter(s)
	if s1 != s2:
		print('YES')
	elif s1 == s2 and l1 == l2:
		print('YES')
	else:
		print('NO')


from collections import Counter
a = int(input())
for _ in range(a):
	(k, p) = input().split()
	flag = 0
	sc = Counter(k)
	rc = Counter(p)
	if set(k) == set(p):
		for i in k:
			if sc[i] != rc[i]:
				flag = 1
		if flag == 1:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


from collections import Counter
n = int(input())
for i in range(n):
	(x, y) = map(str, input().split())
	x = list(x)
	y = list(y)
	x.sort()
	y.sort()
	p = set(x)
	q = set(y)
	a = list(p)
	b = list(q)
	a.sort()
	b.sort()
	if a != b:
		print('YES')
	elif Counter(x) == Counter(y):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = input().split()
	lista = []
	listaa = [0 for x in range(26)]
	listb = []
	listbb = [0 for x in range(26)]
	for j in a:
		if ord(j) - 97 not in lista:
			lista.append(ord(j) - 97)
		listaa[ord(j) - 97] += 1
	for k in b:
		if ord(k) - 97 not in listb:
			listb.append(ord(k) - 97)
		listbb[ord(k) - 97] += 1
	lista.sort()
	listb.sort()
	if lista == listb:
		if listaa == listbb:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input().strip())):
	(r, s) = input().strip().split()
	l1 = list(set(list(r)))
	l1.sort()
	l2 = list(set(list(s)))
	l2.sort()
	if ''.join(l1) == ''.join(l2):
		l1 = list(r)
		l2 = list(s)
		l1.sort()
		l2.sort()
		if ''.join(l1) == ''.join(l2):
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	(r, s) = map(str, input().split())
	d1 = {}
	d2 = {}
	for f in r:
		if f in d1:
			d1[f] += 1
		else:
			d1[f] = 1
	for j in s:
		if j in d2:
			d2[j] += 1
		else:
			d2[j] = 1
	if d1 == d2 or d1.values() == d2.values() or d1.keys() != d2.keys():
		print('YES')
	else:
		print('NO')


for x in range(int(input())):
	A = str(input()).split()
	B = []
	B.append(A[1])
	A.remove(A[1])
	C = list(A[0])
	D = list(B[0])
	C.sort()
	D.sort()
	E = list(set(C))
	F = list(set(D))
	if C == D:
		print('YES')
	elif E != F:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	s = s.split(' ')
	a = {}
	b = {}
	for i in s[0]:
		if i in a:
			a[i] += 1
		else:
			a[i] = 1
	for i in s[1]:
		if i in b:
			b[i] += 1
		else:
			b[i] = 1
	if a.values() == b.values() or a == b or a.keys() != b.keys():
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
for hkhh in range(t):
	(r, s) = map(str, input().split())
	csr = set(r)
	css = set(s)
	cr = Counter(r)
	cs = Counter(s)
	if csr == css:
		if cr == cs:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(rec1, rec2) = input().split()
	(l1, l2) = (list(rec1), list(rec2))
	l1.sort()
	l2.sort()
	(s1, s2) = (set(l1), set(l2))
	if s1 == s2 and l1 == l2:
		print('YES')
	elif s1 == s2 and l1 != l2:
		print('NO')
	elif s1 != s2:
		print('YES')


t = int(input())
for i in range(t):
	(r, s) = input().split()
	r = sorted(r)
	s = sorted(s)
	if r == s:
		print('YES')
	elif set(r) != set(s):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(r, s) = input().split()
	x = list(set(r))
	y = list(set(s))
	x.sort()
	y.sort()
	a = []
	b = []
	for i in range(len(x)):
		a.append(r.count(x[i]))
	for i in range(len(y)):
		b.append(s.count(y[i]))
	if x != y:
		print('YES')
	elif x == y and a == b:
		print('YES')
	elif x == y and a != b:
		print('NO')


for _ in range(int(input())):
	(r, s) = tuple(input().split())
	if set(r) == set(s):
		if sorted(r) == sorted(s):
			print('YES')
		else:
			print('NO')
	elif sorted(r) == sorted(s):
		print('NO')
	else:
		print('YES')


from collections import Counter
for _ in range(int(input())):
	(s, t) = input().split()
	print('YES' if (set(s) == set(t)) == (Counter(s) == Counter(t)) else 'NO')


t = int(input())
for t in range(t):
	(r, s) = [i for i in input().split(' ')]

	def dicti(p):
		d = {}
		for i in p:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		return d
	dr = dicti(r)
	ds = dicti(s)
	if dr == ds:
		print('YES')
	elif set(r) != set(s):
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	(a, b) = input().split()
	c = Counter(a)
	d = Counter(b)
	s = set(a)
	r = set(b)
	if s == r:
		if c == d:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(r, s) = input().split(' ')
	(d1, d2) = ({}, {})
	for i in r:
		d1[i] = d1.get(i, 0) + 1
	for i in s:
		d2[i] = d2.get(i, 0) + 1
	(d1l, d2l) = (list(d1.keys()), list(d2.keys()))
	if sorted(d1l) == sorted(d2l):
		if d1 == d2:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(r, s) = map(str, input().split())
	(t1, t2) = (sorted(r), sorted(s))
	(d1, d2) = (set(r), set(s))
	if t1 == t2:
		print('YES')
	elif d1 == d2:
		print('NO')
	else:
		print('YES')


def nag(a, b):
	if sorted(a) == sorted(b):
		return 'YES'
	elif set(a) != set(b):
		return 'YES'
	return 'NO'
t = int(input())
while t:
	(a, b) = map(str, input().split())
	result = nag(a, b)
	print(result)
	t -= 1


for tc in range(int(input())):
	(r, s) = input().split()
	rs = set(r)
	ss = set(s)
	ans = 'YES'
	if rs == ss:
		for i in rs:
			if r.count(i) != s.count(i):
				ans = 'NO'
	print(ans)


tests = int(input())
for i in range(tests):
	(recipe1, recipe2) = input().split()
	recipe_arr1 = [0] * 26
	recipe_arr2 = [0] * 26
	chef_ans = True
	correct_ans = True
	for j in recipe1:
		recipe_arr1[ord(j) - 97] += 1
	for j in recipe2:
		recipe_arr2[ord(j) - 97] += 1
	for j in range(26):
		if recipe_arr1[j] > 0 and recipe_arr2[j] == 0 or (recipe_arr2[j] > 0 and recipe_arr1[j] == 0):
			chef_ans = False
		if recipe_arr1[j] != recipe_arr2[j]:
			correct_ans = False
	if chef_ans == correct_ans:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(r, s) = input().split()
	r = list(r)
	s = list(s)
	r.sort()
	s.sort()
	if set(r) == set(s):
		t = 'YES'
	else:
		t = 'NO'
	if r == s and len(r) == len(s):
		c = 'YES'
	else:
		c = 'NO'
	if t == c:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(r, s) = map(str, input().split())
	(r, s) = (list(r), list(s))
	(d1, d2) = ({}, {})
	for i in r:
		if i in d1:
			d1[i] += 1
		else:
			d1[i] = 1
	for i in s:
		if i in d2:
			d2[i] += 1
		else:
			d2[i] = 1
	if set(r) != set(s):
		print('YES')
	else:
		if set(r) == set(s):
			flag = 0
			for (i, j) in d1.items():
				if i in d2.keys() and j == d2[i]:
					continue
				else:
					flag = 1
				break
		if flag == 1:
			print('NO')
		else:
			print('YES')


from collections import Counter
for i in range(int(input())):
	(r, s) = map(str, input().split())
	print('YES' if (set(r) == set(s)) == (Counter(r) == Counter(s)) else 'NO')


from collections import Counter
for _ in range(int(input())):
	(r, s) = input().split()
	set_r = set(r)
	set_s = set(s)
	counts_r = Counter(r)
	counts_s = Counter(s)
	if set_s == set_r:
		if counts_s == counts_r:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(r, s) = input().split()
	r1 = list(r)
	s1 = list(s)
	r1.sort()
	s1.sort()
	cr = []
	cs = []
	rf = list(set(r1))
	sf = list(set(s1))
	for i in range(len(r1)):
		cr.append(r1.count(r1[i]))
	for i in range(len(s1)):
		cs.append(s1.count(s1[i]))
	if rf != sf or cr == cs:
		print('YES')
	else:
		print('NO')


x = int(input())
a = []
for i in range(x):
	(y, z) = map(str, input().split())
	y = sorted(y)
	z = sorted(z)
	if y == z:
		print('YES')
	elif set(y) != set(z):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(str, input().split())
	from collections import Counter as Co
	(a, b) = (Co(a), Co(b))
	if a.keys() == b.keys():
		for i in a:
			if a[i] != b[i]:
				print('NO')
				break
		else:
			print('YES')
	else:
		print('YES')


T = int(input())
for i in range(T):
	(a, b) = map(str, input().split())
	if sorted(a) == sorted(b):
		print('YES')
	elif set(a) != set(b):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(a, b) = map(str, input().split())
	x = list(set(a))
	y = list(set(b))
	x.sort()
	y.sort()
	p = []
	q = []
	for i in range(len(x)):
		p.append(a.count(x[i]))
	for i in range(len(y)):
		q.append(b.count(y[i]))
	if x != y:
		print('YES')
	elif x == y and p == q:
		print('YES')
	elif x == y and p != q:
		print('NO')


T = int(input())
for i in range(T):
	str = input().split()
	a = str[0]
	b = str[1]
	d1 = {}
	d2 = {}
	for i in a:
		if i in d1:
			d1[i] += 1
		else:
			d1[i] = 1
	for i in b:
		if i in d2:
			d2[i] += 1
		else:
			d2[i] = 1
	if d1.values() == d2.values() or d1.keys() != d2.keys() or d1 == d2:
		print('YES')
	else:
		print('NO')


from collections import Counter
for i in range(int(input())):
	(r, s) = input().split()
	a = set(r)
	b = set(s)
	if a != b:
		print('YES')
	elif a == b and Counter(r) == Counter(s):
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
for i in range(t):
	(r, s) = map(str, input().split())
	a = list(r)
	b = list(s)
	a.sort()
	b.sort()
	c = set(a)
	d = set(b)
	e = list(c)
	f = list(d)
	e.sort()
	f.sort()
	if e != f:
		print('YES')
	elif Counter(a) == Counter(b):
		print('YES')
	else:
		print('NO')


from collections import Counter

def check(s, t):
	if set(s) != set(t):
		return True
	if set(s) == set(t) and Counter(s) == Counter(t):
		return True
	return False
for _ in range(int(input())):
	(a, b) = input().split()
	if check(a, b):
		print('YES')
		continue
	print('NO')


for _ in range(int(input())):
	(arr, ars) = list(map(str, input().split()))
	check1 = 0
	check2 = 0
	if set(arr) == set(ars):
		check1 = 1
	if sorted(tuple(arr)) == sorted(tuple(ars)):
		check2 = 1
	if check1 == check2:
		print('YES')
	elif check1 == 1 and check2 == 0:
		print('NO')


test_case = int(input())
for i in range(test_case):
	S = input().split(' ')
	list1 = []
	list2 = []
	set1 = {'.'}
	set2 = {'.'}
	for j in range(len(S[0])):
		list1.append(S[0][j])
		set1.add(S[0][j])
	for k in range(len(S[1])):
		list2.append(S[1][k])
		set2.add(S[1][k])
	if set1 == set2:
		granan = True
		for j in range(len(list1)):
			if list1[j] in list2:
				list2.remove(list1[j])
			else:
				granan = False
				break
		if granan == True and len(list2) == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for test_case in range(0, t):
	(a, b) = input().split()
	a_list = list(a)
	a_list.sort()
	b_list = list(b)
	b_list.sort()
	a_set = set(a_list)
	b_set = set(b_list)
	if a_set == a_set and a_list == b_list:
		print('YES')
	elif a_set == b_set and a_list != b_list:
		print('NO')
	elif a_set != b_set:
		print('YES')


for i in range(int(input())):
	(a, b) = [str(x) for x in input().split(' ')]
	if sorted(set(a)) == sorted(set(b)):
		if sorted(a) == sorted(b):
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(r, s) = input().split()
	c = 0
	d = 0
	s1 = set(r)
	s2 = set(s)
	if s1 == s2:
		d = 1
	d1 = {}
	d2 = {}
	for j in s1:
		d1[j] = r.count(j)
	for k in s2:
		d2[k] = s.count(k)
	f = 0
	if d1 == d2:
		f = 1
	if d == f:
		print('YES')
	else:
		print('NO')


def isTrue(R, S):
	d1 = {}
	d2 = {}
	for i in R:
		if i not in d1:
			d1[i] = 1
		else:
			d1[i] += 1
	for j in S:
		if j not in d2:
			d2[j] = 1
		else:
			d2[j] += 1
	chef = 0
	reality = 0
	if set(d1.keys()) == set(d2.keys()):
		chef = 1
		for i in R:
			if d1[i] != d2[i]:
				break
		else:
			reality = 1
	if chef == reality:
		return True
	else:
		return False
T = int(input())
for i in range(T):
	(R, S) = input().split()
	if isTrue(R, S) == True:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(r, s) = input().split()
	r1 = list(set(r))
	s1 = list(set(s))
	r1.sort()
	s1.sort()
	l1 = []
	l2 = []
	for i in range(len(r1)):
		l1.append(r.count(r1[i]))
	for i in range(len(s1)):
		l2.append(s.count(s1[i]))
	if r1 != s1:
		print('YES')
	elif r1 == s1 and l1 == l2:
		print('YES')
	elif r1 == s1 and l1 != l2:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	(r, s) = input().split()
	r = list(r)
	s = list(s)
	r.sort()
	s.sort()
	if set(r) == set(s):
		print('YES') if r == s else print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(s, r) = map(str, input().split())
	k = set(s)
	m = set(r)
	inter = k.intersection(m)
	c3 = 0
	c4 = 0
	for i in inter:
		c1 = s.count(i)
		c2 = r.count(i)
		c3 += 1
		if c1 == c2:
			c4 += 1
	if sorted(s) == sorted(r):
		print('YES')
	elif len(inter) == 0:
		print('YES')
	elif c3 == c4:
		print('YES')
	elif k != m:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(r, s) = input().split()
	l1 = []
	l2 = []
	dict_r = {}
	dict_s = {}
	for char in r:
		if char in dict_r:
			dict_r[char] += 1
		else:
			l1.append(char)
			dict_r[char] = 1
	for char in s:
		if char in dict_s:
			dict_s[char] += 1
		else:
			l2.append(char)
			dict_s[char] = 1
	l1.sort()
	l2.sort()
	flag = True
	if l1 == l2:
		for (key, value) in dict_r.items():
			if value != dict_s[key]:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(x, y) = input().split()
	check1 = all((i in x for i in y))
	check2 = all((i in y for i in x))
	if check1 == False and check2 == False or check1 != check2:
		print('YES')
	else:
		for i in x:
			if x.count(i) != y.count(i):
				print('NO')
				break
		else:
			print('YES')
	t -= 1


for _ in range(int(input())):
	(s1, s2) = [str(x) for x in input().split(' ')]
	if sorted(set(s1)) == sorted(set(s2)):
		if sorted(s1) == sorted(s2):
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for ni in range(t):
	(r, s) = input().split()
	r = list(sorted(list(r)))
	s = list(sorted(list(s)))
	r1 = set(r)
	s1 = set(s)
	if s1 == r1:
		if r == s:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


from math import gcd, sqrt, ceil, floor, log10
from heapq import heapify, heappop, heappush, nsmallest, nlargest
from collections import Counter, deque, OrderedDict, defaultdict
from itertools import combinations, permutations, zip_longest
from bisect import bisect_left, bisect_right
from functools import lru_cache
import sys
import time
import string
sys.setrecursionlimit(3000000)
INT_MAX = float('inf')
INT_MIN = float('-inf')
MOD = int(1000000000.0) + 7
NEWLINE = '\n'
SPACE = ' '
inp = lambda fn: fn(input())
inp_vars = lambda fn, delim, convert_to=list: convert_to(map(fn, input().split(delim)))

def solve(*args, **kwargs):
	(s, r) = args
	chef = correct = True
	(s, r) = (Counter(s), Counter(r))
	for ch in string.ascii_lowercase:
		if s[ch] == 0 and r[ch] != 0 or (s[ch] != 0 and r[ch] == 0):
			chef = False
		if s[ch] != r[ch]:
			correct = False
	return 'YES' if correct == chef else 'NO'

def main(*args, **kwargs):
	for _ in range(int(input())):
		(arg1, arg2) = inp_vars(str, SPACE)
		res = solve(*(arg1, arg2))
		if type(res) in {list, tuple, set}:
			print(*res, sep=' ')
		else:
			print(res)
main()


t = input()
for c in range(0, int(t)):
	(r, s) = input().split()
	rset = set(r)
	chef = 1
	for x in rset:
		if x not in s:
			chef = 0
			break
	sset = set(s)
	for w in sset:
		if w not in r:
			chef = 0
			break
	if chef == 1:
		correct = 1
		for y in rset:
			if r.count(y) != s.count(y):
				correct = 0
				break
		if correct == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(str1, str2) = map(str, input().split())
	ans = True
	if set(str1) == set(str2):
		chef = True
		for ch in set(str1):
			if str1.count(ch) != str2.count(ch):
				ans = False
				break
	else:
		chef = False
	if chef == True and ans == True:
		print('YES')
	elif chef == True and ans == False:
		print('NO')
	elif chef == False:
		print('YES')


from collections import Counter
for _ in range(int(input())):
	(s1, s2) = input().split()
	a1 = Counter(s1)
	a2 = Counter(s2)
	f = 0
	if set(s1) == set(s2):
		for i in s1:
			if a1[i] != a2[i]:
				f = 1
		if f == 1:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


for _ in range(int(input())):
	(r, s) = map(str, input().split())
	R = []
	S = []
	for i in r:
		R.append(i)
	for i in s:
		S.append(i)
	R.sort()
	S.sort()
	a = set(R)
	b = set(S)
	if a == b:
		if R == S:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(r, s) = input().split()
	s1 = set()
	s2 = set()
	dict_r = {}
	dict_s = {}
	for char in r:
		if char in dict_r:
			dict_r[char] += 1
		else:
			s1.add(char)
			dict_r[char] = 1
	for char in s:
		if char in dict_s:
			dict_s[char] += 1
		else:
			s2.add(char)
			dict_s[char] = 1
	flag = True
	if s1 == s2:
		for (key, value) in dict_r.items():
			if value != dict_s[key]:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


testcases = int(input())
for i in range(testcases):
	(r, s) = list(map(str, input().split()))
	temp1 = dict()
	temp2 = dict()
	for i in r:
		temp1[i] = temp1.get(i, 0) + 1
	for i in s:
		temp2[i] = temp2.get(i, 0) + 1
	list1 = list(temp1.keys())
	list2 = list(temp2.keys())
	if sorted(list1) == sorted(list2):
		if temp1 == temp2:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b) = input().split()
	(a1, b1) = (set(a), set(b))
	a = sorted(a)
	b = sorted(b)
	if a1 == b1:
		if a == b:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(a, b) = map(str, input().split())
	c = 0
	for i in a:
		if i not in b:
			c += 1
	a1 = set(a)
	b1 = set(b)
	c3 = 0
	c4 = 0
	cc = a1.intersection(b1)
	for i in cc:
		c1 = a.count(i)
		c2 = b.count(i)
		c3 += 1
		if c1 == c2:
			c4 += 1
	if c3 == c4:
		print('YES')
	elif len(a) == c:
		print('YES')
	elif sorted(a) == sorted(b):
		print('YES')
	elif set(a) != set(b):
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	(r, s) = input().split()
	x = Counter(r)
	y = Counter(s)
	r = set(r)
	s = set(s)
	if r == s:
		if x == y:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')