You are given two strings $s$ and $t$ both of length $n$ and both consisting of lowercase Latin letters.

In one move, you can choose any length $len$ from $1$ to $n$ and perform the following operation:   Choose any contiguous substring of the string $s$ of length $len$ and reverse it;  at the same time choose any contiguous substring of the string $t$ of length $len$ and reverse it as well. 

Note that during one move you reverse exactly one substring of the string $s$ and exactly one substring of the string $t$.

Also note that borders of substrings you reverse in $s$ and in $t$ can be different, the only restriction is that you reverse the substrings of equal length. For example, if $len=3$ and $n=5$, you can reverse $s[1 \dots 3]$ and $t[3 \dots 5]$, $s[2 \dots 4]$ and $t[2 \dots 4]$, but not $s[1 \dots 3]$ and $t[1 \dots 2]$.

Your task is to say if it is possible to make strings $s$ and $t$ equal after some (possibly, empty) sequence of moves.

You have to answer $q$ independent test cases.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 10^4$) — the number of test cases. Then $q$ test cases follow.

The first line of the test case contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the length of $s$ and $t$.

The second line of the test case contains one string $s$ consisting of $n$ lowercase Latin letters.

The third line of the test case contains one string $t$ consisting of $n$ lowercase Latin letters.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$).


-----Output-----

For each test case, print the answer on it — "YES" (without quotes) if it is possible to make strings $s$ and $t$ equal after some (possibly, empty) sequence of moves and "NO" otherwise.


-----Example-----
Input
4
4
abcd
abdc
5
ababa
baaba
4
asdf
asdg
4
abcd
badc

Output
NO
YES
NO
YES

Difficulty: HARD
Tags: String algorithms

Sorting

Constructive algorithms
Skill types: Sorting

Starter code:

Solutions:
import sys, math
import io, os
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = int(1000000000.0) + 7

def cal(s):
	l = [0] * 26
	cnt = 0
	for i in s:
		cnt += sum(l[ord(i) - 97 + 1:26])
		l[ord(i) - 97] += 1
	return cnt
for q in range(int(data())):
	n = int(data())
	s = data()
	t = data()
	cnt_s = cal(s)
	cnt_t = cal(t)
	(C_s, C_t) = (Counter(s), Counter(t))
	if (abs(cnt_s + cnt_t) % 2 == 0 or max(C_s.values()) > 1) and C_s == C_t:
		out('YES')
	else:
		out('NO')


import io, os
input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline
ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())

def bs(ls):
	c = 0
	for _ in range(len(ls)):
		for i in range(len(ls) - 1):
			if ls[i] > ls[i + 1]:
				c += 1
				(ls[i + 1], ls[i]) = (ls[i], ls[i + 1])
	return c & 1
for _ in range(ii()):
	(l, a, b) = (ii(), list(input()), list(input()))
	(da, db) = ({}, {})
	for c in a:
		if c not in da:
			da[c] = 0
		da[c] += 1
	for c in b:
		if c not in db:
			db[c] = 0
		db[c] += 1
	ok = False
	for k in da:
		if k not in db or db[k] != da[k]:
			print('NO')
			break
		if da[k] > 1:
			ok = True
	else:
		if ok:
			print('YES')
		else:
			print('YNEOS'[bs(a) != bs(b)::2])


import math
import sys
from collections import defaultdict, Counter
from itertools import groupby
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def count_chars(s):
	res = [0] * 26
	for c in s:
		res[ord(c) - ord('a')] += 1
	return res

def inversions_parity(s):
	parity = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if s[i] > s[j]:
				parity ^= 1
	return parity

def main():
	q = ri()
	for _ in range(q):
		n = ri()
		s = input()
		t = input()
		cs = Counter(s)
		ct = Counter(t)
		if cs != ct:
			print('NO')
		else:
			print('YES' if max(cs.values()) * max(ct.values()) > 1 or inversions_parity(s) == inversions_parity(t) else 'NO')
main()


q = int(input())
for i in range(q):
	n = int(input())
	a = input()
	b = input()
	countA = [0] * 26
	countB = [0] * 26
	for char in a:
		countA[ord(char) - 97] += 1
	for char in b:
		countB[ord(char) - 97] += 1
	no = 0
	for i in range(26):
		if countA[i] != countB[i]:
			no = 1
			break
	if no:
		print('NO')
		continue
	yes = 0
	for i in range(26):
		if countA[i] >= 2:
			yes = 1
			break
		if countB[i] >= 2:
			yes = 1
			break
	if yes:
		print('YES')
		continue

	def countRev(s):
		count = 0
		for i in range(n):
			for j in range(i + 1, n):
				if s[i] > s[j]:
					count += 1
		return count
	x = countRev(a) - countRev(b)
	if x % 2:
		print('NO')
	else:
		print('YES')


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	s = list(minp())
	t = list(minp())
	if sorted(t) != sorted(s):
		print('NO')
		return
	for i in range(26):
		if s.count(chr(ord('a') + i)) > 1:
			print('YES')
			return
	r = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if t.index(s[i]) > t.index(s[j]):
				r += 1
	print(['NO', 'YES'][r % 2 == 0])
for i in range(mint()):
	solve()


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

class BIT:

	def __init__(self, n):
		self.N = n
		self.tree = [0] * n

	def add(self, i, value=1):
		(n, tree) = (self.N, self.tree)
		while i < n:
			tree[i] += value
			i |= i + 1

	def sum(self, r):
		tree = self.tree
		result = 0
		while r > 0:
			result += tree[r - 1]
			r &= r - 1
		return result

def countInv(a):
	n = len(a)
	ctr = 0
	bit = BIT(26)
	for i in a:
		ctr += bit.sum(i)
		bit.add(i)
	return (n * (n - 1) >> 1) - ctr
q = int(input())
d = {}
for i in range(26):
	d[chr(ord('a') + i)] = i
for _ in range(q):
	n = int(input())
	ss = input()
	tt = input()
	s = []
	t = []
	ctr = [0] * 26
	for c in ss:
		code = d[c]
		s.append(code)
		ctr[code] += 1
	for c in ctr:
		if c > 1:
			hasSame = True
			break
	else:
		hasSame = False
	for c in tt:
		t.append(d[c])
	if sorted(s) != sorted(t):
		print('NO')
	elif hasSame:
		print('YES')
	elif countInv(s) + countInv(t) & 1:
		print('NO')
	else:
		print('YES')


import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	n = int(stdin.readline())
	s = list(stdin.readline()[:-1])
	t = list(stdin.readline()[:-1])
	rs = 0
	lis = [0] * 26
	for i in s:
		rs += sum(lis[:ord(i) - ord('a')])
		lis[ord(i) - ord('a')] += 1
	rt = 0
	lis = [0] * 26
	for i in t:
		rt += sum(lis[:ord(i) - ord('a')])
		lis[ord(i) - ord('a')] += 1
	s.sort()
	t.sort()
	flag = True
	for i in range(n):
		if s[i] != t[i]:
			flag = False
			break
	if not flag:
		ANS.append('NO')
		continue
	sf = False
	for i in range(1, n):
		if s[i - 1] == s[i]:
			sf = True
			break
	if sf or rs % 2 == rt % 2:
		ANS.append('YES')
	else:
		ANS.append('NO')
print('\n'.join(ANS))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	c1 = Counter(s)
	c2 = Counter(t)
	if c1 != c2:
		print('NO')
		continue
	if n > 26:
		print('YES')
		continue
	if max(c1.values()) >= 2:
		print('YES')
		continue
	p1 = 0
	p2 = 0
	for i in range(n):
		for j in range(i + 1, n):
			if s[i] > s[j]:
				p1 += 1
			if t[i] > t[j]:
				p2 += 1
	print('YES' if p1 % 2 == p2 % 2 else 'NO')


def cal(s):
	res = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if s[i] > s[j]:
				res ^= 1
	return res

def solve():
	int(input())
	s = input()
	t = input()
	if sorted(s) != sorted(t):
		print('NO')
		return
	for i in range(26):
		if s.count(chr(ord('a') + i)) > 1:
			print('YES')
			return
	print(['NO', 'YES'][cal(s) == cal(t)])
for i in range(int(input())):
	solve()


def f(s, t):
	if sorted(s) != sorted(t):
		return False
	(ss, st) = (set(s), set(t))
	if len(s) > len(ss) or len(t) > len(st):
		return True

	def rec(s, i, j):
		if i == j:
			return 0
		if i + 1 == j:
			if s[i] > s[j]:
				(s[i], s[j]) = (s[j], s[i])
				return 1
			else:
				return 0
		mid = (j - i) // 2
		inv = 0
		inv += rec(s, i, i + mid)
		inv += rec(s, i + mid + 1, j)
		out = []
		(a, b) = (i, i + mid + 1)
		while a <= i + mid or b <= j:
			if a > i + mid:
				out.append(s[b])
				b += 1
			elif b > j:
				out.append(s[a])
				a += 1
			elif s[a] > s[b]:
				out.append(s[b])
				inv += i + mid - a + 1
				b += 1
			else:
				out.append(s[a])
				a += 1
		assert len(out) == j - i + 1
		for k in range(len(out)):
			s[i + k] = out[k]
		return inv
	assert rec(list('24135'), 0, 4) == 3
	assert rec(list('bacd'), 0, 3) == 1
	assert rec(list('abdc'), 0, 3) == 1
	assert rec(list('badc'), 0, 3) == 2
	assert rec(list('acbd'), 0, 3) == 1
	assert rec(list('abcdefgh'), 0, 7) == 0
	assert rec(list('abcd'), 0, 3) == 0
	assert rec(list('ba'), 0, 1) == 1
	assert rec(list('AGFDE'), 0, 4) == 5
	ps = rec(list(s), 0, len(s) - 1)
	pt = rec(list(t), 0, len(t) - 1)
	return ps % 2 == pt % 2
assert f('ababa', 'baaba') is True
assert f('abcd', 'abdc') is False
assert f('asdf', 'asdg') is False
assert f('abcd', 'badc') is True
q = int(input())
for _ in range(q):
	l = int(input())
	s = input()
	t = input()
	ans = f(s, t)
	if ans:
		print('YES')
	else:
		print('NO')


q = int(input())

def mergeSort(arr, n):
	temp_arr = [0] * n
	return _mergeSort(arr, temp_arr, 0, n - 1)

def _mergeSort(arr, temp_arr, left, right):
	inv_count = 0
	if left < right:
		mid = (left + right) // 2
		inv_count = _mergeSort(arr, temp_arr, left, mid)
		inv_count += _mergeSort(arr, temp_arr, mid + 1, right)
		inv_count += merge(arr, temp_arr, left, mid, right)
	return inv_count

def merge(arr, temp_arr, left, mid, right):
	i = left
	j = mid + 1
	k = left
	inv_count = 0
	while i <= mid and j <= right:
		if arr[i] <= arr[j]:
			temp_arr[k] = arr[i]
			k += 1
			i += 1
		else:
			temp_arr[k] = arr[j]
			inv_count += mid - i + 1
			k += 1
			j += 1
	while i <= mid:
		temp_arr[k] = arr[i]
		k += 1
		i += 1
	while j <= right:
		temp_arr[k] = arr[j]
		k += 1
		j += 1
	for loop_var in range(left, right + 1):
		arr[loop_var] = temp_arr[loop_var]
	return inv_count
for i in range(q):
	l = int(input())
	s1 = input()
	s2 = input()
	if sorted(s1) != sorted(s2):
		print('NO')
		continue
	if len(s1) != len(set(s1)):
		print('YES')
		continue
	if len(s2) != len(set(s2)):
		print('YES')
		continue
	arr = [s2.index(c) for c in s1]
	if mergeSort(arr, len(arr)) % 2 == 0:
		print('YES')
	else:
		print('NO')


from string import ascii_lowercase as letters
from collections import Counter

class SegmentTree:

	def __init__(self, arr, func, initialRes=0):
		self.f = func
		self.N = len(arr)
		self.tree = [0 for _ in range(4 * self.N)]
		self.initialRes = initialRes
		for i in range(self.N):
			self.tree[self.N + i] = arr[i]
		for i in range(self.N - 1, 0, -1):
			self.tree[i] = self.f(self.tree[i << 1], self.tree[i << 1 | 1])

	def updateTreeNode(self, idx, value):
		self.tree[idx + self.N] = value
		idx += self.N
		i = idx
		while i > 1:
			self.tree[i >> 1] = self.f(self.tree[i], self.tree[i ^ 1])
			i >>= 1

	def query(self, l, r):
		r += 1
		res = self.initialRes
		l += self.N
		r += self.N
		while l < r:
			if l & 1:
				res = self.f(res, self.tree[l])
				l += 1
			if r & 1:
				r -= 1
				res = self.f(res, self.tree[r])
			l >>= 1
			r >>= 1
		return res

def getMaxSegTree(arr):
	return SegmentTree(arr, lambda a, b: max(a, b), initialRes=-float('inf'))

def getMinSegTree(arr):
	return SegmentTree(arr, lambda a, b: min(a, b), initialRes=float('inf'))

def getSumSegTree(arr):
	return SegmentTree(arr, lambda a, b: a + b, initialRes=0)

def countSwaps(s):
	n = len(s)
	sortedString = list(s)
	sortedString.sort()
	indexMap = dict()
	for (i, c) in enumerate(s):
		indexMap[c] = i
	sumSeg = getSumSegTree([1] * n)
	swapCnt = 0
	for (i, c) in enumerate(sortedString):
		idx = indexMap[c]
		swapCnt += sumSeg.query(0, idx) - 1
		sumSeg.updateTreeNode(idx, 0)
	return swapCnt

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		n = int(input())
		s = input()
		t = input()
		cs = Counter(s)
		ct = Counter(t)
		ok = True
		for c in letters:
			if cs[c] != ct[c]:
				ok = False
				break
		if ok == False:
			allans.append('NO')
		else:
			ok = False
			for c in letters:
				if cs[c] > 1:
					ok = True
					break
			if ok:
				allans.append('YES')
				continue
			else:
				one = countSwaps(s)
				two = countSwaps(t)
				if abs(one - two) % 2 == 0:
					allans.append('YES')
				else:
					allans.append('NO')
	multiLineArrayPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultVal, dimensionArr):
	dv = defaultVal
	da = dimensionArr
	if len(da) == 1:
		return [dv for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


import math
import sys
from collections import defaultdict
from itertools import groupby
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def count_chars(s):
	res = [0] * 26
	for c in s:
		res[ord(c) - ord('a')] += 1
	return res

def inversions_parity(s):
	parity = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if s[i] > s[j]:
				parity ^= 1
	return parity

def main():
	q = ri()
	for _ in range(q):
		n = ri()
		s = input()
		t = input()
		s_stats = count_chars(s)
		t_stats = count_chars(t)
		if s_stats != t_stats:
			print('NO')
		elif any((cnt > 1 for cnt in s_stats)) or any((cnt > 1 for cnt in t_stats)):
			print('YES')
		else:
			print('YES' if inversions_parity(s) == inversions_parity(t) else 'NO')
main()


q = int(input())
while q > 0:
	n = int(input())
	s = str(input())
	t = str(input())
	l1 = [0] * 26
	l2 = l1.copy()
	for index in range(n):
		l1[ord(s[index]) - ord('a')] += 1
		l2[ord(t[index]) - ord('a')] += 1
	ok = True
	for index in range(26):
		if l1[index] != l2[index]:
			ok = False
			print('NO')
			break
	if ok:
		good = False
		for index in range(26):
			if l1[index] >= 2:
				good = True
				print('YES')
				break
		if not good:
			invs = 0
			invt = 0
			for l in range(n):
				for r in range(l + 1, n):
					if s[l] > s[r]:
						invs += 1
					if t[l] > t[r]:
						invt += 1
			if invs & 1 == invt & 1:
				print('YES')
			else:
				print('NO')
	q -= 1


def f(s):
	res = 0
	for i in range(0, len(s)):
		for j in range(0, len(s) - 1):
			if s[j] > s[j + 1]:
				(s[j], s[j + 1]) = (s[j + 1], s[j])
				res = res + 1
	return res
T = int(input())
while T:
	T = T - 1
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	if sorted(s1) != sorted(s2):
		print('NO')
		continue
	flag = False
	for c in range(0, 26):
		if s1.count(chr(ord('a') + c)) > 1 or s2.count(chr(ord('a') + c)) > 1:
			print('YES')
			flag = True
			break
	if flag:
		continue
	if (f(s1) - f(s2)) % 2 == 0:
		print('YES')
	else:
		print('NO')


alph = __import__('string').ascii_lowercase
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	if sorted(s) != sorted(t):
		print('NO')
		continue
	if len({*s}) != len(s) or len({*t}) != len(t):
		print('YES')
		continue
	pos = {}
	j = 0
	for i in s:
		pos[i] = j
		j += 1
	ans = 0
	t = list(t)
	for i in range(n - 1, 0, -1):
		for j in range(i):
			if pos[t[j]] > pos[t[j + 1]]:
				(t[j], t[j + 1]) = (t[j + 1], t[j])
				ans += 1
	print('YNEOS'[ans % 2::2])


from collections import defaultdict
import sys
input = sys.stdin.readline

def getsum(BITTree, i):
	i + 1
	s = 0
	while i > 0:
		s += BITTree[i]
		i -= i & -i
	return s

def updatebit(BITTree, n, i, v):
	i = i + 1
	while i <= n:
		BITTree[i] += v
		i += i & -i
t = int(input())
for i in range(t):
	n = int(input())
	s = [i for i in input() if i != '\n']
	t = [i for i in input() if i != '\n']
	(alpha1, alpha2) = ([0] * 28, [0] * 28)
	for i in range(n):
		alpha1[ord(s[i]) - 97] += 1
		alpha2[ord(t[i]) - 97] += 1
	if alpha1 == alpha2:
		(bit1, bit2) = ([0] * 30, [0] * 30)
		(counter1, counter2) = (0, 0)
		for k in range(n - 1, -1, -1):
			updatebit(bit1, 29, ord(s[k]) - 96, 1)
			counter1 += getsum(bit1, ord(s[k]) - 96)
			updatebit(bit2, 29, ord(t[k]) - 96, 1)
			counter2 += getsum(bit2, ord(t[k]) - 96)
		if counter1 == counter2 or abs(counter1 - counter2) % 2 == 0:
			sys.stdout.write('YES' + '\n')
		elif abs(counter1 - counter2) % 2 == 1:
			for i in alpha1:
				if i >= 2:
					sys.stdout.write('YES' + '\n')
					break
			else:
				sys.stdout.write('NO' + '\n')
	else:
		sys.stdout.write('NO' + '\n')


import sys
from collections import deque
from queue import PriorityQueue
import math
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
for _ in range(ii()):
	n = ii()
	a = list(ip())
	b = list(ip())
	x = [0] * 26
	y = [0] * 26
	for i in a:
		x[ord(i) - 97] += 1
	for i in b:
		y[ord(i) - 97] += 1
	if x != y:
		print('NO')
		continue
	ma = max(x)
	if ma > 1:
		print('YES')
		continue
	t1 = 0
	for i in range(len(a)):
		for j in range(len(a) - 1):
			if a[j] < a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				t1 += 1
	t2 = 0
	for i in range(len(b)):
		for j in range(len(b) - 1):
			if b[j] < b[j + 1]:
				(b[j], b[j + 1]) = (b[j + 1], b[j])
				t2 += 1
	if (t1 - t2) % 2 == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(input())
	t = list(input())
	target = sorted(s)
	if target != sorted(t):
		print('NO')
		continue
	seen = set()
	for c in s:
		if c in seen:
			print('YES')
			break
		seen.add(c)
	else:
		scnt = 0
		for j in range(n - 1):
			for i in range(n - 1):
				if s[i] > s[i + 1]:
					(s[i], s[i + 1]) = (s[i + 1], s[i])
					scnt += 1
		tcnt = 0
		for j in range(n - 1):
			for i in range(n - 1):
				if t[i] > t[i + 1]:
					(t[i], t[i + 1]) = (t[i + 1], t[i])
					tcnt += 1
		if (scnt - tcnt) % 2 == 0:
			print('YES')
		else:
			print('NO')


def inversionCount(s):
	freq = [0 for _ in range(26)]
	inv = 0
	for i in range(len(s)):
		temp = 0
		for j in range(ord(s[i]) - ord('a')):
			temp += freq[j]
		inv += i - temp
		freq[ord(s[i]) - ord('a')] += 1
	return inv

def haveRepeated(S1, S2):
	freq = [0 for _ in range(26)]
	for i in range(len(S1)):
		if freq[ord(S1[i]) - ord('a')] > 0:
			return 1
		freq[ord(S1[i]) - ord('a')] += 1
	for i in range(26):
		freq[i] = 0
	for i in range(len(S2)):
		if freq[ord(S2[i]) - ord('a')] > 0:
			return 1
		freq[ord(S2[i]) - ord('a')] += 1
	return 0

def checkToMakeEqual(S1, S2):
	freq = [0 for _ in range(26)]
	for i in range(len(S1)):
		freq[ord(S1[i]) - ord('a')] += 1
	flag = 0
	for i in range(len(S2)):
		if freq[ord(S2[i]) - ord('a')] == 0:
			flag = 1
			break
		freq[ord(S2[i]) - ord('a')] -= 1
	if flag == 1:
		print('No')
		return
	invCount1 = inversionCount(S1)
	invCount2 = inversionCount(S2)
	if invCount1 == invCount2 or invCount1 % 2 == invCount2 % 2 or haveRepeated(S1, S2) == 1:
		print('Yes')
	else:
		print('No')
T = int(input())
for _ in range(T):
	n = int(input())
	S1 = str(input())
	S2 = str(input())
	checkToMakeEqual(S1, S2)


from collections import *
h = input
q = len
r = range
f = lambda s: (Counter(s), q(set(s)) == q(s) and sum((s[i] > s[j] for i in r(q(s)) for j in r(i, q(s)))) & 1)
for _ in r(int(h())):
	(n, s, t) = (h(), h(), h())
	print('YNEOS'[f(s) != f(t)::2])


I = input
for _ in [0] * int(I()):
	n = int(I())
	s = I()
	t = [*I()]
	p = {}
	j = f = 0
	if sorted(s) != sorted(t):
		print('NO')
		continue
	if len({*s}) != len(s) or len({*t}) != len(t):
		print('YES')
		continue
	for i in s:
		p[i] = j
		j += 1
	for i in range(len(s) - 1, 0, -1):
		for j in range(i):
			if p[t[j]] > p[t[j + 1]]:
				(t[j], t[j + 1]) = (t[j + 1], t[j])
				f += 1
	print('YNEOS'[f & 1::2])


import sys

def getinv(wd, n):
	ind = [-1] * 26
	for i in range(n):
		o = wd[i]
		if ind[o] != -1:
			return (-1, [])
		else:
			ind[o] = i
	ret = []
	a = []
	for i in range(26):
		if ind[i] != -1:
			ret.append(i)
			a.append((i, ind[i]))
	inv = 0
	for i in range(n):
		(val, pos) = a[i]
		for j in range(pos):
			if wd[j] > val:
				inv += 1
	return (inv, ret)
for q in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	wd1 = [ord(h) - 97 for h in sys.stdin.readline().strip()]
	wd2 = [ord(h) - 97 for h in sys.stdin.readline().strip()]
	if sorted(wd1[:]) != sorted(wd2[:]):
		sys.stdout.write('NO\n')
		continue
	(inv1, ret1) = getinv(wd1, n)
	(inv2, ret2) = getinv(wd2, n)
	if inv1 == -1 or inv2 == -1:
		sys.stdout.write('YES\n')
		continue
	if inv1 + inv2 & 1:
		sys.stdout.write('NO\n')
	else:
		sys.stdout.write('YES\n')


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split(' ')))

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

def get_str():
	return input().strip()

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_f():
	n = get_int()
	s = get_str()
	t = get_str()
	Cs = Counter(s)
	Ct = Counter(t)
	for (k, v) in Cs.items():
		if k not in Ct or Ct[k] != v:
			return False
	for (k, v) in Cs.items():
		if v > 1:
			return True
	(inv_s, inv_t) = (0, 0)
	for i in range(n):
		for j in range(i):
			inv_s += s[j] > s[i]
			inv_t += t[j] > t[i]
	return (inv_s + inv_t) % 2 == 0
t = get_int()
for _ in range(t):
	print(yes_no(solve_f()))


import os, sys
from io import BytesIO, IOBase
from collections import Counter

def inv(x):
	arr = [[ord(i) - 97] for i in x]
	ans = 0
	while len(arr) != 1:
		arr1 = []
		for i in range(0, len(arr), 2):
			if i == len(arr) - 1:
				arr1.append(arr[-1])
				continue
			arr1.append([])
			(a, b) = (0, 0)
			for _ in range(len(arr[i]) + len(arr[i + 1])):
				if a == len(arr[i]):
					arr1[-1].append(arr[i + 1][b])
					b += 1
				elif b == len(arr[i + 1]):
					arr1[-1].append(arr[i][a])
					a += 1
				elif arr[i][a] <= arr[i + 1][b]:
					arr1[-1].append(arr[i][a])
					a += 1
				else:
					arr1[-1].append(arr[i + 1][b])
					b += 1
					ans += len(arr[i]) - a
		arr = arr1
	return ans

def solve(n, s, t):
	x = Counter(s)
	if x != Counter(t):
		return 'NO'
	if x[max(x, key=x.get)] >= 2:
		return 'YES'
	if inv(s) & 1 == inv(t) & 1:
		return 'YES'
	return 'NO'

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input().strip()
		t = input().strip()
		print(solve(n, s, t))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
t = int(input())
visa = []
visb = []
for i in range(26):
	visa.append(0)
	visb.append(0)
for tot in range(t):
	n = int(input())
	a = input()
	b = input()
	for i in range(26):
		visa[i] = visb[i] = 0
	for i in a:
		visa[ord(i) - 97] += 1
	for i in b:
		visb[ord(i) - 97] += 1
	flag = 1
	f2 = 0
	for i in range(26):
		if visa[i] != visb[i]:
			flag = 0
		if visa[i] > 1:
			f2 = 1
	if flag:
		if f2:
			print('YES')
		else:
			s = 0
			for i in range(n):
				for j in range(i, n):
					if a[i] > a[j]:
						s ^= 1
			for i in range(n):
				for j in range(i, n):
					if b[i] > b[j]:
						s ^= 1
			if s:
				print('NO')
			else:
				print('YES')
	else:
		print('NO')


from operator import itemgetter

class BIT:

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def add(self, i, val):
		i = i + 1
		while i <= self.n:
			self.bit[i] += val
			i += i & -i

	def _sum(self, i):
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s

	def sum(self, i, j):
		return self._sum(j) - self._sum(i)

def run_length_compress(string):
	string.append('@')
	n = len(string)
	begin = 0
	end = 1
	cnt = 1
	ans = []
	while True:
		if end >= n:
			break
		if string[begin] == string[end]:
			end += 1
			cnt += 1
		else:
			ans.append((cnt, string[begin]))
			begin = end
			end = begin + 1
			cnt = 1
	return ans
q = int(input())
for _ in range(q):
	n = int(input())
	s = list(input())
	t = list(input())
	tmp_s = sorted(s)
	tmp_t = sorted(t)
	s_run = run_length_compress(tmp_s)
	t_run = run_length_compress(tmp_t)
	flag = False
	f = False
	for i in range(len(s_run)):
		if s_run[i][0] >= 2:
			flag = True
		if s_run[i] != t_run[i]:
			print('NO')
			f = True
			break
	if f:
		continue
	if flag:
		print('YES')
		continue
	cnt_s = 0
	cnt_t = 0
	for i in range(n)[::-1]:
		for j in range(i):
			if s[j] > s[j + 1]:
				(s[j], s[j + 1]) = (s[j + 1], s[j])
				cnt_s += 1
			if t[j] > t[j + 1]:
				(t[j], t[j + 1]) = (t[j + 1], t[j])
				cnt_t += 1
	if cnt_s % 2 == cnt_t % 2:
		print('YES')
	else:
		print('NO')


from string import ascii_lowercase
q = int(input())
for _ in range(q):
	n = int(input())
	A = input()
	B = input()
	c_a = {}
	c_b = {}
	ans = False
	if sorted(A) == sorted(B):
		inv_a = 0
		inv_b = 0
		has_multi = False
		for a in A:
			for k in c_a:
				if k > a:
					inv_a += c_a[k]
			if a not in c_a:
				c_a[a] = 0
			c_a[a] += 1
		for b in B:
			for k in c_b:
				if k > b:
					inv_b += c_b[k]
			if b not in c_b:
				c_b[b] = 0
			c_b[b] += 1
		for val in c_a.values():
			has_multi = has_multi or val > 1
		if inv_a % 2 == inv_b % 2:
			ans = True
		elif has_multi:
			ans = True
	if ans:
		print('YES')
	else:
		print('NO')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][0] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res

def inver(s):
	c = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if s[i] > s[j]:
				c += 1
	return c
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	a = [ord(i) for i in s]
	b = [ord(i) for i in t]
	if sorted(a) != sorted(b):
		print('NO')
		continue
	if len(set(a)) != n:
		print('YES')
		continue
	if inver(a) % 2 == inver(b) % 2:
		print('YES')
	else:
		print('NO')


def getInvCount(arr):
	inv_count = 0
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			if arr[i] > arr[j]:
				inv_count += 1
	return inv_count
q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	t = input()
	if set(s) != set(t):
		print('NO')
		continue
	if len(set(s)) < len(s):
		print('YES')
		continue
	elif len(s) <= 26 and getInvCount(list(s)) % 2 == getInvCount(list(t)) % 2:
		print('YES')
	else:
		print('NO')


from collections import Counter
import sys
input = sys.stdin.readline

class Bit:

	def __init__(self, n):
		self.size = n
		self.tree = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def add(self, i, x):
		while i <= self.size:
			self.tree[i] += x
			i += i & -i
q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	t = input()
	if Counter(s) != Counter(t):
		print('NO')
		continue
	elif Counter(s).most_common()[0][1] > 1:
		print('YES')
		continue
	s_list = [ord(s[i]) for i in range(n)]
	t_list = [ord(t[i]) for i in range(n)]
	bit_s = Bit(150)
	inv_s = 0
	for i in range(n - 1, -1, -1):
		inv_s += bit_s.sum(s_list[i])
		bit_s.add(s_list[i], 1)
	bit_t = Bit(150)
	inv_t = 0
	for i in range(n - 1, -1, -1):
		inv_t += bit_t.sum(t_list[i])
		bit_t.add(t_list[i], 1)
	if (inv_s - inv_t) % 2 == 0:
		print('YES')
	else:
		print('NO')


from collections import Counter, defaultdict
from string import ascii_lowercase

def can(e):
	for (k, v) in e.items():
		if {vi & 1 for vi in v} == {0, 1}:
			return True
	return False

def _parity(permutation):
	length = len(permutation)
	elements_seen = [False] * length
	cycles = 0
	for (index, already_seen) in enumerate(elements_seen):
		if already_seen:
			continue
		cycles += 1
		current = index
		while not elements_seen[current]:
			elements_seen[current] = True
			current = permutation[current]
	return (length - cycles) % 2 == 0

def parity(s):
	i = 0
	c = Counter(s)
	e = defaultdict(list)
	for (k, v) in sorted(c.items()):
		for _ in range(v):
			e[k].append(i)
			i += 1
	if can(e):
		return {0, 1}
	p = []
	for ch in s:
		p.append(e[ch].pop())
	return {_parity(p)}
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	if Counter(s) == Counter(t) and parity(s) & parity(t):
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	t = input()
	x = set(s)
	y = set(t)
	if x != y:
		print('NO')
		continue
	if len(x) == n:
		a = [0] * n
		for (i, c) in enumerate(t):
			a[i] = s.find(c)
		yeet = 0
		vis = [False] * n
		for i in range(n):
			if vis[i]:
				continue
			j = i
			cyc = 0
			while not vis[j]:
				cyc += 1
				vis[j] = True
				j = a[j]
			yeet += (cyc - 1) % 2
			yeet %= 2
		if yeet == 0:
			print('YES')
		else:
			print('NO')
		continue
	print('YES')


from collections import Counter

def moves_needed_when_there_is_no_repeated_char(st):
	size_st = len(st)
	sloution = 0
	for _ in range(size_st):
		for ind in range(size_st - 1):
			if st[ind] > st[ind + 1]:
				(st[ind], st[ind + 1]) = (st[ind + 1], st[ind])
				sloution += 1
	return sloution % 2

def check_number_of_chars(st1, st2):
	cnt_a = Counter(st1)
	cnt_b = Counter(st2)
	if cnt_a != cnt_b:
		return False
	else:
		return True

def is_equal(st1, st2, number):
	if st1 == st2:
		return True
	if not check_number_of_chars(st1, st2):
		return False
	if len(set(st1)) < len(st1) or len(set(st2)) < len(st2):
		return True
	if moves_needed_when_there_is_no_repeated_char(st1) == moves_needed_when_there_is_no_repeated_char(st2):
		return True
	else:
		return False
for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	if is_equal(a, b, n):
		print('YES')
	else:
		print('NO')


from collections import *

def f(s):
	c = Counter(s)
	if c.most_common()[0][1] > 1:
		return c
	return (c, sum((s[i] > s[j] for i in range(len(s)) for j in range(i, len(s)))) & 1)
for _ in range(int(input())):
	(n, s, t) = (input(), input(), input())
	print('YNEOS'[f(s) != f(t)::2])


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	table_a = [0] * 26
	table_b = [0] * 26
	for i in range(n):
		table_a[ord(a[i]) - 97] += 1
		table_b[ord(b[i]) - 97] += 1
	flag = 0
	for i in range(26):
		if table_a[i] != table_b[i]:
			flag = -1
			break
		elif table_a[i] > 1:
			flag = 1
	if flag == -1:
		print('NO')
		continue
	if flag == 1:
		print('YES')
		continue
	table_indx = [0] * 26
	for i in range(n):
		table_indx[ord(b[i]) - 97] = i + 1
	count = 0
	incrs = [0] * (n + 1)
	for i in range(n):
		d = table_indx[ord(a[i]) - 97]
		count += abs(incrs[d] + d - (i + 1))
		for j in range(1, d + 1):
			incrs[j] += 1
	if count % 2 == 0:
		print('YES')
	else:
		print('NO')


import random

def count_lens(t):
	t = list(t)
	n = len(t)
	res = 0
	for _ in range(n):
		for k in range(n - 1):
			if t[k] > t[k + 1]:
				(t[k], t[k + 1]) = (t[k + 1], t[k])
				res += 1
	return res % 2

def prog():
	input()
	(a, b) = (input(), input())
	if sorted(a) != sorted(b):
		print('NO')
		return
	if len(set(a)) < len(a):
		print('YES')
		return
	print('YES' if count_lens(a) == count_lens(b) else 'NO')
t = int(input())
for _ in range(t):
	prog()


import sys
input = sys.stdin.readline
q = int(input())
from collections import Counter
for testcases in range(q):
	n = int(input())
	S = input().strip()
	T = input().strip()
	CS = Counter(S)
	CT = Counter(T)
	if CS != CT:
		print('NO')
		continue
	if max(CS.values()) >= 2:
		print('YES')
		continue
	W = [0] * 26
	SA = 0
	for s in S:
		SA += sum(W[ord(s) - 97:])
		W[ord(s) - 97] += 1
	W = [0] * 26
	TA = 0
	for s in T:
		TA += sum(W[ord(s) - 97:])
		W[ord(s) - 97] += 1
	if (SA + TA) % 2 == 0:
		print('YES')
	else:
		print('NO')


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 30, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if a.get_at(m)[0] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

def merge(arr, temp, left, mid, right):
	inv_count = 0
	i = left
	j = mid
	k = left
	while i <= mid - 1 and j <= right:
		if arr[i] <= arr[j]:
			temp[k] = arr[i]
			k += 1
			i += 1
		else:
			temp[k] = arr[j]
			k += 1
			j += 1
			inv_count = inv_count + (mid - i)
	while i <= mid - 1:
		temp[k] = arr[i]
		k += 1
		i += 1
	while j <= right:
		temp[k] = arr[j]
		k += 1
		j += 1
	for i in range(left, right + 1, 1):
		arr[i] = temp[i]
	return inv_count

def _mergeSort(arr, temp, left, right):
	inv_count = 0
	if right > left:
		mid = int((right + left) / 2)
		inv_count = _mergeSort(arr, temp, left, mid)
		inv_count += _mergeSort(arr, temp, mid + 1, right)
		inv_count += merge(arr, temp, left, mid + 1, right)
	return inv_count

def countSwaps(arr, n):
	temp = [0 for i in range(n)]
	return _mergeSort(arr, temp, 0, n - 1)

def minSwaps(arr):
	n = len(arr)
	arrpos = [*enumerate(arr)]
	arrpos.sort(key=lambda it: it[1])
	vis = {k: False for k in range(n)}
	ans = 0
	for i in range(n):
		if vis[i] or arrpos[i][0] == i:
			continue
		cycle_size = 0
		j = i
		while not vis[j]:
			vis[j] = True
			j = arrpos[j][0]
			cycle_size += 1
		if cycle_size > 0:
			ans += cycle_size - 1
	return ans

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	d = defaultdict(list)
	d1 = defaultdict(list)
	f = 0
	for i in range(n):
		d[s[i]].append(i)
		d1[t[i]].append(i)
	if f == 1:
		print('YES')
	else:
		k = 0
		ans = 0
		for i in d:
			if len(d[i]) != len(d1[i]):
				k = 1
				break
			if len(d[i]) > 1 or len(d1[i]) > 1:
				if k == 0:
					k = -1
		if k == -1:
			print('YES')
			continue
		for i in range(n):
			for j in range(i + 1, n):
				if s[i] > s[j]:
					ans += 1
				if t[i] > t[j]:
					ans += 1
		if k == 1 or ans % 2 == 1:
			print('NO')
		else:
			print('YES')


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	c1 = Counter(s)
	c2 = Counter(t)
	if c1 != c2:
		print('NO')
	elif max(c1.values()) >= 2:
		print('YES')
	else:
		c = sorted(s)
		cnt = [0, 0]
		for j in range(n):
			if s[j] != c[j]:
				ind = s.index(c[j])
				s[j:ind + 1] = [c[j]] + s[j:ind]
				cnt[0] += ind - j
			if t[j] != c[j]:
				ind = t.index(c[j])
				t[j:ind + 1] = [c[j]] + t[j:ind]
				cnt[1] += ind - j
		if cnt[0] % 2 == cnt[1] % 2:
			print('YES')
		else:
			print('NO')


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
inf = float('inf')
from functools import cmp_to_key
from collections import defaultdict as dd
from collections import Counter, deque
from heapq import *
import math
from math import floor, ceil, sqrt

def geti():
	return map(int, input().strip().split())

def getl():
	return list(map(int, input().strip().split()))

def getis():
	return map(str, input().strip().split())

def getls():
	return list(map(str, input().strip().split()))

def gets():
	return input().strip()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def inversions(s, good):
	count = dd(int)
	inv = 0
	for i in s:
		for j in count:
			if j > i:
				inv += count[j]
		count[i] += 1
		if count[i] >= 2:
			good[0] = True
	return inv

def solve():
	for _ in range(geta()):
		n = geta()
		s = gets()
		t = gets()
		good = [False]
		one = inversions(s, good)
		two = inversions(t, good)
		if Counter(s) != Counter(t):
			print('NO')
			continue
		if abs(one - two) % 2 == 0 or good[0]:
			print('YES')
		else:
			print('NO')
solve()


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
q = ri()
for _ in range(q):
	n = ri()
	s = input()
	t = input()
	cnt_s = Counter(s)
	cnt_t = Counter(t)
	if cnt_s != cnt_t:
		ans = 'NO'
	else:
		have_double = False
		for i in cnt_s.values():
			if i > 1:
				have_double = True
				break
		if have_double:
			ans = 'YES'
		else:
			inv_s = 0
			inv_t = 0
			for i in range(n - 1):
				for j in range(i + 1, n):
					if s[i] > s[j]:
						inv_s += 1
					if t[i] > t[j]:
						inv_t += 1
			if inv_s % 2 == inv_t % 2:
				ans = 'YES'
			else:
				ans = 'NO'
	print(ans)


from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
mod = 10 ** 9 + 7

def mergeSort(arr, n):
	temp_arr = [0] * n
	return _mergeSort(arr, temp_arr, 0, n - 1)

def _mergeSort(arr, temp_arr, left, right):
	inv_count = 0
	if left < right:
		mid = (left + right) // 2
		inv_count = _mergeSort(arr, temp_arr, left, mid)
		inv_count += _mergeSort(arr, temp_arr, mid + 1, right)
		inv_count += merge(arr, temp_arr, left, mid, right)
	return inv_count

def merge(arr, temp_arr, left, mid, right):
	i = left
	j = mid + 1
	k = left
	inv_count = 0
	while i <= mid and j <= right:
		if arr[i] <= arr[j]:
			temp_arr[k] = arr[i]
			k += 1
			i += 1
		else:
			temp_arr[k] = arr[j]
			inv_count += mid - i + 1
			k += 1
			j += 1
	while i <= mid:
		temp_arr[k] = arr[i]
		k += 1
		i += 1
	while j <= right:
		temp_arr[k] = arr[j]
		k += 1
		j += 1
	for loop_var in range(left, right + 1):
		arr[loop_var] = temp_arr[loop_var]
	return inv_count
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	if sorted(s) != sorted(t):
		print('NO')
	else:
		hash = defaultdict(int)
		flag = 0
		for i in s:
			hash[i] += 1
			if hash[i] > 1:
				print('YES')
				flag = 1
				break
		if not flag:
			l1 = [ord(i) for i in s]
			l2 = [ord(i) for i in t]
			z1 = mergeSort(l1, n)
			z2 = mergeSort(l2, n)
			if z1 % 2 != z2 % 2:
				print('NO')
			else:
				print('YES')


def count_bits(x):
	c = 0
	while x > 0:
		c += x & 1
		x >>= 1
	return c

def swaps_required(ixs):
	memb = 0
	ans = 0
	n = len(ixs)
	for i in range(n):
		bits = count_bits(memb >> ixs[i])
		ans += ixs[i] - i + bits
		memb += 1 << ixs[i]
	return ans

def can_match(s, t):
	n = len(s)
	ss = sorted([(c, i) for (i, c) in enumerate(s)])
	ts = sorted([(c, i) for (i, c) in enumerate(t)])
	for i in range(n):
		if ss[i][0] != ts[i][0]:
			return 'NO'
	for i in range(1, n):
		if ss[i][0] == ss[i - 1][0]:
			return 'YES'
	paritys = swaps_required([i for (_, i) in ss]) % 2
	parityt = swaps_required([i for (_, i) in ts]) % 2
	if paritys == parityt:
		return 'YES'
	else:
		return 'NO'
t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	s = input().strip()
	t = input().strip()
	print(can_match(s, t))


for _ in range(int(input())):
	n = int(input())
	(s1, s2) = (input(), input())
	(a1, a2) = ([0] * 26, [0] * 26)
	for v in map(ord, s1):
		a1[v - 97] += 1
	for v in map(ord, s2):
		a2[v - 97] += 1
	if a1 != a2:
		print('NO')
		continue
	if max(a1) > 1:
		print('YES')
		continue
	inv1 = sum((c1 > c2 for (i, c1) in enumerate(s1) for c2 in s1[i + 1:]))
	inv2 = sum((c1 > c2 for (i, c1) in enumerate(s2) for c2 in s2[i + 1:]))
	print('YES' if inv1 % 2 == inv2 % 2 else 'NO')