Chef has two strings A and B of lengths N and M respectively.

Chef can rearrange both strings in any way he wants. Let the rearranged string of A be A' and the rearranged string of B be B'. 

Determine whether we can construct rearrangements A' and B' such that (A' + B') is a palindrome.

Here + denotes the concatenation operation. For e.g. {abc} + {xyz} = {abcxyz}.

Note: A string is called palindrome if it reads the same backwards and forwards, for e.g. \texttt{noon} and \texttt{level} are palindromic strings.

------ Input Format ------ 

- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first line of each test case contains two integers N and M — the length of the strings A and B respectively.
- The second line of each test case contains a string A of length N containing lowercase Latin letters only.
- The third line of each test case contains a string B of length M containing lowercase Latin letters only.

------ Output Format ------ 

For each test case, output YES if we can rearrange A and B such that (A' + B') becomes a palindrome. Otherwise, output NO.

You may print each character of YES and NO in uppercase or lowercase (for example, yes, yEs, Yes will be considered identical).

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

$1 ≤ T ≤ 10^{5}$
$1 ≤ N, M ≤ 2 \cdot 10^{5}$
$A$ and $B$ consist of lowercase Latin letters only.
- The sum of $N + M$ over all test cases does not exceed $2 \cdot 10^{5}$.

----- Sample Input 1 ------ 
4
5 2
abcdd
ac
3 3
abc
xyz
2 4
aa
aaaa
1 3
a
aax

----- Sample Output 1 ------ 
YES
NO
YES
NO

----- explanation 1 ------ 
Test case $1$: We can rearrange $A$ to $A' = acdbd$ and $B$ to $B' = ca$. So $A' + B' = acdbdca$ which is palindromic.

Test case $2$: We can not rearrange $A$ and $B$ such that $A' + B'$ is palindromic.

Test case $3$: For $A' = aa$ and $B' = aaaa$, $A' + B' = aaaaaa$ is palindromic.

Difficulty: MEDIUM

Solutions:
from collections import Counter

def solve(s1, s2, m, n):
	s = s1 + s2
	dic = {}
	for i in range(m + n):
		if s[i] not in dic.keys():
			dic[s[i]] = 1
		else:
			dic[s[i]] += 1
	c = 0
	for v in dic.values():
		if v & 1 == 1:
			c += 1
		if c >= 2:
			return 'NO'
	if n > m:
		(s1, s2) = (s2, s1)
	dic1 = Counter(s1)
	for ele in s2:
		if ele not in dic1.keys() or dic1[ele] == 0:
			return 'NO'
		dic1[ele] -= 1
	return 'YES'
T = int(input())
for i in range(T):
	inpArr = input().split()
	(m, n) = list(map(int, inpArr))
	s1 = input()
	s2 = input()
	ans = solve(s1, s2, m, n)
	print(ans)


from collections import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	s1 = input()
	count = Counter(s + s1)
	count1 = Counter(s)
	count2 = Counter(s1)
	g = True
	if len(s) >= len(s1):
		for x in count2:
			if count1[x] < count2[x]:
				g = False
				break
	else:
		for x in count1:
			if count2[x] < count1[x]:
				g = False
				break
	f = 0
	if (m + n) % 2 == 0 and g:
		for x in count.keys():
			if count[x] % 2 != 0:
				f = 1
				break
		if f == 0:
			print('YES')
		else:
			print('NO')
	elif (m + n) % 2 == 1 and g:
		for x in count.keys():
			if count[x] % 2 != 0:
				f = f + 1
			if f == 2:
				break
		if f == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def isPalindrome(s):
	odd = 0
	for elem in set(s):
		if s.count(elem) % 2 != 0:
			odd += 1
	return odd < 2
for i in range(int(input())):
	(n, m) = map(int, input().split())
	A = input()
	B = input()
	if n < m:
		(A, B) = (B, A)
	for elem in B:
		if elem not in A:
			print('NO')
			break
		A = A.replace(elem, '', 1)
	else:
		if isPalindrome(A):
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	z = 0
	if n < m:
		(a, b) = (b, a)
	for j in b:
		if j not in a:
			print('NO')
			break
		a = a.replace(j, '', 1)
	else:
		for j in set(a):
			if a.count(j) % 2:
				z = z + 1
		if z < 2:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	s1 = list(input())
	s2 = list(input())
	cs = []
	condition = 'YES'
	if m > n:
		(m, n) = (n, m)
		(s1, s2) = (s2, s1)
	j = 0
	while j < len(s2):
		if s2[j] in s1:
			cs.append(s2[j])
			s1.remove(s2[j])
			s2.pop(j)
		else:
			condition = 'NO'
			break
	oc = 0
	tot = 0
	l = len(s1)
	for j in 'abcdefghijklmnopqrstuvwxyz':
		c = s1.count(j)
		tot += c
		if c % 2:
			oc += 1
		if l % 2 and oc > 1:
			condition = 'NO'
		elif l % 2 == 0 and oc > 0:
			condition = 'NO'
		if tot == l:
			break
	print(condition)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(input())
	b = list(input())
	c = 0
	(d, e) = (0, 0)
	if n > m:
		(n, m) = (m, n)
		(a, b) = (b, a)
	for i in a:
		if i in b:
			b.remove(i)
		else:
			print('NO')
			c = 1
			break
	if c == 0:
		s = set(b)
		for i in s:
			if b.count(i) % 2 != 0:
				d += 1
				if d > 1:
					print('NO')
					c = 1
					break
		if c == 0:
			print('YES')


testcases = int(input())
for _ in range(testcases):
	(length1, length2) = map(int, input().split())
	s1 = input()
	s2 = input()
	if length2 > length1:
		(s1, s2) = (s2, s1)
	if True:
		s1 = list(s1)
		s2 = list(s2)
		copy_s2 = list(s2)
		for i in range(0, len(s2)):
			if copy_s2[i] in s1:
				s1.remove(copy_s2[i])
				s2.remove(copy_s2[i])
		if len(s2) != 0:
			print('NO')
		else:
			b = {}
			for i in s1:
				if i in b:
					b[i] += 1
				else:
					b[i] = 1
			count = 0
			for i in b.values():
				if i % 2 == 1:
					count += 1
			if count > 1:
				print('NO')
			else:
				print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	if n < m:
		(n, m) = (m, n)
		(s1, s2) = (s2, s1)
	d1 = {}
	d2 = {}
	for i in range(n):
		if s1[i] in d1:
			d1[s1[i]] += 1
		else:
			d1[s1[i]] = 1
	for i in range(m):
		if s2[i] in d2:
			d2[s2[i]] += 1
		else:
			d2[s2[i]] = 1
	for i in d2:
		if i not in d1:
			print('NO')
			break
		elif d2[i] > d1[i]:
			print('NO')
			break
		d1[i] -= d2[i]
	else:
		odd = 0
		for i in d1:
			if d1[i] % 2:
				odd += 1
		if (n - m) % 2:
			if odd == 1:
				print('YES')
			else:
				print('NO')
		elif odd == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n1, n2) = list(map(int, input().split()))
	st1 = input()
	st = input()
	if n1 < n2:
		s1 = st
		s2 = st1
	else:
		s1 = st1
		s2 = st
	dic = {}
	f = 0
	for i in s1:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	for i in s2:
		if i in dic:
			dic[i] -= 1
			if dic[i] == 0:
				dic.pop(i)
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		k = 0
		for i in dic:
			if dic[i] % 2 != 0:
				k += 1
		if k <= 1:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(l, r) = map(int, input().split(' '))
	left = input()
	right = input()
	m = []
	for j in set(left):
		if left.count(j) == right.count(j):
			pass
		elif left.count(j) > right.count(j):
			rem = left.count(j) - right.count(j)
			if rem % 2 == 0:
				m.append(0)
			else:
				m.append(1)
	n = []
	for j in set(right):
		if left.count(j) == right.count(j):
			pass
		elif left.count(j) < right.count(j):
			rem = right.count(j) - left.count(j)
			if rem % 2 == 0:
				n.append(0)
			else:
				n.append(1)
	if len(n) == 0 and m.count(1) > 1:
		print('NO')
	elif len(m) == 0 and n.count(1) > 1:
		print('NO')
	elif len(n) != 0 and len(m) != 0:
		print('NO')
	else:
		print('YES')


from collections import Counter

def solve(a, b, m, n):
	(a, b) = (b, a) if m < n else (a, b)
	(ca, cb) = (Counter([c for c in a]), Counter([c for c in b]))
	if len(cb - ca) > 0:
		return 'NO'
	a = ca - cb
	(l, c) = (0, 0)
	for v in a.values():
		l += v
		c += 1 if v & 1 == 1 else 0
	if c == l & 1:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	(m, n) = list(map(int, input().split()))
	a = input()
	b = input()
	print(solve(a, b, m, n))


def solve():
	(m, n) = map(int, input().split())
	(a, b) = (input().strip(), input().strip())
	if n > m:
		(a, b) = (b, a)
		(m, n) = (n, m)
	mp = {}
	for c in a:
		mp[c] = mp.get(c, 0) + 1
	for c in b:
		mp[c] = mp.get(c, 0) - 1
	odd = 0
	for val in mp.values():
		if val < 0:
			return False
		if val % 2:
			odd += 1
	return odd <= 1
t = int(input().strip())
for _ in range(t):
	if solve():
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	a = input()
	b = input()
	c = dict()
	d = dict()
	for i in a:
		if i in c:
			c[i] += 1
		else:
			c[i] = 1
	for i in b:
		if i in c:
			c[i] -= 1
			if c[i] == 0:
				c.pop(i)
		elif i in d:
			d[i] += 1
		else:
			d[i] = 1
	if c != {} and d != {}:
		print('NO')
		continue
	if len(c):
		odd = 0
		for i in c:
			if c[i] % 2 != 0:
				odd += 1
		if odd > 1:
			print('NO')
			continue
	elif len(d):
		odd = 0
		for i in d:
			if d[i] % 2 != 0:
				odd += 1
		if odd > 1:
			print('NO')
			continue
	print('YES')


def isPalindrome(s1, s2, m, n):
	dc1 = {}
	dc2 = {}
	for i in s1:
		if i in dc1:
			dc1[i] += 1
		else:
			dc1[i] = 1
	for i in s2:
		if i in dc1:
			dc1[i] -= 1
			if dc1[i] == 0:
				dc1.pop(i)
		elif i in dc2:
			dc2[i] += 1
		else:
			dc2[i] = 1
	if dc1 != {} and dc2 != {}:
		return 'NO'
	if dc1:
		od = 0
		for i in dc1:
			if dc1[i] % 2 != 0:
				od += 1
		if od > 1:
			return 'NO'
	elif dc2:
		od = 0
		for i in dc2:
			if dc2[i] % 2 != 0:
				od += 1
		if od > 1:
			return 'NO'
	return 'YES'

def main():
	t = int(input())
	for _ in range(t):
		(m, n) = map(int, input().split())
		s1 = input()
		s2 = input()
		print(isPalindrome(s1, s2, m, n))
main()


from collections import defaultdict
import math as mt
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	(mp1, mp2) = (defaultdict(int), defaultdict(int))
	for i in s1:
		mp1[i] += 1
	for i in s2:
		mp2[i] += 1
	for i in set(s1):
		if i in mp2:
			if mp2[i] > mp1[i]:
				mp2[i] -= mp1[i]
				del mp1[i]
			elif mp1[i] > mp2[i]:
				mp1[i] -= mp2[i]
				del mp2[i]
			else:
				del mp2[i]
				del mp1[i]
	if len(mp1) and len(mp2):
		print('NO')
	else:
		cnt = 0
		for i in mp1:
			cnt += mp1[i] & 1
		for i in mp2:
			cnt += mp2[i] & 1
		if cnt > 1:
			print('NO')
		else:
			print('YES')


t = int(input())
while t > 0:
	(m, n) = input().split()
	m = int(m)
	n = int(n)
	s1 = input()
	s2 = input()
	d = {}
	d1 = {}
	d2 = {}
	for i in range(m):
		if s1[i] in d.keys():
			d[s1[i]] += 1
		else:
			d[s1[i]] = 1
		if s1[i] in d1.keys():
			d1[s1[i]] += 1
		else:
			d1[s1[i]] = 1
	for i in range(n):
		if s2[i] in d.keys():
			d[s2[i]] += 1
		else:
			d[s2[i]] = 1
		if s2[i] in d2.keys():
			d2[s2[i]] += 1
		else:
			d2[s2[i]] = 1
	odd = 0
	even = 0
	odd_string = 0
	for i in d.keys():
		if d[i] % 2 == 0:
			even += 1
		else:
			if odd_string == 0:
				odd_string = i
			odd += 1
	cnt = 0
	if odd >= 2:
		print('NO')
	else:
		for i in d.keys():
			if i not in d1.keys():
				d1[i] = 0
			if i not in d2.keys():
				d2[i] = 0
			if d1[i] > d2[i] and m <= n or (d1[i] < d2[i] and m >= n):
				cnt += 1
		if cnt >= 1:
			print('NO')
		else:
			print('YES')
	t -= 1


t = int(input())
while t > 0:
	(len1, len2) = map(int, input().split())
	s1 = input()
	s2 = input()
	if len2 > len1:
		s = s1
		s1 = s2
		s2 = s
	f = [0] * 26
	for i in s1:
		asc = ord(i)
		f[asc - 97] = f[asc - 97] + 1
	for i in s2:
		asc = ord(i)
		f[asc - 97] = f[asc - 97] - 1
	flag = 0
	c = 0
	for i in range(0, 26):
		if f[i] < 0:
			flag = 1
			break
		if f[i] % 2 == 0:
			continue
		if f[i] % 2 != 0:
			c = c + 1
	if flag == 1:
		print('NO')
	elif abs(len1 - len2) % 2 == 0 and c == 0:
		print('YES')
	elif abs(len1 - len2) % 2 != 0 and c == 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


from collections import Counter
t = int(input())
while t > 0:
	(n, m) = map(int, input().strip().split())
	x = input()
	y = input()
	if len(x) < len(y):
		for i in x:
			if i in y:
				y = y.replace(i, '', 1)
				x = x.replace(i, '', 1)
	else:
		for i in y:
			if i in x:
				x = x.replace(i, '', 1)
				y = y.replace(i, '', 1)
	if x == '' or y == '':
		temp = x + y
		z = Counter(temp)
		c = 0
		for i in z.values():
			if i % 2 == 1:
				c += 1
		if c <= 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	if len(s1) < len(s2):
		(s1, s2) = (s2, s1)
	d = {}
	ans = True
	for i in s1:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in s2:
		if i not in d or d[i] <= 0:
			ans = False
			break
		else:
			d[i] -= 1
	if ans:
		od = 0
		for i in d:
			if d[i] & 1:
				od += 1
		if n + m & 1:
			if od == 1:
				print('YES')
			else:
				print('NO')
		elif od == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	f = [0] * 128
	if m > n:
		(n, m) = (m, n)
		(s1, s2) = (s2, s1)
	for ch in s1:
		f[ord(ch)] += 1
	for ch in s2:
		f[ord(ch)] -= 1
	(flag, cnt) = (True, 0)
	for i in range(128):
		if f[i] < 0:
			flag = False
			break
		if f[i] % 2 == 0:
			continue
		if cnt:
			flag = False
		else:
			cnt = 1
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for j in range(t):
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	odd = 0
	if n < m:
		(s1, s2) = (s2, s1)
	for i in s2:
		if i not in s1:
			print('NO')
			break
		s1 = s1.replace(i, '', 1)
	else:
		for i in set(s1):
			if s1.count(i) % 2:
				odd = odd + 1
		if odd < 2:
			print('YES')
		else:
			print('NO')


for t in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	d = 0
	s1 = input()
	s2 = input()
	if len(s1) < len(s2):
		for i in s1:
			if i in s2:
				s1 = s1.replace(i, '', 1)
				s2 = s2.replace(i, '', 1)
	else:
		for i in s2:
			if i in s1:
				s1 = s1.replace(i, '', 1)
				s2 = s2.replace(i, '', 1)
	if s1 == '' or s2 == '':
		s = s1 + s2
		from collections import Counter
		d = Counter(s)
		for j in d.values():
			if j % 2 != 0:
				c = c + 1
		if c == 0 or c == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import string
from functools import lru_cache
import atexit, io
import sys
from math import log2
import math
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right, insort
from math import gcd
from math import sqrt
from collections import Counter, defaultdict
from heapq import heappush, heappop, heapify
import heapq

class FenwickTree:

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

	def prefixSum(self, idx):
		s = 0
		while idx > 0:
			s += self.farr[idx]
			idx -= idx & -idx
		return s

	def update(self, idx, val):
		while idx < len(self.farr):
			self.farr[idx] += val
			idx += idx & -idx

	def find(self, k):
		curr = 0
		ans = 0
		prevSum = 0
		for i in range(log2(n), -1, -1):
			if self.farr[curr + (i << i)] + prevSum < k:
				curr += 1 << i
				prevSum += self.farr[curr]
		return curr + 1

class Trie(object):

	def __init__(self):
		self.trie = {}

	def insert(self, word):
		t = self.trie
		for c in word:
			if c not in t:
				t[c] = {}
			t = t[c]
		t['-'] = True

	def search(self, word):
		t = self.trie
		for c in word:
			if c not in t:
				return False
			t = t[c]
		return '-' in t

	def startsWith(self, prefix):
		t = self.trie
		for c in prefix:
			if c not in t:
				return False
			t = t[c]
		return True

	def query(self, word):
		ans = 0
		t = self.trie
		for i in word:
			if i not in t:
				break
			ans += 1
			t = t[i]
		return ans

class FenvTree:

	def __init__(self, arr):
		arr.insert(0, 0)
		self.farr = [0]
		prefix = [0]
		for i in arr[1:]:
			prefix.append(prefix[-1] + i)
		for i in range(1, len(arr)):
			idash = i - (i & -i)
			self.farr.append(prefix[i] - prefix[idash])

	def query(self, l, r):
		return self.prefixSum(r) - self.prefixSum(l - 1)

	def prefixSum(self, idx):
		s = 0
		while idx > 0:
			s += self.farr[idx]
			idx -= idx & -idx
		return s

	def update(self, idx, val):
		while idx < len(self.farr):
			self.farr[idx] += val
			idx += idx & -idx

class DSU:

	def __init__(self, n):
		self.parent = []
		self.size = []
		for i in range(n + 1):
			self.parent.append(i)
			self.size.append(1)

	def union(self, u, v):
		pu = self.findPar(u)
		pv = self.findPar(v)
		if pu == pv:
			return
		if self.size[pu] < self.size[pv]:
			self.parent[pu] = pv
			self.size[pv] += self.size[pu]
		else:
			self.parent[pv] = pu
			self.size[pu] += self.size[pv]

	def unionByRank(self, u, v):
		pu = self.findPar(u)
		pv = self.findPar(v)
		if pu == pv:
			return
		if self.rank[pu] < self.rank[pv]:
			self.parent[pu] = pv
		elif self.rank[pv] < self.rank[pu]:
			self.parent[pv] = pu
		else:
			self.parent[pu] = pv
			self.rank[pv] += 1

	def findPar(self, node):
		if self.parent[node] == node:
			return node
		self.parent[node] = self.findPar(self.parent[node])
		return self.parent[node]

class info:

	def __init__(self, _open=0, _close=0, _full=0):
		self.open = _open
		self.close = _close
		self.full = _full

class SGTree:

	def __init__(self, n):
		self.seg = [0 for _ in range(4 * n)]

	def build(self, ind, low, high, arr):
		if low == high:
			self.seg[ind] = arr[low]
			return
		mid = (low + high) // 2
		self.build(2 * ind + 1, low, mid, arr)
		self.build(2 * ind + 2, mid + 1, high, arr)
		self.seg[ind] = min(self.seg[2 * ind + 1], self.seg[2 * ind + 2])

	def query(self, ind, low, high, l, r):
		if r < low or l > high:
			return sys.maxsize
		if low <= l and r >= high:
			return self.seg[ind]
		mid = low + high >> 1
		left = self.query(2 * ind + 1, 0, mid, l, r)
		right = self.query(2 * ind + 2, mid + 1, high, l, r)
		return min(left, right)

	def update(self, ind, low, high, i, val):
		if low == high:
			self.seg = val
			return
		mid = low + high >> 1
		if i <= mid:
			self.update(2 * ind + 1, low, mid, i, val)
		else:
			self.update(2 * ind + 1, mid + 1, high, i, val)
		self.seg[ind] = min(self.seg[2 * ind + 1], self.seg[2 * ind + 2])

def isPalindrome(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

def IntList():
	return list(map(int, sys.stdin.readline().strip().split()))

def getInts():
	return map(int, sys.stdin.readline().strip().split())

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

def StrList():
	list(sys.stdin.readline().strip())

def FloatList():
	lis = input().split()
	lis = list(map(float, lis))
	return lis

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

def findPrimePair(n):
	isPrime = [0] * (n + 1)
	SieveOfEratosthenes(n, isPrime)
	for i in range(0, n):
		if isPrime[i] and isPrime[n - i]:
			print(i, n - i)
			return

def query(ind, low, high, l, r, seg):
	if r < low or l > high:
		return info()
	if low <= l and r >= high:
		return self.seg[ind]
	mid = low + high >> 1
	left = self.query(2 * ind + 1, 0, mid, l, r, seg)
	right = self.query(2 * ind + 2, mid + 1, high, l, r, seg)
	return merge(left, right)

def merge(left, right):
	ans = info()
	ans.full = left.full + right.full + min(left.open, right.close)
	ans.open = left.open + right.open + min(left.open, right.close)
	ans.close = left.close + right.close + min(left.open, right.close)
	return ans

def build(ind, low, high, s, seg):
	if low == high:
		seg[ind] = info(s[low] == '(', s[low] == ')', 0)
		return
	mid = (low + high) // 2
	build(2 * ind + 1, low, mid, s, seg)
	build(2 * ind + 2, mid + 1, high, s, seg)
	seg[ind] = merge(seg[2 * ind + 1], seg[2 * ind + 2])

def countN(lis):
	ans = 0
	cnt = 0
	for i in range(len(lis) - 1, -1, -1):
		if lis[i] == 0:
			cnt += 1
		else:
			ans += cnt
	return ans

class Pair:

	def __init__(self, x, y, gcd):
		self.x = x
		self.y = y
		self.gcd = gcd

def Euclidean(a, b):
	if b == 0:
		return Pair(1, 0, a)
	dash = Euclidean(b, a % b)
	return Pair(dash.y, dash.x - a // b * dash.y, dash.gcd)

def chineseRemainder(a1, n1, a2, n2):
	p = Euclidean(n1, n2)
	x = p.x
	gcd = p.gcd
	if (a1 - a2) % gcd:
		return -1
	k = (a1 - a2) // gcd
	a = a1 - n1 * (k * x % n2 // gcd)
	lcm = n1 * n2 // gcd
	if a < 0:
		a += lcm
	return a
mdd = 998244353

def ncr(n, k, md):
	mod = 998244353
	tab = [[0 for _ in range(k + 1)] for i in range(n + 1)]
	for i in range(1, len(tab)):
		tab[i][0] = 1
	for i in range(1, len(tab)):
		for j in range(1, min(i + 1, len(tab[0]))):
			if i == 1 and j == 1:
				tab[i][j] = 1
			else:
				tab[i][j] = (tab[i - 1][j] + tab[i - 1][j - 1]) % mod
	return tab

def repeat(i, j, arr):
	if i > j:
		return
	cnt1 = i
	cnt2 = j
	while cnt1 < cnt2:
		(arr[cnt1], arr[cnt2]) = (arr[cnt2], arr[cnt1])
		cnt1 += 1
		cnt2 -= 1
	if i - 1 >= 0:
		ele = arr[i - 1]
		if ele > 0:
			s = int(sqrt(ele - 1)) + 1
			first = s * s - ele
			repeat(first, i - 1, arr)
	return
spf = []

def makeSeive(n):
	for i in range(n + 1):
		spf.append(i)

def seive(n):
	s = int(sqrt(n + 1))
	for i in range(2, s + 1):
		if spf[i] == i:
			for j in range(i * i, n + 1, i):
				if spf[j] == j:
					spf[j] = i

def getFactorization(x):
	ret = set()
	while x != 1:
		ret.add(spf[x])
		x = x // spf[x]
	return ret

def zFunc(patt, txt):
	st = patt + '#' + txt
	zArray = [0 for _ in range(len(st))]
	l = 0
	r = 0
	for i in range(1, len(st)):
		if r >= i:
			zArray[i] = min(r - i + 1, zArray[i - l])
		while i + zArray[i] < len(st) and st[zArray[i]] == st[zArray[i] + i]:
			zArray[i] += 1
		if zArray[i] + i - 1 > r:
			l = i
			r = i + zArray[i] - 1
	return zArray.count(len(patt))

def kmp(txt, patt):
	newString = patt + '#' + txt
	freqCount = 0
	freqArray = [0 for _ in range(len(newString))]
	i = 1
	length = 0
	while i < len(newString):
		if newString[i] == newString[length]:
			length += 1
			freqArray[i] = length
			i += 1
		elif length > 0:
			length = freqArray[length - 1]
		else:
			freqArray[i] = 0
			i += 1
	for i in freqArray:
		if i == len(patt):
			freqCount += 1
	return freqCount

def getLPS(s):
	st = '@#' + '#'.join(s) + '#&'
	c = 0
	r = 0
	lps = [0] * len(st)
	for i in range(1, len(st) - 1):
		mirror = c - (i - c)
		if i < r and mirror >= 0:
			lps[i] = min(lps[mirror], r - i)
		while st[i + lps[i] + 1] == st[i - lps[i] - 1]:
			lps[i] += 1
		if i + lps[i] > r:
			r = i + lps[i]
			c = i
	return max(lps)
fact = [1 for _ in range(100002)]
mod = 10 ** 9 + 7

def getFact(n):
	for i in range(1, n + 1):
		fact[i] = fact[i - 1] * i % mod

def getInv(word):
	num = math.factorial(len(word))
	for v in Counter(word).values():
		num = num * pow(math.factorial(v), mod - 2, mod) % mod
	return int(num) % (10 ** 9 + 7)

def subarrayXor(arr, n, m):
	HashTable = defaultdict(bool)
	HashTable[0] = 1
	count = 0
	curSum = 0
	for i in arr:
		curSum ^= i
		if HashTable[curSum ^ m]:
			count += HashTable[curSum ^ m]
		HashTable[curSum] += 1
	return count

def get2dPrefixSum(matrix, mid=0):
	n = len(matrix)
	m = len(matrix[0])
	prefix = [[0 for _ in range(m + 1)] for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + matrix[i - 1][j - 1]
	return prefix

def get2dPrefixSumCnt(matrix, mid=0):
	n = len(matrix)
	m = len(matrix[0])
	prefix = [[0 for _ in range(m + 1)] for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + matrix[i - 1][j - 1]
	return prefix

def getSumRange(r1, c1, r2, c2, prefix):
	cnt = prefix[r2][c2] - prefix[r2][c1 - 1] - prefix[r1 - 1][c2] + prefix[r1 - 1][c1 - 1]
	return cnt

def getPrefix(arr):
	prefix = [0]
	for i in arr:
		prefix.append(prefix[-1] + i)
	return prefix

def getInv(arr):
	cnt = 0
	ans = []
	for i in arr:
		ind = bisect_right(ans, i)
		cnt += len(ans) - ind
		insort(ans, i)
	return cnt
M = 10 ** 5

def getFactors(x):
	temp = []
	k = 1
	while k * k <= x:
		if x % k == 0:
			temp.append(k)
			if k * k != x:
				temp.append(x // k)
		k += 1
	return temp

def grayCode(n):
	if not n:
		return [0]
	res = [0, 1]
	for i in range(2, n + 1):
		for j in range(len(res) - 1, -1, -1):
			res.append(res[j] | 1 << i - 1)
	return res

def threeSum(nums, target):
	ans = -1
	d = dict()
	for (i, j) in enumerate(nums):
		d[j] = i + 1
	nums.sort()
	for i in range(len(nums) - 2):
		low = i + 1
		high = len(nums) - 1
		while low < high:
			s = nums[i] + nums[low] + nums[high]
			if s == target:
				print(d[nums[low]], d[nums[high]], d[nums[i]])
				return
				low += 1
				high -= 1
			elif s < 0:
				low = low + 1
			else:
				high -= 1
	print('IMPOSSIBLE')
	return

def FuckCF():
	(a, b) = map(int, input().split())
	s1 = input()
	s2 = input()
	c1 = Counter(s1)
	c2 = Counter(s2)
	if b < a:
		(c1, c2) = (c2, c1)
	for (i, j) in c1.items():
		if j > c2[i]:
			print('NO')
			return
	cnt = 0
	for (i, j) in c2.items():
		if abs(j - c1[i]) % 2:
			cnt += 1
	if cnt > 1:
		print('NO')
	else:
		print('YES')
t = 1
t = int(input())
for i in range(t):
	FuckCF()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s1 = input()
	s2 = input()
	dic = {}
	if b > a:
		(s1, s2) = (s2, s1)
	for i in s1:
		if i not in dic:
			dic[i] = 1
		else:
			dic[i] += 1
	for i in s2:
		if i in dic:
			dic[i] -= 1
		else:
			dic[i] = -1
	count = 0
	f = 0
	for i in dic:
		if dic[i] < 0:
			f = 1
			break
		elif dic[i] % 2 != 0:
			count += 1
	if f == 1 or count > 1:
		print('NO')
	else:
		print('YES')


test = int(input())
for _ in range(test):
	(n, m) = map(int, input().split())
	s = input()
	s2 = input()
	freq = [0] * 128
	if m > n:
		(n, m) = (m, n)
		(s, s2) = (s2, s)
	for ch in s:
		freq[ord(ch)] += 1
	for ch in s2:
		freq[ord(ch)] -= 1
	(flag, cnt) = (True, 0)
	for i in range(128):
		if freq[i] < 0:
			flag = False
			break
		if freq[i] % 2 == 0:
			continue
		if cnt:
			flag = False
		else:
			cnt = 1
	if flag:
		print('YES')
	else:
		print('NO')


case = int(input())
for _ in range(case):
	(m, n) = map(int, input().split(' '))
	s1 = input()
	s2 = input()
	s1dic = {}
	s2dic = {}
	for i in range(m):
		if s1[i] not in s1dic:
			s1dic[s1[i]] = 0
		s1dic[s1[i]] += 1
	for i in range(n):
		if s2[i] not in s2dic:
			s2dic[s2[i]] = 0
		s2dic[s2[i]] += 1
	ans = True
	if n < m:
		for key in s2dic:
			if key not in s1dic:
				ans = False
				break
			if s1dic[key] < s2dic[key]:
				ans = False
				break
			else:
				s1dic[key] -= s2dic[key]
		odd = False
		for key in s1dic:
			if s1dic[key] & 1 == 1:
				if not odd:
					odd = True
				else:
					ans = False
					break
	else:
		for key in s1dic:
			if key not in s2dic:
				ans = False
				break
			if s2dic[key] < s1dic[key]:
				ans = False
				break
			else:
				s2dic[key] -= s1dic[key]
		odd = False
		for key in s2dic:
			if s2dic[key] & 1 == 1:
				if not odd:
					odd = True
				else:
					ans = False
					break
	if ans:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = 1
	c = 0
	d = {}
	(x, y) = map(int, input().split())
	s1 = input()
	s2 = input()
	l1 = list(s1)
	l2 = list(s2)
	if x > y:
		for j in l2:
			if j in l1:
				l1.remove(j)
			else:
				a = 0
				break
		if a == 0:
			print('NO')
		else:
			for k in l1:
				if k in d:
					d[k] += 1
				else:
					d[k] = 1
			for q in d.values():
				if q % 2 != 0:
					c += 1
			if c == 0 or c == 1:
				print('YES')
			else:
				print('NO')
	else:
		for j in l1:
			if j in l2:
				l2.remove(j)
			else:
				a = 0
				break
		if a == 0:
			print('NO')
		else:
			for k in l2:
				if k in d:
					d[k] += 1
				else:
					d[k] = 1
			for q in d.values():
				if q % 2 != 0:
					c += 1
			if c == 0 or c == 1:
				print('YES')
			else:
				print('NO')


def isPalindrome(s):
	odd = 0
	for ch in set(s):
		if s.count(ch) % 2:
			odd += 1
	return odd < 2
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = str(input())[:n].lower()
	B = str(input())[:m].lower()
	if n < m:
		(A, B) = (B, A)
	for ch in B:
		if ch not in A:
			print('NO')
			break
		A = A.replace(ch, '', 1)
	else:
		if isPalindrome(A):
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(s1, s2) = (input(), input())
	if a < b:
		(s1, s2) = (s2, s1)
		(a, b) = (b, a)
	hm = {}
	for i in s1:
		hm.setdefault(i, 0)
		hm[i] += 1
	res = 'YES'
	for i in s2:
		if hm.get(i, 0) == 0:
			res = 'NO'
			break
		else:
			hm[i] -= 1
	if res != 'NO' and a - b > 0:
		(o, e) = (0, 0)
		for i in hm.keys():
			if hm[i] % 2 == 1:
				o += 1
				if o > 1:
					res = 'NO'
			else:
				e += 1
	print(res)


def isPalindrome(s):
	odd = 0
	for ch in set(s):
		if s.count(ch) % 2:
			odd += 1
	return odd < 2
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	if n < m:
		(s1, s2) = (s2, s1)
	for ch in s2:
		if ch not in s1:
			print('NO')
			break
		s1 = s1.replace(ch, '', 1)
	else:
		if isPalindrome(s1):
			print('YES')
		else:
			print('NO')


def soln():
	(n, m) = [int(x) for x in input().split()]
	a = input()
	b = input()
	d = dict()
	big = small = ''
	if n > m:
		big = a
		small = b
	else:
		big = b
		small = a
	for char in big:
		d[char] = d.get(char, 0) + 1
	for char in small:
		if d.get(char, 0) <= 0:
			return 'NO'
		else:
			d[char] -= 1
	noOdd = 0
	for char in d:
		if d[char] % 2 == 1:
			noOdd += 1
	if (n + m) % 2 == 1:
		return 'YES' if noOdd == 1 else 'NO'
	else:
		return 'YES' if noOdd == 0 else 'NO'
t = int(input())
for i in range(t):
	print(soln())


from collections import defaultdict

def check(a, b):
	if len(a) < len(b):
		(a, b) = (b, a)
	c = defaultdict(int)
	for i in a:
		c[i] += 1
	for i in b:
		c[i] -= 1
		if c[i] < 0:
			return False
	f = 0
	for i in c:
		if c[i] % 2 == 1:
			f += 1
	return f in [0, 1]
for _ in range(int(input())):
	input()
	print('YES' if check(input(), input()) else 'NO')


def palindrome(s):
	s1 = set(s)
	odd = ''
	for i in s1:
		if s.count(i) % 2 != 0:
			odd += i
	if len(s) % 2 == 0:
		if len(odd) == 0:
			print('YES')
		else:
			print('NO')
	elif len(odd) != 1:
		print('NO')
	else:
		print('YES')
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	f = 0
	if len(a) > len(b):
		s1 = a
		s2 = b
	else:
		s1 = b
		s2 = a
	for i in s2:
		if i not in s1:
			f = 1
			break
		else:
			s1 = s1.replace(i, '', 1)
	if f == 1:
		print('NO')
	else:
		palindrome(s1)


import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def read_int():
	return int(input())

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

def read_string_list():
	return list(input())

def read_string_list_with_space():
	return list(input().split())

def read_string():
	return input()

def read_graph():
	(n, m) = read_int_list()
	graph = [[] for _ in range(n)]
	for _ in range(m):
		(u, v) = read_int_list()
		graph[u].append(v)
		graph[v].append(u)
	return graph

def execute():
	for _ in range(read_int()):
		(n, m) = read_int_list()
		s = read_string()
		t = read_string()
		if n == m:
			s = sorted(s)
			t = sorted(t)[::-1]
			res = 1
			for i in range(n):
				if s[i] != t[n - i - 1]:
					res = 0
					break
			if res:
				print('YES')
			else:
				print('NO')
		else:
			(freq_small, freq_big) = ([0 for _ in range(26)], [0 for _ in range(26)])
			if n > m:
				(m, n) = (n, m)
				(t, s) = (s, t)
			for c in s:
				freq_small[ord(c) - 97] += 1
			for c in t:
				freq_big[ord(c) - 97] += 1
			res = 1
			for i in range(26):
				if freq_small[i] > freq_big[i]:
					res = 0
					break
				freq_big[i] -= freq_small[i]
			if res:
				odd = 0
				for i in range(26):
					if freq_big[i] % 2 == 1:
						odd += 1
					if odd > 1:
						res = 0
						break
			if res:
				print('YES')
			else:
				print('NO')
execute()


t = int(input())
from collections import Counter
for _ in range(t):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	if n > m:
		(n, m) = (m, n)
		(a, b) = (b, a)
	cnt1 = Counter(a)
	cnt2 = Counter(b)
	check = True
	for key in cnt1:
		if cnt1[key] <= cnt2[key]:
			cnt2[key] -= cnt1[key]
		else:
			check = False
			break
	if not check:
		print('NO')
	else:
		odd = 0
		even = 0
		for key in cnt2:
			if cnt2[key] % 2 == 0:
				even += 1
			else:
				odd += 1
		if odd <= 1:
			print('YES')
		else:
			print('NO')


for tc in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		s1 = input()
		s2 = input()
	else:
		s2 = input()
		s1 = input()
	d = {}
	di = {}
	for i in s1:
		d[i] = 0
	for i in s2:
		di[i] = 0
	for i in s1:
		d[i] += 1
	for i in s2:
		di[i] += 1
	temp = 0
	for i in di.keys():
		if i not in d.keys():
			temp = 1
			break
	if temp:
		print('NO')
	else:
		for i in di.keys():
			d[i] -= di[i]
		check = 0
		for i in d.values():
			if i < 0:
				check = 1
		if check:
			print('NO')
		else:
			count = 0
			for i in d.values():
				if i % 2 == 1:
					count += 1
			if count > 1:
				print('NO')
			else:
				print('YES')


from collections import Counter

def checkvalid(a, b, n, m):
	if n < m:
		(a, b) = (b, a)
		(n, m) = (m, n)
	ac = Counter(a)
	bc = Counter(b)
	for i in range(m):
		if b[i] in ac and ac[b[i]] > 0:
			ac[b[i]] -= 1
		else:
			return False
	oddFound = False
	for key in ac:
		if ac[key] % 2:
			if oddFound:
				return False
			oddFound = True
	return True
tests = int(input())
for t0 in range(tests):
	valid = True
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	print(['NO', 'YES'][checkvalid(a, b, n, m)])


t = int(input())
for t in range(t):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	p = ''
	q = ''
	if len(a) > len(b):
		p = a
		q = b
	else:
		p = b
		q = a
	flag = 1
	u = {}
	v = {}
	for i in p:
		if i in u:
			u[i] = u[i] + 1
		else:
			u[i] = 1
	for i in q:
		if i in v:
			v[i] = v[i] + 1
		else:
			v[i] = 1
	for i in v:
		if u.get(i, 0) < v[i]:
			flag = 0
	for i in u:
		if i in v:
			u[i] = u[i] - v[i]
	count_odd = 0
	for i in u:
		if u[i] % 2 != 0:
			count_odd = count_odd + 1
	if flag == 0:
		print('NO')
	elif count_odd > 1:
		print('NO')
	else:
		print('YES')


from collections import Counter

def solve():
	(n, m) = map(int, input().split())
	(a, b) = (input(), input())
	if n < m:
		(a, b) = (b, a)
	(cntA, cntB) = (Counter(a), Counter(b))
	for i in cntB:
		if cntA[i] < cntB[i]:
			print('NO')
			return
		cntA[i] -= cntB[i]
	(odd, even) = (0, 0)
	for i in cntA:
		if cntA[i] == 0:
			continue
		if cntA[i] % 2 == 0:
			even += 1
		else:
			odd += 1
	if odd <= 1:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = input()
	b = input()
	if x < y:
		(a, b) = (b, a)
	d = {}
	flag = True
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in b:
		if i not in d:
			flag = False
			break
		else:
			if d[i] == 0:
				flag = False
				break
			d[i] -= 1
	if flag == False:
		print('NO')
		continue
	count = 0
	for i in d:
		if d[i] % 2 != 0:
			count += 1
		if count > 1:
			flag = False
			break
	if flag == False:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	d = {}
	for i in a:
		val = (n >= m) - (n < m)
		if i in d:
			d[i] += val
		else:
			d[i] = val
	for i in b:
		val = (m > n) - (m <= n)
		if i in d:
			d[i] += val
		else:
			d[i] = val
	odd = 0
	for i in d.values():
		if i & 1:
			odd += 1
	if odd <= 1 and min(d.values()) >= 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	x = input()
	y = input()
	s = []
	if a < b:
		for i in y:
			s.append(i)
		q = 0
		for i in x:
			if i in s:
				s.remove(i)
			else:
				q = 1
				print('NO')
				break
		if q == 0:
			d = {}
			for i in s:
				if i not in d:
					d[i] = 1
				else:
					d[i] += 1
			c = 0
			for i in d:
				if d[i] % 2 != 0:
					c += 1
			if c <= 1:
				print('YES')
			else:
				print('NO')
	elif b < a:
		for i in x:
			s.append(i)
		q = 0
		for i in y:
			if i in s:
				s.remove(i)
			else:
				q = 1
				print('NO')
				break
		if q == 0:
			d = {}
			for i in s:
				if i not in d:
					d[i] = 1
				else:
					d[i] += 1
			c = 0
			for i in d:
				if d[i] % 2 != 0:
					c += 1
			if c <= 1:
				print('YES')
			else:
				print('NO')
	else:
		d1 = {}
		d2 = {}
		for i in x:
			if i not in d1:
				d1[i] = 1
			else:
				d1[i] += 1
		for i in y:
			if i not in d2:
				d2[i] = 1
			else:
				d2[i] += 1
		for i in d1:
			if i not in d2:
				print('NO')
				break
			elif i in d2 and d1[i] != d2[i]:
				print('NO')
				break
		else:
			print('YES')


def palindrome(n, m, a, b):
	d = {}
	for i in a:
		val = (n >= m) - (n < m)
		if i in d:
			d[i] += val
		else:
			d[i] = val
	for i in b:
		val = (m > n) - (m <= n)
		if i in d:
			d[i] += val
		else:
			d[i] = val
	c = 0
	for i in d.values():
		c += i & 1
	return 'YES' if c <= 1 and min(d.values()) >= 0 else 'NO'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	print(palindrome(n, m, a, b))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	freq = {}
	for c in input():
		add = (n >= m) - (n < m)
		if c in freq:
			freq[c] += add
		else:
			freq[c] = add
	for c in input():
		add = (m > n) - (m <= n)
		if c in freq:
			freq[c] += add
		else:
			freq[c] = add
	odd = 0
	for y in freq.values():
		odd += y % 2
	print('YES' if odd <= 1 and min(freq.values()) >= 0 else 'NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	flag = 0
	a = input()
	b = input()
	if len(a) < len(b):
		lis1 = list(b)
		lis2 = list(a)
	else:
		lis1 = list(a)
		lis2 = list(b)
	flag = 0
	for i in lis2:
		if i in lis1:
			lis1.remove(i)
		else:
			print('NO')
			flag = 1
			break
	if flag == 1:
		continue
	c = ''
	flag = 0
	count = 0
	for i in lis1:
		if i not in c:
			c += i
			x = lis1.count(i)
			if x % 2 != 0:
				count += 1
			if count >= 2:
				print('NO')
				flag = 1
				break
	if flag == 0:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	if n < m:
		(a, b) = (b, a)
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	ans = True
	for i in b:
		if i in d:
			if d[i] == 0:
				ans = False
				break
			d[i] -= 1
		else:
			ans = False
			break
	if not ans:
		print('NO')
	else:
		cnt = 0
		for i in d.keys():
			j = d[i]
			if j % 2 != 0:
				cnt += 1
		print('NO' if cnt > 1 else 'YES')


def check(a, b):
	ca = Counter(a)
	cb = Counter(b)
	for i in ca:
		if ca[i] > cb[i]:
			return False
	return True

def solve(c, leng):
	cc = Counter(c)
	o = 0
	for i in cc.values():
		if i % 2 == 1:
			o += 1
	if o > 1:
		return 'NO'
	else:
		return 'YES'
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = input()
	if m < n:
		(a, b) = (b, a)
	c = a + b
	from collections import Counter
	if check(a, b) == False:
		print('NO')
	else:
		ans = solve(c, len(c))
		print(ans)


from collections import Counter

def findin(a, b):
	ca = Counter(a)
	cb = Counter(b)
	for i in ca:
		if ca[i] > cb[i]:
			return False
	return True

def solve(c, n):
	cnt = Counter(c)
	v = cnt.values()
	odds = 0
	evens = 0
	for i in v:
		if i % 2 == 0:
			evens += 1
		else:
			odds += 1
	if odds > 1:
		return 'NO'
	else:
		return 'YES'
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = input()
	b = input()
	if m < n:
		(a, b) = (b, a)
	if not findin(a, b):
		print('NO')
	else:
		c = a + b
		ans = solve(c, len(c))
		print(ans)


from collections import Counter
t = int(input())
while t:
	(m, n) = list(map(int, input().split()))
	a = list(input())
	b = list(input())
	if m > n:
		count_a = Counter(a)
		count_b = Counter(b)
	else:
		count_a = Counter(b)
		count_b = Counter(a)
	for (k, v) in count_b.items():
		if count_a[k]:
			count_b[k] -= min(v, count_a[k])
			count_a[k] -= v
	if sum(list(count_b.values())):
		print('NO')
		t -= 1
		continue
	else:
		odd = 0
		for (k, v) in count_a.items():
			odd += v % 2
		if odd > 1:
			print('NO')
			t -= 1
			continue
	print('YES')
	t -= 1


def solve():
	(n, m) = map(int, input().split())
	s1 = input()
	s2 = input()
	if len(s1) < len(s2):
		(s1, s2) = (s2, s1)
	(m1, m2) = ({}, {})
	for i in s1:
		if i not in m1:
			m1[i] = 0
		m1[i] += 1
	for i in s2:
		if i not in m2:
			m2[i] = 0
		m2[i] += 1
	for i in m2.keys():
		if i not in m1 or m1[i] < m2[i]:
			print('NO')
			return
		m1[i] -= m2[i]
	(o, e) = (0, 0)
	for i in m1.keys():
		if m1[i] % 2 == 1:
			o += 1
		else:
			e += 1
	if o <= 1:
		print('YES')
	else:
		print('NO')
testcase = int(input())
while testcase:
	solve()
	testcase -= 1