This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.

After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.

Ujan has two distinct strings $s$ and $t$ of length $n$ consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions $i$ and $j$ ($1 \le i,j \le n$, the values $i$ and $j$ can be equal or different), and swaps the characters $s_i$ and $t_j$. Can he succeed?

Note that he has to perform this operation exactly once. He has to perform this operation.


-----Input-----

The first line contains a single integer $k$ ($1 \leq k \leq 10$), the number of test cases.

For each of the test cases, the first line contains a single integer $n$ ($2 \leq n \leq 10^4$), the length of the strings $s$ and $t$. 

Each of the next two lines contains the strings $s$ and $t$, each having length exactly $n$. The strings consist only of lowercase English letters. It is guaranteed that strings are different.


-----Output-----

For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.

You can print each letter in any case (upper or lower).


-----Example-----
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca

Output
Yes
No
No
No



-----Note-----

In the first test case, Ujan can swap characters $s_1$ and $t_4$, obtaining the word "house".

In the second test case, it is not possible to make the strings equal using exactly one swap of $s_i$ and $t_j$.

Difficulty: EASY
Tags: String algorithms

Starter code:

Solutions:
t = int(input())
for x in range(t):
	n = int(input())
	s = input()
	t = input()
	i = c = 0
	a = b = ''
	while c < 4 and i < n:
		if s[i] != t[i]:
			c += 1
			a += s[i]
			b += t[i]
		i += 1
	if c == 2 and len(set(a)) == len(set(b)) == 1:
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s1 = input()
	s2 = input()
	ls = []
	for i in range(n):
		if s1[i] != s2[i]:
			ls.append(i)
	if len(ls) == 0:
		print('YES')
	elif len(ls) != 2:
		print('NO')
	elif s1[ls[0]] == s1[ls[1]] and s2[ls[0]] == s2[ls[1]]:
		print('YES')
	else:
		print('NO')


tes = int(input())
for j in range(0, tes):
	size = int(input())
	s = input()
	t = input()
	arr = []
	l = 0
	k = 0
	for i in range(0, size):
		if s[i] != t[i]:
			arr.append(i)
			l = l + 1
		if l > 2:
			print('NO')
			k = 1
			break
	if l == 2 and s[arr[0]] == s[arr[1]] and (t[arr[0]] == t[arr[1]]):
		print('YES')
	elif l < 2 or k == 0:
		print('NO')


import math
import sys
from collections import defaultdict, Counter
from functools import lru_cache
t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	count = 0
	ind = []
	for i in range(n):
		if s1[i] != s2[i]:
			count += 1
			ind.append(i)
	if count == 2:
		if s1[ind[0]] == s1[ind[1]] and s2[ind[1]] == s2[ind[0]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for x in range(t):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	w1 = []
	w2 = []
	ruined = 0
	for x in range(n):
		if s1[x] == s2[x]:
			pass
		else:
			w1.append(s1[x])
			w2.append(s2[x])
		if len(w1) > 2 or len(w2) > 2:
			ruined = 1
			break
	if len(w1) == 1 or len(w1) > 2:
		print('NO')
	elif w1[0] != w1[1] or w2[1] != w2[0]:
		print('NO')
	else:
		print('YES')


from collections import deque as d
k = int(input())
for _ in range(k):
	n = int(input())
	s = list(input())
	st = list(input())
	l = d()
	for i in range(n):
		if s[i] != st[i]:
			l.append(i)
	if len(l) == 2:
		(s[l[0]], st[l[1]]) = (st[l[1]], s[l[0]])
		if s == st:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


from sys import stdin
ntest = int(stdin.readline())
for t in range(ntest):
	inutile = int(stdin.readline())
	s = [c for c in stdin.readline()]
	t = [c for c in stdin.readline()]
	risp = [pos for pos in range(inutile) if int(s[pos] != t[pos])]
	if len(risp) != 2:
		print('No')
	elif s[risp[1]] == s[risp[0]] and t[risp[0]] == t[risp[1]]:
		print('Yes')
	else:
		print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	p = []
	for i in range(n):
		if s[i] != t[i]:
			p.append(i)
		if len(p) > 2:
			break
	if len(p) == 2 and s[p[0]] == s[p[1]] and (t[p[1]] == t[p[0]]):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	cnt = 0
	flag = 0
	(l, c) = ([], [])
	for i in range(n):
		if s[i] != t[i]:
			cnt += 1
			l.append(s[i])
			c.append(t[i])
	if cnt == 0:
		print('Yes')
	elif cnt == 2:
		l = list(set(l))
		c = list(set(c))
		if len(c) == 1 and len(l) == 1:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input().strip())
for _ in range(k):
	lung = int(input().strip())
	(s, t, mod) = ([i for i in input().strip()], [j for j in input().strip()], '')
	first = True
	n_c = 0
	if s == t:
		print('NO')
	else:
		for i in range(len(s)):
			if s[i] != t[i] and first:
				(mod, prec) = (t[i], s[i])
				s[i] = mod
				n_c += 1
				first = False
			elif s[i] != t[i] and (not first):
				if t[i] == mod:
					t[i] = prec
					n_c += 1
					break
		if s == t and n_c == 2:
			print('YES')
		else:
			print('NO')


import sys, math, bisect

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		s = input()
		t = input()
		A = [0 for k in range(30)]
		for e in s:
			A[ord(e) - 97] += 1
		for e in t:
			A[ord(e) - 97] += 1
		f = 0
		for e in A:
			if e % 2 == 1:
				f = 1
				break
		if f == 1:
			print('No')
		else:
			print('Yes')
			S = [str(e) for e in s]
			T = [str(e) for e in t]
			ans = []
			for k in range(n - 1):
				if S[k] != T[k]:
					for l in range(k + 1, n):
						if S[k] == S[l]:
							(T[k], S[l]) = (S[l], T[k])
							ans.append([l + 1, k + 1])
							break
						if S[k] == T[l]:
							(S[l], T[l]) = (T[l], S[l])
							ans.append([l + 1, l + 1])
							(S[l], T[k]) = (T[k], S[l])
							ans.append([l + 1, k + 1])
							break
			print(len(ans))
			for e in ans:
				print(*e)
main()


import sys

def solve():
	(n,) = map(int, sys.stdin.readline().split())
	s = list(sys.stdin.readline().strip())
	t = list(sys.stdin.readline().strip())
	ch = []
	for i in range(n):
		if s[i] != t[i]:
			ch.append(i)
	if len(ch) == 0:
		print('Yes')
	elif len(ch) != 2:
		print('No')
	else:
		(i1, i2) = ch
		f = s[i1] == s[i2] and t[i1] == t[i2]
		print('Yes' if f else 'No')
(k,) = map(int, sys.stdin.readline().split())
for _ in range(k):
	solve()


q = int(input())
for _ in range(q):
	n = int(input())
	s1 = input()
	s2 = input()
	a = []
	for i in range(n):
		if s1[i] != s2[i]:
			a.append(s1[i] + s2[i])
	if len(a) != 2:
		print('No')
	elif a[0] == a[1]:
		print('Yes')
	else:
		print('No')


k = int(input())
out = []
for i in range(k):
	kq = [0]
	n = int(input())
	(j, check) = (0, 0)
	s = input()
	t = input()
	while j < n and len(kq) <= 3 and (check <= 3):
		if s[j] != t[j]:
			check = check + 1
			if kq.count(s[j]) == 0:
				kq.append(s[j])
			elif kq[-1] == s[j]:
				check = 4
			if kq.count(t[j]) == 0:
				kq.append(t[j])
		j = j + 1
	if j < n or check != 2 or len(kq) > 3:
		out.append('No')
	else:
		out.append('Yes')
for i in range(k):
	print(out[i])


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	i = -1
	j = -1
	count = 0
	for k in range(n):
		if s[k] != t[k]:
			count += 1
			if i == -1:
				i = k
			else:
				j = k
	if count > 2:
		print('No')
	elif count == 2 and s[i] == s[j] and (t[j] == t[i]):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	x = []
	y = []
	for j in range(len(a)):
		if a[j] != b[j]:
			x.append(a[j])
			y.append(b[j])
	if len(x) >= 3 or len(x) <= 1:
		print('No')
	elif x[0] == x[1] and y[0] == y[1]:
		print('Yes')
	else:
		print('No')


n = int(input())
for x in range(n):
	lenstr = int(input())
	str1 = input()
	str2 = input()
	count = 0
	diff = []
	for i in range(lenstr):
		if str1[i] != str2[i]:
			count += 1
			diff.append(i)
	if count > 2:
		print('No')
	elif count == 1:
		print('No')
	elif count == 2:
		if str1[diff[0]] == str1[diff[1]] and str2[diff[1]] == str2[diff[0]]:
			print('Yes')
		else:
			print('No')


import os, sys, math
import collections
if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.in.txt', encoding='utf8')
	input = src.readline

def solve(s, t):
	diff = []
	contains_the_same = False
	for (e, (a, b)) in enumerate(zip(s, t)):
		if a != b:
			diff.append(e)
		else:
			contains_the_same = True
	if not diff:
		return contains_the_same
	if len(diff) != 2:
		return False
	(a, b) = diff
	return s[a] == s[b] and t[a] == t[b]
k = int(input().strip())
for _ in range(k):
	n = int(input().strip())
	s = input().strip()
	t = input().strip()
	res = solve(s, t)
	print('Yes' if res else 'No')


from collections import Counter

def shared_chars(s1, s2):
	m = []
	notm = []
	for i in range(len(s1)):
		if s1[i] == s2[i]:
			m.append(s1[i])
		else:
			notm.append((s1[i], s2[i]))
	return (m, notm)

def main(s, t):
	(m, notm) = shared_chars(s, t)
	if len(notm) != 2:
		return False
	if notm[0][0] == notm[1][0] and notm[0][1] == notm[1][1]:
		return True
	return False
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	if not main(s, t):
		print('No')
	else:
		print('Yes')


i = input
for _ in range(int(i())):
	i()
	d = [(x, y) for (x, y) in zip(i(), i()) if x != y]
	print('YNEOS'[len(d) != 2 or d[0] != d[1]::2])


t = int(input())
while t > 0:
	n = int(input())
	s1 = input()
	s2 = input()
	n_changes = 0
	change_items1 = []
	change_items2 = []
	for i in range(n):
		if s1[i] == s2[i]:
			continue
		else:
			n_changes += 1
			change_items1.append(s1[i])
			change_items2.append(s2[i])
	if n_changes != 2:
		print('No')
	elif change_items1[0] == change_items1[1] and change_items2[0] == change_items2[1]:
		print('Yes')
	else:
		print('No')
	t -= 1


def main():
	testcase = int(input())
	result = []
	for i in range(testcase):
		char_count = int(input())
		str1 = input()
		str2 = input()
		str1_comp = []
		str2_comp = []
		for j in range(char_count):
			if str1[j] != str2[j]:
				str1_comp.append(str1[j])
				str2_comp.append(str2[j])
			if len(str1_comp) > 2:
				result.append('No')
				break
		if len(str1_comp) == 1:
			result.append('No')
		elif len(str1_comp) == 2:
			if str1_comp[0] == str1_comp[1] and str2_comp[0] == str2_comp[1]:
				result.append('Yes')
			else:
				result.append('No')
	for i in result:
		print(i)
main()


t = int(input())
for _ in range(t):
	l = int(input())
	x = input()
	y = input()
	if x == y:
		print('Yes')
	else:
		xl = []
		yl = []
		inc = 0
		for i in range(l):
			if x[i] != y[i]:
				inc += 1
				xl.append(x[i])
				yl.append(y[i])
		if inc == 2:
			if xl[0] == xl[1] and yl[0] == yl[1]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


import sys
from collections import Counter

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check1(C):
	for v in C.values():
		if v % 2 != 0:
			return False
	return True

def check2(S, T):
	ans = []
	for i in range(N):
		if S[i] != T[i]:
			try:
				j = S[i + 1:].index(S[i]) + i + 1
				(S[j], T[i]) = (T[i], S[j])
				ans.append((j, i))
			except:
				j = T[i + 1:].index(S[i]) + i + 1
				(S[i], T[j]) = (T[j], S[j])
				ans.append((j, j))
				(S[j], T[i]) = (T[i], S[j])
				ans.append((j, i))
	return ans
for _ in range(INT()):
	N = INT()
	S = list(input())
	T = list(input())
	C1 = Counter(S)
	C2 = Counter(T)
	C = Counter(S + T)
	if not check1(C):
		No()
		continue
	ans = check2(S, T)
	Yes()
	print(len(ans))
	for (i, j) in ans:
		print(i + 1, j + 1)


entrada = int(input())
for k in range(entrada):
	tamanho = int(input())
	strings = input()
	stringt = input()
	cs = ''
	ct = ''
	contador = 0
	flag = True
	for i in range(tamanho):
		if strings[i] != stringt[i]:
			contador += 1
			if cs == '' and ct == '':
				cs = strings[i]
				ct = stringt[i]
			elif strings[i] != cs or stringt[i] != ct:
				flag = False
				break
		if contador > 2:
			flag = False
			break
	if flag and contador == 2:
		print('Yes')
	else:
		print('No')


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = input()
	t = input()
	L1 = []
	L2 = []
	c = 0
	for i in range(0, len(s)):
		if s[i] != t[i]:
			c += 1
			L1.append(s[i])
			L2.append(t[i])
	if c == 2 and L1[0] == L1[1] and (L2[1] == L2[0]):
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
for i in stdin:
	q = int(i)
	break

def swap(i, j):
	global s
	global m
	global t
	global M
	M.append([i + 1, j + 1])
	m += 1
	(s[i], t[j]) = (t[j], s[i])

def solve():
	global s
	global t
	global m
	global A
	for i in range(1, len(A)):
		if s[A[0]] == s[A[i]]:
			swap(A[i], A[0])
			if s[A[i]] == t[A[i]]:
				A = A[1:i] + A[i + 1:]
			else:
				del A[0]
			return 1
	for i in range(1, len(A)):
		if s[A[0]] == t[A[i]]:
			swap(A[i], A[i])
			swap(A[i], A[0])
			if s[A[i]] == t[A[i]]:
				A = A[1:i] + A[i + 1:]
			else:
				del A[0]
			return 1
	return 0
for i in range(q):
	for i in stdin:
		n = int(i)
		break
	for i in stdin:
		s = list(i.strip())
		break
	for i in stdin:
		t = list(i.strip())
		break
	A = []
	for i in range(n):
		if s[i] != t[i]:
			A.append(i)
	m = 0
	M = []
	while 1:
		if solve():
			if A == []:
				stdout.write('Yes\n')
				stdout.write(str(m) + '\n')
				for i in M:
					stdout.write(str(i[0]) + ' ' + str(i[1]) + '\n')
				break
		else:
			stdout.write('No\n')
			break


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	eqchr = [0] * n
	for i in range(n):
		if s[i] == t[i]:
			eqchr[i] = 1
	cnt = eqchr.count(0)
	flag = 0
	if cnt == 2:
		list = []
		for i in range(n):
			if eqchr[i] == 0:
				list.append(i)
		x = list[0]
		y = list[1]
		if s[x] == s[y]:
			if t[x] == t[y]:
				flag = 1
	if flag:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	a = []
	for i in range(n):
		if s[i] != t[i]:
			a.append(i)
	if len(a) > 2 or len(a) == 1:
		print('NO')
	elif len(a) == 0:
		print('YES')
	elif s[a[0]] == s[a[1]] and t[a[0]] == t[a[1]]:
		print('YES')
	else:
		print('NO')


def every_letter_appears_even_times(word1, word2):
	letters = dict()
	for ch in word1 + word2:
		if ch not in letters:
			letters[ch] = 1
		else:
			letters[ch] += 1
	for ch in letters:
		if letters[ch] % 2:
			return False
	return True
tests_count = int(input())
for test in range(tests_count):
	words_len = int(input())
	(word1, word2) = (list(input()), list(input()))
	if word1 == word2:
		print('Yes')
		print('0')
	elif not every_letter_appears_even_times(word1, word2):
		print('No')
	else:
		print('Yes')
		results = []
		for i in range(words_len - 1):
			if word1[i] != word2[i]:
				if word1[i] in word1[i + 1:]:
					x = word1.index(word1[i], i + 1)
					(word1[x], word2[i]) = (word2[i], word1[x])
					results.append([x, i])
				else:
					x = word2.index(word1[i], i + 1)
					(word1[x], word2[x]) = (word2[x], word1[x])
					(word1[x], word2[i]) = (word2[i], word1[x])
					results.append([x, x])
					results.append([x, i])
		print(len(results))
		for result in results:
			print(result[0] + 1, result[1] + 1)


def task_2(n, s_string, t_string):
	result = 'Yes'
	values = list()
	changes = 0
	change_set = set()
	for i in range(n):
		if s_string[i] != t_string[i]:
			changes += 1
			change_set.add(s_string[i] + t_string[i])
			if changes > 2 or len(change_set) > 1:
				result = 'No'
				break
	if changes == 1 and len(change_set) == 1:
		result = 'No'
	print(result)
k = int(input().rstrip())
for i in range(k):
	n = int(input().rstrip())
	s_string = str(input().rstrip())
	t_string = str(input().rstrip())
	task_2(n, s_string, t_string)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	ara = []
	arb = []
	count = 0
	ar1 = list(a)
	ar2 = list(b)
	for i in range(len(ar1)):
		if ar1[i] != ar2[i]:
			count += 1
			ara.append(ar1[i])
			arb.append(ar2[i])
	if count == 2:
		if len(set(ara)) == len(set(arb)) == 1:
			print('YES')
		else:
			print('NO')
	elif count == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	l1 = []
	l2 = []
	for (i, j) in zip(s, t):
		if i != j:
			l1.append(i)
			l2.append(j)
	if len(l1) == 2 and len(set(l1)) == 1 and (len(set(l2)) == 1):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	p = int(input())
	a = [i for i in input()]
	b = [i for i in input()]
	f = []
	for i in range(p):
		if a[i] != b[i]:
			f.append(i)
	if len(f) == 2:
		(a[f[0]], b[f[1]]) = (b[f[1]], a[f[0]])
	if a == b:
		print('Yes')
	else:
		print('No')


T = int(input())
for _ in range(T):
	n = int(input())
	w1 = list(input())
	w2 = list(input())
	for i in range(n - 1, -1, -1):
		if w1[i] == w2[i]:
			del w1[i]
			del w2[i]
	if len(w1) == len(w1) and len(w1) == 2:
		if w1[0] == w1[1] and w2[0] == w2[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


def run_testcase():
	n = int(input())
	string1 = input()
	string2 = input()
	swaps = []
	diff = 0
	for (char1, char2) in zip(string1, string2):
		if char1 != char2:
			diff += 1
			if diff > 2:
				return 'No'
			swaps.append((char1, char2))
	if diff == 1:
		return 'No'
	if swaps[0][0] == swaps[1][0] and swaps[0][1] == swaps[1][1]:
		return 'Yes'
	return 'No'
testcase_count = int(input())
for i in range(testcase_count):
	print(str(run_testcase()))


def swap(n, p):
	(x, y) = (0, 0)
	counter = 0
	flag = 0
	for i in range(len(s[p][0])):
		if s[p][0][i] != s[p][1][i] and counter == 0:
			counter += 1
			x = s[p][0][i]
			y = s[p][1][i]
		elif s[p][0][i] != s[p][1][i] and counter != 0:
			counter += 1
			if x == s[p][0][i] and y == s[p][1][i]:
				flag = 1
		if counter > 2:
			return 'No'
	if flag == 1:
		return 'Yes'
	else:
		return 'No'
n = int(input())
s = [['' for i in range(2)] for j in range(n)]
for i in range(n):
	a = int(input())
	s[i][0] = input()
	s[i][1] = input()
for p in range(n):
	print(swap(n, p))


tests = int(input())
for _ in range(tests):
	n = int(input())
	s = input()
	t = input()
	poms = []
	pomt = []
	for i in range(n):
		if s[i] != t[i]:
			poms.append(s[i])
			pomt.append(t[i])
	if len(poms) == 0:
		print('Yes')
	elif len(poms) == 1:
		if poms[0] == pomt[0]:
			print('Yes')
		else:
			print('No')
	elif len(poms) == 2:
		if poms[0] == poms[1] and pomt[1] == pomt[0]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for t in range(int(input())):
	n = int(input())
	s = str(input())
	t = str(input())
	l = []
	for i in range(n):
		xx = s[i]
		yy = t[i]
		if xx != yy:
			l.append(i)
	if len(l) == 2:
		if t[l[1]] == t[l[0]] and s[l[1]] == s[l[0]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


from sys import stdin, stdout

def solve(s, t):
	(sd, td) = ('', '')
	res = False
	for (x, y) in zip(s, t):
		if x != y:
			if not sd and (not td):
				(sd, td) = (x, y)
			elif res:
				return 'NO'
			elif x != sd or y != td:
				return 'NO'
			else:
				res = True
	return 'YES' if res else 'NO'

def main():
	k = int(input())
	for _ in range(k):
		n = int(input())
		(s, t) = (input(), input())
		print(solve(s, t))
main()


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	w = []
	x = []
	for i in range(n):
		if a[i] != b[i]:
			w.append(a[i])
			x.append(b[i])
	if len(w) == 2 and w[0] == w[1] and (x[0] == x[1]):
		print('Yes')
	elif len(w) == 0:
		print('Yes')
	else:
		print('No')


Q = int(input())
for q in range(Q):
	N = int(input())
	s = input()
	t = input()
	c = 0
	s1 = ''
	t1 = ''
	fl = False
	for n in range(N):
		if s[n] != t[n]:
			if c > 1:
				fl = False
				break
			elif c == 0:
				s1 = s[n]
				t1 = t[n]
			elif c == 1:
				if s[n] == s1 and t[n] == t1:
					fl = True
				else:
					fl = False
					break
			c += 1
	if fl:
		print('Yes')
	elif c == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
l1 = []
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	l3 = []
	c = 0
	flag = 0
	for j in range(n):
		if a[j] != b[j]:
			c += 1
			l3.append([ord(a[j]), ord(b[j])])
		if c > 2:
			flag = 1
			break
	if flag == 1:
		l1.append('No')
	elif c == 2:
		if l3[0][0] == l3[1][0] and l3[0][1] == l3[1][1]:
			l1.append('Yes')
		else:
			l1.append('No')
	elif c == 1:
		l1.append('No')
	else:
		l1.append('Yes')
for k in range(t):
	print(l1[k])


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	a = []
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			a.append(i)
	if c == 0:
		print('YES')
	elif c != 2 and c != 0:
		print('NO')
	elif s[a[0]] == s[a[1]] and t[a[0]] == t[a[1]]:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	o = int(input())
	s = input().rstrip()
	t = input().rstrip()
	x = list(s)
	y = list(t)
	L = []
	Q = []
	for j in range(0, len(x)):
		if x[j] != y[j]:
			D = []
			D.append(x[j])
			D.append(y[j])
			if D not in L:
				L.append(D)
			Q.append(D)
	if len(L) == 1 and len(Q) == 2:
		print('YES')
	else:
		print('NO')


N = int(input())
for i in range(N):
	n = int(input())
	s1 = input()
	s2 = input()
	c = 0
	c1 = []
	c2 = []
	for j in range(n):
		if s1[j] == s2[j]:
			continue
		else:
			c += 1
			c1.append(s1[j])
			c2.append(s2[j])
	if c == 2 and c1[0] == c1[1] and (c2[0] == c2[1]):
		print('Yes')
	else:
		print('No')


a = int(input())
B = []
for i in range(a):
	x = int(input())
	A1 = input()
	A2 = input()
	C = []
	for j in range(x):
		if A1[j] != A2[j]:
			C.append(j)
	if len(C) != 2:
		B.append('No')
	elif A1[C[0]] == A1[C[1]] and A2[C[1]] == A2[C[0]]:
		B.append('Yes')
	else:
		B.append('No')
for b in B:
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	k = list()
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			k.append(i)
			if c > 2:
				break
	if c == 2:
		p = s[k[0]]
		s[k[0]] = t[k[1]]
		t[k[1]] = p
		if s == t:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	count = 0
	l = []
	r = []
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			l.append(s[i])
			r.append(t[i])
	if count == 2 and len(set(l)) == 1 and (len(set(r)) == 1):
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	o = s + t
	a = [0] * 26
	for j in o:
		a[ord(j) - 97] += 1
	for j in a:
		if j % 2 == 1:
			print('No')
			break
	else:
		s = list(s)
		t = list(t)
		number = 0
		ans = []
		print('Yes')
		for j in range(n):
			if s[j] != t[j]:
				check = True
				for k in range(j + 1, n):
					if t[k] == t[j]:
						number += 1
						ans.append([j + 1, k + 1])
						t[k] = s[j]
						s[j] = t[j]
						check = False
						break
				if check:
					for k in range(j + 1, n):
						if s[k] == t[j]:
							number += 2
							ans.append([j + 1, j + 1])
							ans.append([k + 1, j + 1])
							s[k] = s[j]
							s[j] = t[j]
							break
		print(number)
		for j in ans:
			print(*j)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	t = str(input())
	dif = []
	for i in range(n):
		if s[i] != t[i]:
			dif.append(i)
	if len(dif) != 2:
		print('No')
		continue
	if s[dif[0]] == s[dif[1]] and t[dif[0]] == t[dif[1]]:
		print('Yes')
	else:
		print('No')


import sys
input = lambda : sys.stdin.readline().strip()
k = int(input())
for i in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	res = []
	for i in range(n):
		try:
			found = s.index(s[i], i + 1)
			(s[found], t[i]) = (t[i], s[found])
			res.append((found, i))
		except:
			try:
				found = t.index(s[i], i)
				(t[found], s[found]) = (s[found], t[found])
				res.append((found, found))
				(s[found], t[i]) = (t[i], s[found])
				res.append((found, i))
			except:
				print('No')
				break
	else:
		print('Yes')
		print(len(res))
		for i in res:
			print(i[0] + 1, i[1] + 1)


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	p = []
	for i in range(n):
		if s[i] != t[i]:
			p.append((s[i], t[i]))
	if len(p) == 2 and p[0][0] == p[1][0] and (p[0][1] == p[1][1]):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	t = input()
	c = 0
	d = set()
	b = set()
	for j in range(n):
		if s[j] != t[j]:
			c += 1
			d.add(s[j])
			b.add(t[j])
	if c == 2 and len(d) == 1 and (len(b) == 1):
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	(li, li2) = (list(), list())
	(s1, s2) = (input(), input())
	for i in range(n):
		if s1[i] != s2[i]:
			li.append(i)
			li2.append(i)
	if len(li) == 0:
		print('Yes')
		continue
	elif len(li) == 1:
		print('No')
		continue
	if len(li) < 3 and len(li2) < 3:
		if s1[li[0]] == s1[li[1]] and s2[li2[0]] == s2[li2[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
arr = []
for i in range(k):
	ans = 0
	n = int(input())
	s = list(input())
	t = list(input())
	equalsChars = []
	diffIndexes = []
	for i in range(n):
		if s[i] == t[i]:
			equalsChars.append(s[i])
		else:
			diffIndexes.append(i)
	val = len(diffIndexes)
	if val == 0:
		ans = 1
	elif val == 1 or val > 2:
		ans = 0
	elif s[diffIndexes[0]] == s[diffIndexes[1]] and t[diffIndexes[0]] == t[diffIndexes[1]]:
		ans = 1
	if ans == 1:
		arr.append('Yes')
	else:
		arr.append('No')
for _ in arr:
	print(_)


k = int(input())
while k:
	n = int(input())
	s = list(map(str, input().strip()))
	t = list(map(str, input().strip()))
	cnt = [0] * 60
	for i in s:
		cnt[ord(i) - ord('a')] += 1
	for i in t:
		cnt[ord(i) - ord('a')] += 1
	flag = 0
	for i in cnt:
		if i % 2:
			flag = 1
			break
	op = []
	for i in range(n):
		if s[i] != t[i]:
			op.append([s[i], t[i]])
	if len(op) > 2:
		flag = 1
	for (i, v) in enumerate(op):
		if i and (op[i][0] != op[i - 1][0] or op[i][1] != op[i - 1][1]):
			flag = 1
			break
	if flag:
		print('NO')
		k -= 1
		continue
	print('YES')
	k -= 1


for i in range(int(input())):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	ans = 'No'
	x = -1
	for j in range(n):
		if s1[j] != s2[j]:
			x = j
			break
	if x == -1:
		a = [0] * 26
		b = [0] * 26
		for j in range(n):
			a[ord(s1[j]) - 97] += 1
			b[ord(s2[j]) - 97] += 1
		for j in range(26):
			if a[j] > 1:
				ans = 'Yes'
		print(ans)
	else:
		aa = ''
		bb = ''
		for j in range(n):
			if s1[j] != s2[j]:
				aa += s1[j]
				bb += s2[j]
		if len(aa) == 2:
			if aa[0] == aa[1] and bb[0] == bb[1]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	b = []
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			b.append(i)
	if count == 2:
		if s[b[0]] == s[b[1]] and t[b[0]] == t[b[1]]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	f = 0
	ans = []
	for i in range(n):
		if s1[i] != s2[i]:
			for j in range(i + 1, n):
				if s2[j] == s1[i]:
					ans.append([n, j + 1])
					ans.append([n, i + 1])
					(s2[i], s2[j]) = (s2[j], s2[i])
					(s1[n - 1], s2[j]) = (s2[j], s1[n - 1])
					break
				elif s1[j] == s1[i]:
					ans.append([j + 1, i + 1])
					(s1[j], s2[i]) = (s2[i], s1[j])
					break
			else:
				f = 1
				break
	if f == 1:
		print('No')
		continue
	print('Yes')
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


q = int(input())
for _ in range(q):
	n = int(input())
	xs = input()
	ys = input()
	change_x = list()
	change_y = list()
	for (x, y) in zip(xs, ys):
		if x == y:
			continue
		else:
			change_x.append(x)
			change_y.append(y)
	if len(change_x) > 2 or len(change_x) == 1:
		print('No')
	elif len(change_x) == 0:
		print('Yes')
	elif change_x[0] == change_x[1] and change_y[0] == change_y[1]:
		print('Yes')
	else:
		print('No')


from collections import Counter

def run_testcase():
	n = int(input())
	string1 = input()
	string2 = input()
	char_counter = Counter(string1 + string2)
	for (char, count) in char_counter.items():
		if count % 2 == 1:
			print('No')
			return
	string1 = list(string1)
	string2 = list(string2)

	def find(string, char, left):
		for i in range(left, len(string)):
			if string[i] == char:
				return i
		return -1
	moves = []
	for i in range(n):
		if string1[i] == string2[i]:
			continue
		find_in_string2 = find(string2, string2[i], i + 1)
		if find_in_string2 != -1:
			(string1[i], string2[find_in_string2]) = (string2[find_in_string2], string1[i])
			moves.append((i, find_in_string2))
			continue
		find_in_string1 = find(string1, string2[i], i + 1)
		(string2[i + 1], string1[find_in_string1]) = (string1[find_in_string1], string2[i + 1])
		moves.append((find_in_string1, i + 1))
		(string1[i], string2[i + 1]) = (string2[i + 1], string1[i])
		moves.append((i, i + 1))
	print('Yes')
	print(len(moves))
	for move in moves:
		print(move[0] + 1, move[1] + 1, sep=' ')
testcase_count = int(input())
for i in range(testcase_count):
	run_testcase()


k = int(input())
for i in range(k):
	n = int(input())
	(s, t) = [input() for i2 in range(2)]
	if s == t:
		print('Yes')
	else:
		j2 = -1
		k2 = -1
		for i2 in range(n):
			if s[i2] != t[i2]:
				if j2 == -1:
					j2 = i2
				elif k2 == -1:
					k2 = i2
				else:
					print('No')
					break
		else:
			if j2 != -1 and k2 != -1 and (s[j2] == s[k2]) and (t[k2] == t[j2]):
				print('Yes')
			else:
				print('No')


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	t = input()
	c = list()
	for i in range(n):
		if s[i] != t[i]:
			c.append(i)
	if len(c) == 2 and s[c[0]] == s[c[1]] and (t[c[1]] == t[c[0]]):
		print('Yes')
	else:
		print('No')


q = int(input())
for qq in range(q):
	n = int(input())
	s1 = input()
	s2 = input()
	di = []
	for i in range(n):
		if s1[i] != s2[i]:
			di += [[s1[i], s2[i]]]
	if len(di) == 2 and di[0] == di[1]:
		print('YES')
	else:
		print('NO')


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')
for i in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	d = dict()
	for j in range(n):
		if t[j] in d:
			d[t[j]] += 1
		else:
			d.update({t[j]: 1})
		if s[j] in d:
			d[s[j]] += 1
		else:
			d.update({s[j]: 1})
	f = 0
	for j in d:
		if d[j] % 2 != 0:
			f = 1
			break
	if f == 1:
		print('No')
	else:
		ans = []
		print('Yes')
		for j in range(n):
			if s[j] != t[j]:
				for k in range(j + 1, n):
					if s[k] == s[j]:
						(t[j], s[k]) = (s[k], t[j])
						ans.append([k + 1, j + 1])
						break
					elif t[k] == s[j]:
						(t[k], s[k]) = (s[k], t[k])
						ans.append([k + 1, k + 1])
						(t[j], s[k]) = (s[k], t[j])
						ans.append([k + 1, j + 1])
						break
		print(len(ans))
		for d in range(len(ans)):
			print(ans[d][0], ans[d][1])


k = int(input())
for K in range(k):
	n = int(input())
	s = input()
	t = input()
	c = 0
	for i in range(n):
		if s[i] == t[i]:
			c = c + 1
	flag = False
	if c == n - 2:
		flag = True
	if flag:
		f = False
		pos1 = 0
		pos2 = 0
		for i in range(n):
			if s[i] != t[i]:
				if f == False:
					pos1 = i
					f = True
				else:
					pos2 = i
		if s[pos1] == s[pos2] and t[pos1] == t[pos2]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	s1 = []
	t1 = []
	for j in range(n):
		if s[j] != t[j]:
			count += 1
			s1.append(s[j])
			t1.append(t[j])
	if count == 2 and s1[0] == s1[1] and (t1[0] == t1[1]):
		print('Yes')
	else:
		print('No')


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]
(k,) = rl()
for _ in range(k):
	(n,) = rl()
	s = stdin.readline().strip()
	t = stdin.readline().strip()
	st = list(s + t)
	pos = {c: set() for c in st}
	for (i, c) in enumerate(st):
		pos[c].add(i)
	ops = []
	try:
		for i in range(n):
			c = st[i]
			c2 = st[n + i]
			pos[c].remove(i)
			if c == c2:
				pos[c].remove(n + i)
				continue
			j = pos[c].pop()
			st[j] = c2
			pos[c2].remove(n + i)
			pos[c2].add(j)
			if j < n:
				ops.append('%d %d' % (j + 1, i + 1))
			else:
				ops.append('%d %d' % (i + 1, i + 1))
				ops.append('%d %d' % (i + 1, j + 1 - n))
		print('Yes')
		print(len(ops))
		for op in ops:
			print(op)
	except KeyError:
		print('No')


from math import floor, ceil
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	different = []
	for i in range(n):
		if a[i] != b[i]:
			different.append((a[i], b[i]))
	if len(different) == 0 or (len(different) == 2 and different[0] == different[1]):
		print('Yes')
	else:
		print('No')


def get_next(s, i, a):
	for j in range(i, len(s)):
		if s[j] == a:
			return j
	return -1
T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	t = input()
	s = list(s)
	t = list(t)
	cnt = 0
	No = False
	ans = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		j_s = get_next(s, i + 1, s[i])
		j_t = get_next(t, i + 1, t[i])
		if j_s != -1:
			(t[i], s[j_s]) = (s[j_s], t[i])
			ans.append((j_s + 1, i + 1))
			cnt += 1
		elif j_t != -1:
			(s[i], t[j_t]) = (t[j_t], s[i])
			ans.append((i + 1, j_t + 1))
			cnt += 1
		else:
			j_s = get_next(s, i + 1, t[i])
			j_t = get_next(t, i + 1, s[i])
			if j_s == -1 or j_t == -1:
				No = True
				break
			(s[j_s], t[j_t]) = (t[j_t], s[j_s])
			ans.append((j_s + 1, j_t + 1))
			(s[i], t[j_t]) = (t[j_t], s[i])
			ans.append((i + 1, j_t + 1))
			cnt += 2
	if No:
		print('No')
	else:
		print('Yes')
		print(cnt)
		for swap in ans:
			print(swap[0], swap[1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	diff = []
	for i in range(n):
		if count > 2:
			break
		if s[i] != t[i]:
			count += 1
			if len(diff) > 0 and s[i] == diff[0][0] and (t[i] == diff[0][1]) or len(diff) == 0:
				diff.append((s[i], t[i]))
	if count == 2 and len(diff) == 2:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	ch = []
	for i in range(n):
		if s[i] != t[i]:
			ch.append(i)
			c += 1
		if c > 2:
			break
	if c > 2 or c <= 1:
		print('No')
		continue
	i = ch[0]
	j = ch[1]
	(s[i], t[j]) = (t[j], s[i])
	if s == t:
		print('Yes')
	else:
		print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	match = 0
	mismatchs = []
	mismatcht = []
	for i in range(n):
		if s[i] == t[i]:
			match += 1
		else:
			mismatchs.append(s[i])
			mismatcht.append(t[i])
	if match < n - 2 or match == n - 1:
		print('no')
	elif match == n - 2:
		print('yes' if mismatchs[0] == mismatchs[1] and mismatcht[0] == mismatcht[1] else 'no')
	else:
		print('yes')


k = int(input())
for i in range(k):
	di = {}
	ci = {}
	l = int(input())
	n = l
	s = list(input())
	t = list(input())
	d = 0
	for j in range(l):
		if s[j] in di:
			di[s[j]] += 1
		else:
			di[s[j]] = 1
		if t[j] in di:
			di[t[j]] += 1
		else:
			di[t[j]] = 1
	bon = True
	ref = {}
	tt = 0
	for le in di:
		if di[le] % 2 != 0:
			print('No')
			bon = False
			break
		else:
			ref[le] = tt
		tt += di[le] // 2
	if bon:
		print('Yes')
		sw = []
		for j in range(l):
			le = s[j]
			if t[j] == le:
				continue
			if not le in s[j + 1:]:
				jj = t[j + 1:].index(le) + j + 1
				(t[jj], s[jj]) = (s[jj], t[jj])
				sw.append([jj + 1, jj + 1])
			jj = s[j + 1:].index(le) + j + 1
			(t[j], s[jj]) = (s[jj], t[j])
			sw.append([jj + 1, j + 1])
		print(len(sw))
		for tr in sw:
			print(tr[0], tr[1])


n = int(input())
for _ in range(n):
	a = int(input())
	b = input()
	B = []
	c = input()
	C = []
	for i in range(len(b)):
		if b[i] != c[i]:
			B.append(b[i])
			C.append(c[i])
	if len(B) == 2 and B[0] == B[1] and (C[1] == C[0]):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	h = []
	n = int(input())
	k = input()
	l = input()
	for j in range(n):
		if k[j] != l[j]:
			h.append([k[j], l[j]])
	if len(h) != 2:
		print('No')
	elif h[0] == h[1]:
		print('Yes')
	else:
		print('No')


import sys
import math

def readline():
	return input()

def fun(s, t):
	n = len(s)
	for i in range(n):
		if s[i] != t[i]:
			for j in range(i + 1, n):
				if s[j] != t[j]:
					if s[i] == s[j] and t[i] == t[j]:
						ls = list(s)
						lt = list(t)
						(ls[i], lt[j]) = (lt[j], ls[i])
						if ''.join(ls) == ''.join(lt):
							print('Yes')
						else:
							print('No')
					else:
						print('No')
					return
	print('No')
q = int(readline())
for i in range(q):
	n = int(readline())
	s = readline()
	t = readline()
	ans = fun(s, t)


num = int(input())
for i in range(num):
	len = int(input())
	A = input()
	B = input()
	count = 0
	a1 = a2 = b1 = b2 = ''
	for j in range(len):
		if A[j] != B[j]:
			if count == 0:
				a1 = A[j]
				b1 = B[j]
			elif count == 1:
				a2 = A[j]
				b2 = B[j]
			count += 1
	print('Yes') if (a1 == a2 and b2 == b1) and count == 2 else print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	if s == t:
		print('YES')
	count = 0
	diff = []
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			diff.append(i)
	if count == 0:
		print('YES')
	elif count > 2 or count == 1:
		print('NO')
	elif s[diff[0]] == s[diff[1]] and t[diff[1]] == t[diff[0]]:
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

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

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

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		n = ii()
		s = list(si())
		t = list(si())
		a = [0] * 26
		b = [0] * 26
		for i in range(n):
			a[abd[s[i]]] += 1
			b[abd[t[i]]] += 1
		f = 1
		for i in range(26):
			if (a[i] + b[i]) % 2 != 0:
				print('NO')
				f = 0
				break
		if f == 0:
			continue
		print('Yes')
		cnt = 0
		ans = []
		for i in range(n):
			if s[i] != t[i]:
				f = 1
				for j in range(n):
					if i == j:
						continue
					if s[j] != t[j] and s[j] == s[i]:
						(t[i], s[j]) = (s[j], t[i])
						ans.append([j + 1, i + 1])
						f = 0
						break
				if f == 1:
					for k in range(n):
						if i == k:
							continue
						if s[k] != t[k] and t[k] == s[i]:
							(s[k], t[k]) = (t[k], s[k])
							ans.append([k + 1, k + 1])
							(t[i], s[k]) = (s[k], t[i])
							ans.append([k + 1, i + 1])
							break
		print(len(ans))
		for i in ans:
			print(*i)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	f = 0
	l = []
	for i in range(n):
		if s1[i] != s2[i]:
			l.append(i)
		if len(l) > 2:
			print('No')
			break
	else:
		if len(l) == 0 or (len(l) == 2 and s1[l[0]] == s1[l[1]] and (s2[l[0]] == s2[l[1]])):
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	N = int(input())
	s = input()
	a = 0
	t = input()
	C = []
	D = []
	for i in range(N):
		if s[i] != t[i]:
			a += 1
			C.append(s[i])
			D.append(t[i])
	if a == 2 and len(set(C)) == 1 and (len(set(D)) == 1):
		print('Yes')
	else:
		print('No')


k = int(input())
for _ in range(k):
	d = int(input())
	str1 = input()
	str2 = input()
	letter = []
	total = 0
	for a in range(d):
		if str1[a] != str2[a]:
			total += 1
			letter.append(str1[a])
			letter.append(str2[a])
	if total == 2 and letter[0] == letter[2] and (letter[1] == letter[3]):
		print('YES')
	else:
		print('NO')


i = input
for _ in range(int(i())):
	i()
	l1 = [(x, y) for (x, y) in zip(i(), i()) if x != y]
	print('YNEOS'[l1 != [l1[0]] * 2::2])


n = int(input())
for i in range(n):
	m = int(input())
	l = []
	s = str(input())
	s1 = str(input())
	for j in range(0, len(s)):
		if s[j] != s1[j]:
			l.append(s[j])
			l.append(s1[j])
	d = set(l)
	if len(l) == 4 and len(d) == 2 and (l[0] != l[3] or l[1] != l[2]):
		print('Yes')
	else:
		print('No')


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')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	str1 = [k for k in input()]
	str2 = [k for k in input()]
	dict1 = {}
	dict2 = {}
	outy = []
	broke = False
	for s in range(n):
		if str1[s] == str2[s]:
			continue
		else:
			aim = str1[s]
			ind = s
			found1 = False
			found2 = False
			for b in range(s + 1, n):
				if str1[b] == aim:
					ind = b
					found1 = True
					break
			if found1 == True:
				outy.append((ind + 1, s + 1))
				(str1[ind], str2[s]) = (str2[s], str1[ind])
			elif found1 == False:
				for b in range(s + 1, n):
					if str2[b] == aim:
						ind = b
						found2 = True
						break
				if found1 == False and found2 == False:
					broke = True
					break
				else:
					outy.append((n, ind + 1))
					(str1[n - 1], str2[ind]) = (str2[ind], str1[n - 1])
					outy.append((n, s + 1))
					(str1[n - 1], str2[s]) = (str2[s], str1[n - 1])
	if broke == True:
		print('No')
	else:
		print('Yes')
		print(len(outy))
		for i in range(len(outy)):
			print(*outy[i])


def swapp(a, b):
	f = 0
	ar = []
	for i in range(len(a)):
		if a[i] != b[i]:
			f += 1
			ar.append(a[i])
			ar.append(b[i])
	if f == 2 and (ar[0] == ar[2] and ar[1] == ar[3]) or a == b:
		return True
	else:
		return False
t = int(input())
for ts in range(t):
	n = int(input())
	a = input()
	b = input()
	if swapp(a, b):
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
from math import gcd, sqrt, factorial
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	x = list(map(lambda x: ord(x) - 97, S()))
	y = list(map(lambda x: ord(x) - 97, S()))
	a = [[] for i in range(26)]
	b = [[] for i in range(26)]
	v = [0] * 26
	for i in range(n):
		v[x[i]] += 1
		v[y[i]] += 1
		a[x[i]] += (i,)
		b[y[i]] += (i,)
	if 1 in [i & 1 for i in v]:
		print('No')
		continue
	ans = []
	for i in range(n):
		a[x[i]].remove(i)
		b[y[i]].remove(i)
		if x[i] != y[i]:
			if a[x[i]]:
				mn = min(a[x[i]])
				a[x[i]].remove(mn)
				ans += ((mn + 1, i + 1),)
				a[y[i]] += (mn,)
				(x[mn], y[i]) = (y[i], x[mn])
			else:
				ans += ((i + 1, i + 1),)
				mn = min(b[x[i]])
				b[x[i]].remove(mn)
				ans += ((i + 1, mn + 1),)
				b[y[i]] += (mn,)
				(y[mn], y[i]) = (y[i], y[mn])
	print('Yes')
	print(len(ans))
	for i in ans:
		print(*i)


import sys
import itertools
import math
import collections
from collections import Counter

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

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
for _ in range(t):
	n = ii()
	a = input()
	b = input()
	col = []
	for i in range(n):
		if a[i] != b[i]:
			col.append(i)
	if len(col) == 0:
		print('Yes')
		continue
	if len(col) != 2:
		print('No')
		continue
	if a[col[0]] == a[col[1]] and b[col[0]] == b[col[1]]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	unequal = []
	for pair in zip(s, t):
		if pair[0] != pair[1]:
			unequal.append(pair)
		if len(unequal) > 2:
			break
	answer = 'NO'
	if len(unequal) == 0:
		answer = 'YES'
	elif len(unequal) == 2:
		if unequal[0][0] == unequal[1][0] and unequal[0][1] == unequal[1][1]:
			answer = 'YES'
	print(answer)


for _ in range(int(input())):
	n = int(input())
	l = input()
	k = input()
	f = 0
	l1 = ''
	k1 = ''
	ans = 1
	for t in range(len(l)):
		if f == 2 and l[t] != k[t]:
			ans = 0
			break
		if l[t] != k[t] and f == 0:
			l1 = l[t]
			k1 = k[t]
			f += 1
			ans = 0
		elif f == 1 and l[t] != k[t]:
			f += 1
			if l[t] != l1 or k[t] != k1:
				ans = 0
			if l[t] == l1 and k[t] == k1:
				ans = 1
	if ans:
		print('Yes')
	else:
		print('No')


import sys

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	S = input()
	T = input()
	A = []
	B = []
	cnt = 0
	for i in range(N):
		if S[i] != T[i]:
			cnt += 1
			A.append(S[i])
			B.append(T[i])
	if cnt == 0:
		Yes()
	elif cnt == 2:
		if A[0] == A[1] and B[0] == B[1]:
			Yes()
		else:
			No()
	else:
		No()


def swap(i, j):
	global st, tt
	xx = st[i]
	st[i] = tt[j]
	tt[j] = xx
for _ in range(int(input())):
	n = int(input())
	st = list(input())
	tt = list(input())
	dic = {}
	for i in st:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	for i in tt:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	flag = True
	for i in dic:
		if dic[i] % 2 != 0:
			flag = False
	if flag:
		print('Yes')
		ans = 0
		li = []
		for i in range(n):
			if st[i] != tt[i]:
				for j in range(i + 1, n):
					if st[j] == st[i]:
						ans += 1
						li.append([j + 1, i + 1])
						swap(j, i)
						break
					elif st[i] == tt[j]:
						ans += 2
						li.append([j + 1, j + 1])
						swap(j, j)
						li.append([j + 1, i + 1])
						swap(j, i)
						break
		print(ans)
		for i in li:
			print(*i)
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	i1 = -1
	i2 = -1
	ct = 0
	for i in range(n):
		if s1[i] == s2[i]:
			continue
		ct += 1
		if i1 == -1:
			i1 = i
		else:
			i2 = i
	if ct > 2 or ct == 1:
		print('No')
		continue
	if ct == 0 or (ct == 2 and (s1[i1] == s1[i2] and s2[i1] == s2[i2])):
		print('Yes')
	else:
		print('No')


tests = int(input())
result = []
for i in range(tests):
	length = int(input())
	n1 = input()
	n2 = input()
	no_matches = 0
	n1_unmatched = []
	n2_unmatched = []
	for k in range(length):
		if n1[k] != n2[k]:
			no_matches += 1
			n1_unmatched.append(n1[k])
			n2_unmatched.append(n2[k])
	if no_matches == 2:
		if n1_unmatched[0] == n1_unmatched[1] and n2_unmatched[0] == n2_unmatched[1]:
			result.append('Yes')
		else:
			result.append('No')
	else:
		result.append('No')
for x in result:
	print(x)


k = int(input())
for _ in range(k):
	n = int(input())
	s = list(input().strip())
	t = list(input().strip())
	d = {}
	for i in range(n):
		if s[i] != t[i]:
			try:
				d[s[i], t[i]] += 1
			except:
				d[s[i], t[i]] = 1
	if len(d) == 1 and list(d.values())[0] == 2:
		print('Yes')
	else:
		print('No')


import sys

def character_swap(s1, s2):
	a = []
	i = counter = 0
	for (x, y) in zip(s1, s2):
		if x != y:
			counter += 1
			a.append(i)
		if counter > 2:
			print('No')
			return
		i += 1
	if counter < 2:
		print('No')
		return
	if s1[a[0]] == s1[a[1]] and s2[a[1]] == s2[a[0]]:
		print('Yes')
	else:
		print('No')
	return
for (i, line) in enumerate(sys.stdin):
	if i % 3 == 2:
		s1 = line
	elif i != 0 and i % 3 == 0:
		s2 = line
		character_swap(s1, s2)


for q in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	d = True
	tmp = 0
	for i in range(n):
		if t[i] != s[i]:
			for r in range(i + 1, n):
				if t[r] != s[r]:
					if t[r] == t[i] and s[r] == s[i]:
						tmp += 1
						t = t[:r] + t[i] + t[r + 1:]
						s = s[:r] + s[i] + s[r + 1:]
						if tmp > 1:
							d = False
					else:
						d = False
				if not d:
					break
			if tmp == 0:
				d = False
		if not d:
			break
	print('Yes' if d else 'No')


k = int(input())

def task():
	n = int(input())
	lst1 = str(input())
	lst2 = str(input())
	differance = 0
	differancelst1 = {}
	differancelst2 = {}
	for r in range(n):
		if lst1[r] != lst2[r]:
			differance += 1
			if differancelst1 == {}:
				differancelst1[lst1[r]] = 1
				differancelst2[lst2[r]] = 1
			else:
				if not lst1[r] in differancelst1:
					return 'No'
				if not lst2[r] in differancelst2:
					return 'No'
		if differance > 2:
			return 'No'
	if differance == 0 or differance == 2:
		return 'Yes'
	return 'No'
for i in range(k):
	print(task())


def equality(n, s1, s2):
	if s1 == s2:
		return 'Yes'
	diff = []
	for i in range(n):
		if s1[i] != s2[i]:
			diff.append(i)
	if len(diff) != 2:
		return 'No'
	if s1[diff[0]] == s1[diff[1]] and s2[diff[0]] == s2[diff[1]]:
		return 'Yes'
	return 'No'
for i in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	print(equality(n, s1, s2))


for _ in range(int(input())):
	x = int(input())
	a = list(input())
	b = list(input())
	z = []
	s = []
	l = 0
	for n in range(x):
		if a[n] != b[n]:
			l += 1
			z.append(a[n])
			s.append(b[n])
	if l != 2:
		print('No')
	elif s[0] == s[1] and z[0] == z[1]:
		print('Yes')
	else:
		print('No')


import sys
for t in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	s1 = [ord(c) - 97 for c in sys.stdin.readline().strip()]
	s2 = [ord(c) - 97 for c in sys.stdin.readline().strip()]
	badl = [[], []]
	for i in range(n):
		if s1[i] != s2[i]:
			badl[0].append(s1[i])
			badl[1].append(s2[i])
	if len(badl[0]) not in [0, 2]:
		print('No')
	elif len(badl) == 0:
		print('Yes')
	elif badl[0][0] == badl[0][1] and badl[1][0] == badl[1][1]:
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	arr1 = list(input())
	arr2 = list(input())
	diff = []
	wDict = {}
	isPossible = False
	isPossibleByDict = False
	for w in range(n):
		if not isPossibleByDict:
			if wDict.get(arr1[w]):
				isPossibleByDict = True
			else:
				wDict[arr1[w]] = 1
		if len(diff) > 4:
			break
		if arr1[w] != arr2[w]:
			diff.append(arr1[w])
			diff.append(arr2[w])
	if len(diff) == 4:
		if diff[0] == diff[2] and diff[1] == diff[3]:
			isPossible = True
		elif diff[1] == diff[2] == diff[3] == diff[0]:
			isPossible = True
	if isPossible:
		print('Yes')
	elif arr1 == arr2 and isPossibleByDict:
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(input())
	b = list(input())
	index = []
	for i in range(n):
		if a[i] != b[i]:
			index.append(i)
	if len(index) != 2:
		print('No')
	else:
		firsti = index[0]
		seci = index[1]
		if a[firsti] == a[seci] and b[firsti] == b[seci]:
			print('Yes')
		else:
			print('No')


def calc():
	n = int(input())
	s = input()
	t = input()
	diffs = set()
	for i in range(n):
		if s[i] != t[i]:
			diffs.add(i)
	if len(diffs) == 2:
		(i, j) = diffs
		if s[i] == s[j] and t[i] == t[j]:
			return 'YES'
	return 'NO'

def main():
	k = int(input())
	for _ in range(k):
		print(calc())
main()


noInputs = int(input())
for i in range(noInputs):
	lenStr = int(input())
	str1 = input()
	str2 = input()
	notSame = []
	for i in range(lenStr):
		if str1[i] != str2[i]:
			notSame.append(i)
	if len(notSame) == 0:
		print('Yes')
	elif len(notSame) == 2:
		if str1[notSame[0]] == str1[notSame[1]] and str2[notSame[0]] == str2[notSame[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
while k > 0:
	k -= 1
	n = int(input())
	s = input()
	t = input()
	c = 0
	ans = 1
	for i in range(n):
		if s[i] != t[i]:
			if c == 0:
				c += 1
				a = s[i]
				b = t[i]
			elif c == 2:
				ans = 0
				break
			else:
				c += 1
				if s[i] != a or t[i] != b:
					ans = 0
					break
	if c == 1:
		ans = 0
	if ans == 0:
		print('No')
	else:
		print('Yes')


from sys import stdin
t = int(stdin.readline().rstrip())
while t > 0:
	n = int(stdin.readline().rstrip())
	s = stdin.readline().rstrip()
	r = stdin.readline().rstrip()
	c = 0
	(s1, s2) = (set(), set())
	for i in range(n):
		if s[i] != r[i]:
			c += 1
			s1.add(s[i])
			s2.add(r[i])
	if c == 0 or (c == 2 and len(s1) == 1 and (len(s2) == 1)):
		print('YES')
	else:
		print('NO')
	t -= 1


k = int(input())
for _ in range(k):
	n = int(input())
	(s, t) = (input(), input())
	k = ()
	for i in range(n):
		if s[i] != t[i]:
			k += (i,)
			if len(k) > 2:
				print('No')
				break
			if len(k):
				if not (s[k[0]] == s[i] and t[k[0]] == t[i]):
					print('No')
					break
	else:
		if len(k) == 1:
			print('No')
		else:
			print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	k = input()
	r = []
	for i in range(n):
		if s[i] != k[i]:
			r.append([s[i], k[i]])
	if len(r) != 2:
		print('No')
	elif r[0] == r[1]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	cc = {}
	for c in s:
		cc[c] = cc.get(c, 0) + 1
	for c in t:
		cc[c] = cc.get(c, 0) + 1
	for (c, v) in cc.items():
		if v % 2:
			print('No')
			break
	else:
		print('Yes')
		swaps = []
		for i in range(n):
			if s[i] != t[i]:
				for j in range(i + 1, n):
					if t[j] == s[i]:
						swaps.append((j + 1, j + 1))
						(s[j], t[j]) = (t[j], s[j])
						break
				for j in range(i + 1, n):
					if s[j] == s[i]:
						swaps.append((j + 1, i + 1))
						(s[j], t[i]) = (t[i], s[j])
						break
		print(len(swaps))
		for s in swaps:
			print(*s)


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

def main():
	for _ in range(int(input())):
		n = int(input())
		s = list(input())
		t = list(input())
		c = Counter(s + t)
		flag = 0
		for val in c.values():
			if val % 2:
				flag = 1
				break
		if flag:
			print('No')
			continue
		ans = []
		for i in range(n):
			if s[i] == t[i]:
				continue
			for j in range(i + 1, n):
				if s[i] == s[j]:
					ans.append((j + 1, i + 1))
					(s[j], t[i]) = (t[i], s[j])
					break
				elif s[i] == t[j]:
					ans.append((j + 1, j + 1))
					(s[j], t[j]) = (t[j], s[j])
					ans.append((j + 1, i + 1))
					(s[j], t[i]) = (t[i], s[j])
					break
		print('Yes')
		print(len(ans))
		for x in ans:
			print(*x)
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()


def solve():
	n = int(input())
	s = input().strip()
	t = input().strip()
	pos = []
	for i in range(n):
		if s[i] != t[i]:
			pos.append(i)
	if len(pos) != 2:
		print('No')
	else:
		attempt_s = list(s)
		attempt_s[pos[0]] = t[pos[1]]
		attempt_t = list(t)
		attempt_t[pos[1]] = s[pos[0]]
		if attempt_s == attempt_t:
			print('Yes')
		else:
			attempt_s = list(s)
			attempt_s[pos[1]] = t[pos[0]]
			attempt_t = list(t)
			attempt_t[pos[0]] = s[pos[1]]
			if attempt_s == attempt_t:
				print('Yes')
			else:
				print('No')
runs = int(input())
while runs > 0:
	solve()
	runs -= 1


t = int(input())
for l in range(t):
	n = int(input())
	s = list(input())
	k = list(input())
	i = 0
	swap = 0
	ans = list()
	flag2 = False
	while i < n and swap <= 2 * n and (not flag2):
		if s[i] == k[i]:
			i += 1
		else:
			flag = True
			for j in range(i + 1, n):
				if s[j] == s[i]:
					omg = k[i]
					k[i] = s[j]
					s[j] = omg
					ans.append([j + 1, i + 1])
					i += 1
					swap += 1
					flag = False
					break
			if flag:
				for j in range(i + 1, n):
					if s[i] == k[j]:
						omg = k[j]
						k[j] = s[-1]
						s[-1] = omg
						ans.append([n, j + 1])
						omg = k[i]
						k[i] = s[-1]
						s[-1] = omg
						ans.append([n, i + 1])
						swap += 2
						i += 1
						flag = False
			if flag:
				flag2 = True
	if flag2:
		print('NO')
	elif swap >= 2 * n:
		print('NO')
	else:
		print('YES')
		print(swap)
		for zaw in ans:
			print(zaw[0], zaw[1])


n = int(input())
for i in range(n):
	length = int(input())
	x1 = input()
	x2 = input()
	aux = []
	for j in range(length):
		if x1[j] != x2[j]:
			aux.append([x1[j], x2[j]])
	ans = False
	if len(aux) == 2:
		if aux[0] == aux[1]:
			ans = True
	if ans:
		print('YES')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	mark = [0] * 26
	for i in range(n):
		mark[ord(s[i]) - 97] += 1
		mark[ord(t[i]) - 97] += 1
	flag = False
	for num in mark:
		if num % 2 == 1:
			flag = True
			break
	if flag:
		print('No')
		continue
	ss = []
	tt = []
	for i in range(n):
		ss.append(s[i])
		tt.append(t[i])
	ans = []
	for i in range(n):
		if ss[i] != tt[i]:
			flag = True
			for j in range(i + 1, n):
				if ss[j] == ss[i]:
					flag = False
					temp = ss[j]
					ss[j] = tt[i]
					tt[i] = temp
					ans.append((j, i))
					break
			if flag:
				for j in range(i + 1, n):
					if ss[i] == tt[j]:
						temp = tt[j]
						tt[j] = ss[j]
						ss[j] = temp
						ans.append((j, j))
						temp = ss[j]
						ss[j] = tt[i]
						tt[i] = temp
						ans.append((j, i))
						break
	print('Yes')
	print(len(ans))
	for tup in ans:
		print(tup[0] + 1, tup[1] + 1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	seq = []
	for i in range(0, n):
		if a[i] == b[i]:
			continue
		found = 0
		for j in range(i + 1, n):
			if a[j] == a[i]:
				found = 1
				seq += [str(j + 1) + ' ' + str(i + 1)]
				t = b[i]
				b = b[:i] + a[j] + b[i + 1:]
				a = a[:j] + t + a[j + 1:]
				break
		if found == 1:
			continue
		for j in range(i + 1, n):
			if b[j] == a[i]:
				seq += [str(j + 1) + ' ' + str(j + 1)]
				found = 1
				t = a[j]
				a = a[:j] + b[j] + a[j + 1:]
				b = b[:j] + t + b[j + 1:]
				seq += [str(j + 1) + ' ' + str(i + 1)]
				t = b[i]
				b = b[:i] + a[j] + b[i + 1:]
				a = a[:j] + t + a[j + 1:]
				break
		if found == 1:
			continue
		break
	if a == b:
		print('Yes')
		print(len(seq))
		for j in seq:
			print(j)
	else:
		print('No')


for x in range(int(input())):
	n = int(input())
	m1 = input()
	m2 = input()
	s1 = ''
	s2 = ''
	v = 0
	s3 = ''
	s4 = ''
	for (i, n) in enumerate(m1):
		if m1[i] != m2[i]:
			v += 1
			if s1 == '':
				s1 = m1[i]
				s2 = m2[i]
			else:
				s3 = m1[i]
				s4 = m2[i]
	if v == 2 and s1 == s3 and (s2 == s4):
		print('YES')
	elif v == 0:
		print('YES')
	else:
		print('NO')


from collections import Counter
k = int(input())
for _ in range(k):
	n = int(input())
	A = list(input())
	B = list(input())
	C = Counter(A + B)
	ans = True
	for c in C:
		ans = ans and (not C[c] % 2)
	if not ans:
		print('No')
		continue
	swaps = []
	for i in range(n):
		if A[i] == B[i]:
			continue
		for j in range(i + 1, n):
			if A[i] == A[j]:
				swaps.append((j + 1, i + 1))
				(B[i], A[j]) = (A[j], B[i])
				break
			elif A[i] == B[j]:
				swaps.append((j + 1, j + 1))
				(A[j], B[j]) = (B[j], A[j])
				swaps.append((j + 1, i + 1))
				(B[i], A[j]) = (A[j], B[i])
				break
	print('Yes')
	print(len(swaps))
	for x in swaps:
		print(*x)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	d1 = {}
	for i in a:
		if d1.get(i):
			d1[i] = d1[i] + 1
		else:
			d1[i] = 1
	d2 = {}
	for i in b:
		if d2.get(i):
			d2[i] = d2[i] + 1
		else:
			d2[i] = 1
	cnt = 0
	a1 = []
	b1 = []
	for i in range(len(a)):
		if a[i] != b[i]:
			cnt += 1
			a1.append(a[i])
			b1.append(b[i])
		if cnt > 2:
			break
	if cnt == 2:
		if a1[1] == a1[0] and b1[1] == b1[0]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


loop = int(input())
while loop:
	loop -= 1
	length = int(input())
	a = input()
	b = input()
	l = []
	for i in range(length):
		if a[i] != b[i]:
			l.append([a[i], b[i]])
	if len(l) != 2:
		print('No')
	elif l[0] == l[1]:
		print('Yes')
	else:
		print('No')


Q = int(input())
while Q > 0:
	n = int(input())
	s = list(input())
	t = list(input())
	b = True
	res = True
	for i in range(n):
		if s[i] != t[i]:
			if b:
				for j in range(i + 1, n):
					if t[j] == t[i]:
						if t[j] == s[j]:
							continue
						(t[j], s[i]) = (s[i], t[j])
						b = False
						break
				if b:
					res = False
					break
			else:
				res = False
				break
	Q -= 1
	if res:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	d = dict()
	c = 1
	temp = 0
	for (i, j) in zip(s1, s2):
		if i != j:
			if i not in d:
				d[i] = j
			elif d[i] == j:
				c += 1
			else:
				temp = 1
				break
			if len(d) > 1 or c > 2:
				temp = 1
				break
	if temp == 0 and c != 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	l = [i for i in range(len(s)) if s[i] != t[i]]
	if len(l) == 0 or (len(l) == 2 and s[l[0]] == s[l[1]] and (t[l[0]] == t[l[1]])):
		print('Yes')
	else:
		print('No')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def seive():
	prime = [1 for i in range(10 ** 6 + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(10 ** 6 + 1):
		if prime[i]:
			for j in range(2 * i, 10 ** 6 + 1, i):
				prime[j] = 0
for _ in range(l()[0]):
	n = l()[0]
	s = list(input())
	t = list(input())
	ans = []
	i = 0
	for i in range(n):
		if s[i] == t[i]:
			continue
		for j in range(i + 1, n):
			if s[i] == s[j]:
				(s[j], t[i]) = (t[i], s[j])
				ans.append([j + 1, i + 1])
				break
			elif s[i] == t[j]:
				(t[j], s[j]) = (s[j], t[j])
				ans.append([j + 1, j + 1])
				(s[j], t[i]) = (t[i], s[j])
				ans.append([j + 1, i + 1])
				break
	if s != t:
		print('No')
		continue
	print('Yes')
	print(len(ans))
	for x in ans:
		print(*x)


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	a = [0] * 2
	count = 1
	for i in range(n):
		if s[i] is not t[i] and count < 3:
			a[count - 1] = i
			count += 1
	b = list(s)
	c = list(t)
	temp = b[a[0]]
	b[a[0]] = c[a[1]]
	c[a[1]] = temp
	if b == c:
		print('Yes')
	else:
		print('No')


import math
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	cnt = 1
	wrong = 0
	res = []
	for i in range(n):
		if s[i] != t[i]:
			if cnt < 3:
				arr = []
				arr.append(s[i])
				arr.append(t[i])
				res.append(arr)
				cnt += 1
			else:
				wrong = 1
	if wrong == 1:
		print('NO')
	else:
		right = 1
		k = len(res)
		if k == 1:
			print('NO')
		else:
			for i in range(k):
				if res[0][i] != res[1][i]:
					right = 0
			if right == 0:
				print('NO')
			else:
				print('YES')


for _ in range(int(input())):
	n = int(input())
	s1 = str(input())
	s2 = str(input())
	c = 0
	l = []
	for i in range(n):
		if s1[i] != s2[i]:
			c += 1
			l.append(i)
			l.append(s1[i])
			l.append(s2[i])
	if c != 2:
		print('NO')
	elif l[1] == l[4] and l[2] == l[5]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	t = input()
	cnt = 0
	dist1 = []
	dist2 = []
	for j in range(0, n):
		if s[j] != t[j]:
			dist1.append(s[j])
			dist2.append(t[j])
			cnt += 1
	if cnt != 2:
		print('No')
	elif dist1[0] == dist1[1] and dist2[0] == dist2[1]:
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	v = 0
	g = []
	for i in range(n):
		if s[i] != t[i]:
			v += 1
			g.append([s[i], t[i]])
	if v == 0:
		print('Yes')
	elif v == 1 or v > 2:
		print('No')
	elif g[0][0] == g[1][0] and g[0][1] == g[1][1]:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	x = int(input())
	a = list(input())
	b = list(input())
	(su, c) = (0, 0)
	x1 = []
	for i in range(x):
		if su <= 2:
			if a[i] != b[i]:
				su += 1
				x1.append([a[i], b[i]])
		else:
			c = 1
			break
	if c == 1:
		print('NO')
	elif len(x1) == 2:
		if x1[1] == x1[0]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


k = int(input())
for j in range(k):
	n = int(input())
	a = input()
	b = input()
	c = 0
	ar = []
	for i in range(n):
		if a[i] != b[i]:
			ar.append(i)
			c += 1
	if c == 2:
		if a[ar[0]] == a[ar[1]] and b[ar[0]] == b[ar[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import sys
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for i in range(int(ri())):
	n = int(ri())
	s = ri()
	t = ri()
	s = [i for i in s]
	t = [i for i in t]
	se = set()
	for i in s:
		if i in se:
			se.remove(i)
		else:
			se.add(i)
	for i in t:
		if i in se:
			se.remove(i)
		else:
			se.add(i)
	if len(se) > 0:
		No()
	else:
		ans = []
		for i in range(len(s)):
			if s[i] == t[i]:
				continue
			else:
				flag = -1
				for j in range(i + 1, len(s)):
					if t[j] == s[i]:
						flag = j
						break
				if flag != -1:
					ans.append([i + 1, flag])
					ans.append([i + 1, i])
					(s[i + 1], t[flag]) = (t[flag], s[i + 1])
					(s[i + 1], t[i]) = (t[i], s[i + 1])
				else:
					for j in range(i + 1, len(s)):
						if s[j] == s[i]:
							flag = j
							break
					(s[flag], t[i]) = (t[i], s[flag])
					ans.append([flag, i])
		Yes()
		print(len(ans))
		for i in range(len(ans)):
			ans[i] = [j + 1 for j in ans[i]]
		for i in ans:
			print(*i)


from collections import defaultdict

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

def main():
	K = int(input())
	for i in range(K):
		N = int(input())
		s = input()
		t = input()
		if s == t:
			print('Yes')
		else:
			Ds = defaultdict(int)
			Dt = defaultdict(int)
			cnt = 0
			for j in range(N):
				if s[j] != t[j]:
					Ds[s[j]] += 1
					Dt[t[j]] += 1
					cnt += 1
			if cnt != 2:
				print('No')
			elif len(Ds) == 1 and len(Dt) == 1:
				print('Yes')
			else:
				print('No')
main()


testcases = int(input())
while testcases > 0:
	testcases = testcases - 1
	length = int(input())
	string1 = str(input())
	string2 = str(input())
	arr = []
	for i in range(length):
		if string2[i] != string1[i]:
			arr.append(i)
	if len(arr) != 2:
		print('NO')
	elif string1[arr[0]] == string1[arr[1]] and string2[arr[0]] == string2[arr[1]]:
		print('YES')
	else:
		print('NO')


k = int(input())
for i in range(k):
	l = int(input())
	s = input()
	t = input()
	dif = 0
	mass = []
	for i in range(l):
		if s[i] != t[i]:
			dif += 1
			mass.append(i)
	if dif == 0:
		print('Yes')
	if dif != 2:
		print('No')
	elif s[mass[1]] == s[mass[0]] and t[mass[1]] == t[mass[0]]:
		print('Yes')
	else:
		print('No')


def inp():
	return int(input())

def minput():
	return map(int, input().split())

def linput():
	return list(minput())
for _ in range(inp()):
	n = inp()
	s1 = input()
	s2 = input()
	d = 0
	ci = -1
	bre = False
	for i in range(n):
		if s1[i] != s2[i]:
			if ci != -1:
				if d > 1 or s1[ci] != s1[i] or s2[ci] != s2[i]:
					print('No')
					bre = True
					break
			d += 1
			ci = i
	if d == 2 and (not bre):
		print('Yes')
	elif not bre:
		print('No')


def main():
	answer = ''
	for query in range(int(input())):
		n = int(input())
		(s1, s2) = (input(), input())
		different = []
		for i in range(len(s1)):
			if s1[i] != s2[i]:
				different.append(i)
		if len(different) == 0:
			answer += 'Yes \n'
		elif len(different) == 2:
			pair1 = (s1[different[0]], s2[different[0]])
			pair2 = (s1[different[1]], s2[different[1]])
			if pair1[0] == pair2[0] and pair1[1] == pair2[1]:
				answer += 'Yes \n'
			else:
				answer += 'No \n'
		else:
			answer += 'No \n'
	print(answer)
main()


Q = int(input())
dg = 10 ** 5
for __ in [0] * Q:
	n = int(input())
	s = list(input())
	t = list(input())
	res = []
	judge = True
	for i in range(n):
		p = True
		if s[i] != t[i]:
			for j in range(i + 1, n):
				if s[i] == s[j]:
					res.append(j * dg + i)
					s[j] = t[i]
					p = False
					break
			if p:
				for j in range(i + 1, n):
					if s[i] == t[j]:
						res.append(j * dg + j)
						res.append(j * dg + i)
						t[j] = s[j]
						s[j] = t[i]
						p = False
						break
			if p:
				judge = False
				break
	if judge:
		print('YES')
		print(len(res))
		for e in res:
			print(e // dg + 1, e % dg + 1)
	else:
		print('NO')


k = int(input())
temp = []
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	temp = []
	difference = 0
	if n == 2 and s[0] == s[1] and (t[0] == t[1]):
		print('Yes')
		continue
	for j in range(n):
		if s[j] != t[j]:
			difference += 1
			temp.append(s[j])
			temp.append(t[j])
		if difference > 2:
			break
	if difference > 2:
		print('No')
		continue
	elif difference == 2 and n == 2 and (s[0] != s[1] or t[0] != t[1]):
		print('No')
		continue
	elif difference < 2:
		print('No')
	elif difference == 2 and temp[0] == temp[2] and (temp[1] == temp[3]):
		print('Yes')
	elif difference == 2 and (temp[0] != temp[2] or temp[1] != temp[3]):
		print('No')
	else:
		print('Yes')


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
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')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def getXor(n):
	xor = 1
	for i in range(2, n + 1):
		xor = xor ^ i
	return xor
for xyz in range(0, int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	l = []
	for i in range(0, n):
		if s1[i] != s2[i]:
			l.append([s1[i], s2[i]])
	if len(l) != 2 and len(l) != 0:
		print('No')
	elif len(l) == 0:
		print('Yes')
	elif l[0] == l[1]:
		print('Yes')
	else:
		print('No')


k = int(input())
for I in range(k):
	n = int(input())
	s0 = input()
	t0 = input()
	s = [s0[i] for i in range(n)]
	t = [t0[i] for i in range(n)]
	ans = 'Yes'
	ansArr = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		elif s[i] in s[i + 1:]:
			ind = s.index(s[i], i + 1, n)
			ansArr += [[ind + 1, i + 1]]
			(s[ind], t[i]) = (t[i], s[ind])
		elif s[i] in t[i + 1:]:
			ind = t.index(s[i], i + 1, n)
			ansArr += [[i + 1 + 1, ind + 1]]
			(s[i + 1], t[ind]) = (t[ind], s[i + 1])
			ansArr += [[i + 1 + 1, i + 1]]
			(s[i + 1], t[i]) = (t[i], s[i + 1])
		else:
			ans = 'No'
			break
	print(ans)
	if ans == 'Yes':
		print(len(ansArr))
		for item in ansArr:
			print(item[0], item[1])


def swap(a, b):
	n = len(a)
	(A, B) = ([], [])
	for i in range(n):
		if a[i] != b[i]:
			A.append(a[i])
			B.append(b[i])
	if len(A) == len(B) == 0:
		print('Yes')
		return
	if len(A) == len(B) == 2:
		if A[0] == A[1] and B[0] == B[1]:
			print('Yes')
			return
	print('No')
for _ in range(int(input())):
	_ = input()
	a = input()
	b = input()
	swap(a, b)


k = int(input())
answ = []
for j in range(k):
	n = int(input())
	wr = 0
	(index1, index2) = (-1, -1)
	str1 = input()
	str2 = input()
	for i in range(n):
		if str1[i] != str2[i]:
			wr += 1
			index1 = index2
			index2 = i
			if wr == 3:
				answ.append('No')
				break
	else:
		if (str1[index1] == str1[index2] and str2[index2] == str2[index1]) and (not (index1 == -1 or index2 == -1)):
			answ.append('Yes')
		else:
			answ.append('No')
for i in answ:
	print(i)


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	t = input()
	count = 0
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			if count == 1:
				s1 = s[i]
				t1 = t[i]
			elif count == 2:
				s2 = s[i]
				t2 = t[i]
	if count >= 3:
		print('No')
	elif count == 0:
		print('Yes')
	elif count == 1:
		print('No')
	elif count == 2:
		if s1 == s2 and t2 == t1:
			print('Yes')
		else:
			print('No')


import sys
import collections
import heapq
import math
input = sys.stdin.readline

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

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

def rint():
	return int(input().strip())

def rintas():
	return [int(i) for i in input().strip().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
k = rint()
for _ in range(k):
	n = rint()
	S = rstr()
	T = rstr()
	(cnt, f, s) = (0, -1, -1)
	for i in range(n):
		if S[i] != T[i]:
			if f == -1:
				f = i
			elif s == -1:
				s = i
			else:
				cnt += 1
				break
			cnt += 1
	if cnt < 2 or cnt > 2:
		print('No')
	elif S[f] == S[s] and T[f] == T[s]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	diff = []
	for (a, b) in zip(s, t):
		if a != b:
			diff.append((a, b))
	if len(diff) != 2:
		print('No')
	elif diff[0] != diff[1]:
		print('No')
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	li = []
	c = 0
	z = 0
	for i in range(n):
		if s[i] != t[i]:
			li.append(i)
			c += 1
	if c == 2:
		if s[li[0]] == s[li[1]] and t[li[0]] == t[li[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for u in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	a = dict()
	k = 0
	b = []
	for i in range(n):
		if s1[i] != s2[i]:
			k += 1
			b.append(i)
	if k > 2:
		print('NO')
	elif k == 1:
		print('NO')
	elif k == 0:
		print('YES')
	elif s1[b[0]] == s1[b[1]] and s2[b[0]] == s2[b[1]]:
		print('YES')
	else:
		print('NO')


def helper(s, t):
	n = len(s)
	arr = []
	for i in range(n):
		if s[i] != t[i]:
			arr.append([s[i], t[i]])
	if len(arr) != 2:
		return False
	elif len(arr) == 2:
		(a, b) = (arr[0][0], arr[0][1])
		(c, d) = (arr[1][0], arr[1][1])
		if a == c and b == d:
			return True
		return False
n = int(input())
for _ in range(n):
	n1 = int(input())
	s = input()
	t = input()
	res = helper(s, t)
	if res:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	a = int(input())
	(d, f, c) = (input(), input(), [])
	for i in range(a):
		if d[i] != f[i]:
			c.append(d[i])
			c.append(f[i])
	if not len(c) or (len(c) == 4 and c[0] == c[2] and (c[1] == c[3])):
		print('Yes')
	else:
		print('No')


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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		n = N()
		s = list(input())
		t = list(input())
		ct = Counter(s + t)
		for i in ct:
			if ct[i] % 2 == 1:
				print('No')
				break
		else:
			print('Yes')
			res = []
			for i in range(n):
				if s[i] == t[i]:
					continue
				for j in range(i + 1, n):
					if s[j] == s[i]:
						res.append([j + 1, i + 1])
						(s[j], t[i]) = (t[i], s[j])
						break
					if t[j] == s[i]:
						res.append([j + 1, j + 1])
						res.append([j + 1, i + 1])
						(s[j], t[j]) = (t[j], s[j])
						(s[j], t[i]) = (t[i], s[j])
						break
			print(len(res))
			for i in res:
				print(*i)
main()


n_tests = int(input())
for _ in range(n_tests):
	length = int(input())
	a = input()
	b = input()
	difference = None
	difference_2 = None
	done = False
	swapped = False
	for i in range(length):
		if a[i] != b[i]:
			if difference is None:
				difference = a[i]
				difference_2 = b[i]
			elif swapped is False:
				if difference_2 == b[i] and difference == a[i]:
					swapped = True
				else:
					break
			else:
				swapped = False
				break
	if not swapped:
		print('No')
	else:
		print('Yes')


a = int(input())
l = []
for fgf in range(a):
	n = int(input())
	s1 = input()
	t1 = input()
	s = []
	t = []
	for i in s1:
		s.append(i)
	for i in t1:
		t.append(i)
	count = 0
	index = 0
	for i in range(n):
		if s[i] != t[i]:
			count = count + 1
			if count == 1:
				index = i
			if count == 2:
				(s[index], t[i]) = (t[i], s[index])
				if s == t:
					l.append('Yes')
					break
				l.append('No')
				break
	if count == 1:
		l.append('No')
for i in l:
	print(i)


def sol():
	t = int(input().strip())
	for i in range(t):
		sz = int(input().strip())
		str1 = [ord(x.strip()) for x in input().strip()]
		str2 = [ord(x.strip()) for x in input().strip()]
		if str1 == str2:
			print('Yes')
		else:
			dif = -1
			swap = False
			for j in range(sz):
				if str1[j] != str2[j]:
					if dif == -1:
						dif = j
					else:
						swap = True
						t = str2[j]
						str2[j] = str1[dif]
						str1[dif] = t
						if str1 == str2:
							print('Yes')
						else:
							print('No')
						break
			if not swap:
				print('No')
sol()


from collections import defaultdict
k = int(input())
for i in range(k):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	ans = []

	def swp(i, j):
		ans.append((i + 1, j + 1))
		(s1[i], s2[j]) = (s2[j], s1[i])
	c = defaultdict(int)
	for i in s1:
		c[i] += 1
	for i in s2:
		c[i] += 1
	for (k, v) in c.items():
		if v % 2 == 1:
			print('No')
			break
	else:
		print('Yes')
		for i in range(n):
			for j in range(i + 1, n):
				if s1[i] == s1[j]:
					swp(j, i)
					break
			else:
				for j in range(i + 1, n):
					if s1[i] == s2[j]:
						swp(i + 1, j)
						swp(i + 1, i)
						break
		if ans == []:
			ans.append([1, 1])
		assert s1 == s2
		assert len(ans) <= 2 * n
		print(len(ans))
		for i in ans:
			print(*i)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	s1 = list(input())
	sq = s + s1
	d = {}
	a = True
	for t in sq:
		if t not in d:
			d[t] = 0
		d[t] += 1
	for q in d:
		if d[q] % 2 == 1:
			print('No')
			a = False
			break
	if a:
		swaps = []
		for i in range(n):
			if s[i] == s1[i]:
				continue
			for j in range(i + 1, n):
				if s[i] == s[j]:
					swaps.append((j + 1, i + 1))
					(s1[i], s[j]) = (s[j], s1[i])
					break
				elif s[i] == s1[j]:
					swaps.append((j + 1, j + 1))
					(s[j], s1[j]) = (s1[j], s[j])
					swaps.append((j + 1, i + 1))
					(s1[i], s[j]) = (s[j], s1[i])
					break
		print('Yes')
		print(len(swaps))
		for x in swaps:
			print(*x)


import math, collections, sys

def case():
	n = int(input())
	s = input()
	t = input()
	mismatch = []
	for i in range(n):
		if s[i] != t[i]:
			mismatch.append(i)
	if len(mismatch) == 2:
		if s[mismatch[0]] == s[mismatch[1]] and t[mismatch[0]] == t[mismatch[1]]:
			print('YES')
			return
	print('NO')
for _ in range(int(input())):
	case()


from sys import stdin, stdout
import heapq
import bisect
import math
import operator

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(input())
		s = input()
		t = input()
		lis1 = []
		lis2 = []
		counter = 0
		for i in range(n):
			if s[i] != t[i]:
				lis1.append(s[i])
				lis2.append(t[i])
		if len(lis1) > 2:
			print('NO')
		elif len(lis1) == 1:
			print('NO')
		elif lis1[0] == lis1[1] and lis2[0] == lis2[1]:
			print('YES')
		else:
			print('NO')
main()


q = int(input())
for _ in ' ' * q:
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	l = []
	for i in range(n):
		if t[i] != s[i]:
			l += [i]
	if len(l) == 2:
		(s[l[0]], t[l[1]]) = (t[l[1]], s[l[0]])
		if s == t:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def valid(cnt):
	for i in cnt:
		if cnt[i] % 2 == 1:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	cnt = {}
	for i in s:
		if i not in cnt:
			cnt[i] = 1
		else:
			cnt[i] += 1
	for i in t:
		if i not in cnt:
			cnt[i] = 1
		else:
			cnt[i] += 1
	if not valid(cnt):
		print('No')
		continue
	res = []
	print('Yes')
	for i in range(n):
		if s[i] == t[i]:
			continue
		for j in range(i + 1, n):
			if s[j] == s[i]:
				(s[j], t[i]) = (t[i], s[j])
				res.append([j + 1, i + 1])
				break
			elif t[j] == s[i]:
				(s[i + 1], t[j]) = (t[j], s[i + 1])
				(s[i + 1], t[i]) = (t[i], s[i + 1])
				res.append([i + 2, j + 1])
				res.append([i + 2, i + 1])
				break
	print(len(res))
	for i in res:
		print(*i)


import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
orda = ord('a')
k = int(input())
for i in range(k):
	n = int(input())
	s = input().rstrip()
	t = input().rstrip()
	if s == t:
		print('Yes')
		continue
	diffa = []
	diffb = []
	for (a, b) in zip(s, t):
		if a != b:
			diffa.append(a)
			diffb.append(b)
	if len(diffa) != 2:
		print('No')
		continue
	if diffa[0] == diffa[1] and diffb[0] == diffb[1]:
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	lis = []
	for j in range(n):
		if s[j] != t[j]:
			lis.append((s[j], t[j]))
	if len(lis) == 2:
		a = lis[0]
		b = lis[1]
		if a[0] == b[0] and a[1] == b[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for ti in range(t):
	n = int(input())
	lia = []
	lib = []
	a = list(input())
	b = list(input())
	ctr = 0
	for i in range(n):
		if a[i] != b[i]:
			lia.append(a[i])
			lib.append(b[i])
			ctr += 1
		if ctr > 2:
			print('No')
			break
	if ctr == 2:
		if lia[0] == lia[1] and lib[0] == lib[1]:
			print('Yes')
		else:
			print('No')
	elif ctr == 1:
		print('No')


t = int(input())
while t > 0:
	maxVal = 0
	n = int(input())
	st1 = list(input())
	st2 = list(input())
	out = []
	for i in range(n):
		if st1[i] == st2[i]:
			continue
		else:
			for j in range(i + 1, n):
				if st2[i] == st2[j]:
					temp = st1[i]
					st1[i] = st2[j]
					st2[j] = temp
					out.append([i + 1, j + 1])
					break
				elif st2[i] == st1[j]:
					temp = st1[j]
					st1[j] = st2[j]
					st2[j] = temp
					out.append([j + 1, j + 1])
					temp = st1[i]
					st1[i] = st2[j]
					st2[j] = temp
					out.append([i + 1, j + 1])
					break
	if st1 == st2:
		print('YES')
		print(len(out))
		for arr in out:
			print(arr[0], arr[1])
	else:
		print('NO')
	t -= 1


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]
(k,) = rl()
for _ in range(k):
	(n,) = rl()
	s = stdin.readline()
	t = stdin.readline()
	ijk = [i for i in range(n) if s[i] != t[i]]
	if len(ijk) != 2:
		print('No')
		continue
	(i, j) = ijk
	print('Yes' if s[i] == s[j] and t[i] == t[j] else 'No')


for tc in [0] * int(input()):
	n = int(input())
	a = input()
	b = input()
	c = 0
	d = []
	f = 1
	if a == b:
		print('YES')
		continue
	if n == 2:
		if a == b:
			print('YES')
		elif len(set(a)) == len(set(b)) and a != b[::-1] and (len(set(a + b)) <= 2):
			print('YES')
		else:
			print('NO')
	else:
		if a == b[::-1]:
			print('No')
			continue
		for i in range(n):
			if a[i] != b[i]:
				c += 1
				d.append(a[i])
				d.append(b[i])
				if c > 2:
					print('NO')
					f = 0
					break
		if f:
			if len(set(d)) == 2 and c == 2:
				if d[0] == d[-1]:
					print('NO')
				else:
					print('YES')
			else:
				print('NO')


k = int(input())
kolvo = 0
q = 1
j = 0
for j in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	for f in range(n):
		if s[f] != t[f]:
			kolvo += 1
			if kolvo == 1:
				s1 = s[f]
				t1 = t[f]
			if kolvo == 2:
				s2 = s[f]
				t2 = t[f]
	if kolvo == 2:
		if s1 == s2 and t1 == t2:
			print('YES')
			del s2, t2
		else:
			print('NO')
	else:
		print('NO')
	del s, s1, t, t1
	kolvo = 0


import math
from decimal import Decimal
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(a, b):
	c = []
	ans = 0
	f = int(math.sqrt(a))
	for i in range(1, f + 1):
		if a % i == 0:
			c.append(i)
	l = len(c)
	for i in range(l):
		c.append(a // c[i])
	for i in range(len(c)):
		if c[i] <= b:
			ans += 1
	if a / f == f and b >= f:
		return ans - 1
	return ans
q = int(input())
for _ in range(q):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	if s1 == s2:
		print('YES')
		print(1)
		print(1, 1)
		continue
	d = {}
	d1 = {}
	d2 = {}
	for j in s1:
		d[j] = d.get(j, 0) + 1
		d1[j] = d1.get(j, 0) + 1
		if j not in s2:
			d2[j] = 0
	for j in s2:
		d[j] = d.get(j, 0) + 1
		d2[j] = d2.get(j, 0) + 1
		if j not in s1:
			d1[j] = 0
	f = True
	for j in d:
		if d[j] % 2 != 0:
			print('No')
			f = False
			break
	if not f:
		continue
	print('YES')
	ans = []
	for i in range(n):
		if s1[i] != s2[i]:
			k = s1[i]
			if d2[k] != 0:
				for j in range(i + 1, n):
					if s2[j] == s1[i]:
						ans.append((n, j + 1))
						ans.append((n, i + 1))
						d1[k] -= 1
						d2[s2[j]] -= 1
						d2[s2[i]] -= 1
						d2[s1[n - 1]] += 1
						d1[s2[i]] += 1
						(s1[n - 1], s2[j]) = (s2[j], s1[n - 1])
						(s1[n - 1], s2[i]) = (s2[i], s1[n - 1])
						break
			else:
				for j in range(i + 1, n):
					if s1[j] == s1[i]:
						ans.append((j + 1, i + 1))
						d1[k] -= 1
						d1[s2[i]] += 1
						d2[s2[i]] -= 1
						(s1[j], s2[i]) = (s2[i], s1[j])
						break
		else:
			d1[s1[i]] -= 1
			d2[s1[i]] -= 1
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
while n:
	n -= 1
	t = int(input())
	l = input()
	s = input()
	o = []
	p = []
	e = 0
	for i in range(t):
		if l[i] != s[i]:
			o.append(l[i])
			p.append(s[i])
			e += 1
		if e > 2:
			break
	o = list(set(o))
	p = list(set(p))
	if (e == 2 or e == 0) and len(o) == 1 and (len(p) == 1):
		print('Yes')
	else:
		print('No')


t = int(input())

def aze(i):
	while i < n and s[i] == t[i]:
		i += 1
	return i
for _ in range(t):
	n = int(input())
	s = str(input())
	t = str(input())
	i = aze(0)
	if i == n:
		print('YES')
		continue
	j = aze(i + 1)
	if j == n:
		print('NO')
		continue
	k = aze(j + 1)
	if k < n:
		print('NO')
		continue
	if s[i] == s[j] and t[i] == t[j]:
		print('YES')
		continue
	print('NO')


def solve(n, s, t):
	x = s + t
	for v in set(s) | set(t):
		if x.count(v) % 2 != 0:
			return ['No']
	r = ['Yes']
	sList = list(s)
	tList = list(t)
	i = 0
	while i < n:
		if sList[i] != tList[i]:
			if sList[i] in ''.join(sList[i + 1:]):
				j = i + 1 + ''.join(sList[i + 1:]).find(sList[i])
				(sList[j], tList[i]) = (tList[i], sList[j])
				r.append(' '.join(map(str, [j + 1, i + 1])))
			else:
				j = i + 1 + ''.join(tList[i + 1:]).find(sList[i])
				(sList[j], tList[j]) = (tList[j], sList[j])
				r.append(' '.join(map(str, [j + 1, j + 1])))
				(sList[j], tList[i]) = (tList[i], sList[j])
				r.append(' '.join(map(str, [j + 1, i + 1])))
		i += 1
	r.insert(1, len(r) - 1)
	return r
r = []
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	r.extend(solve(n, s, t))
print(*r, sep='\n')


from collections import Counter
for i in range(int(input())):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	C = Counter(s1 + s2)
	f = False
	for i in C:
		if C[i] % 2 == 1:
			f = True
			break
	if f:
		print('No')
		continue
	ans = []
	for i in range(n):
		if s1[i] == s2[i]:
			continue
		for j in range(i + 1, n):
			if s1[i] == s1[j]:
				(s2[i], s1[j]) = (s1[j], s2[i])
				ans.append((j + 1, i + 1))
				break
			if s1[i] == s2[j]:
				ans.append((j + 1, j + 1))
				(s1[j], s2[j]) = (s2[j], s1[j])
				ans.append((j + 1, i + 1))
				(s2[i], s1[j]) = (s1[j], s2[i])
				break
	print('Yes')
	print(len(ans))
	for i in ans:
		print(*i)


for i in range(int(input())):
	N = int(input())
	(First, Second, DifCount, Dif) = (input(), input(), 0, [])
	for j in range(N):
		if First[j] != Second[j]:
			DifCount += 1
			Dif.append(First[j])
			Dif.append(Second[j])
	print('YES' if DifCount == 0 or (DifCount == 2 and Dif[0] == Dif[2] and (Dif[1] == Dif[3])) else 'NO')


queries = int(input())
for x in range(queries):
	length = int(input())
	s = input()
	t = input()
	similarity = 0
	diff = length
	diffs = []
	for x in range(length):
		if s[x] == t[x]:
			similarity += 1
			diff -= 1
		else:
			diffs.append((s[x], t[x]))
	if diff > 2:
		print('No')
		continue
	elif diff == 1:
		print('No')
		continue
	elif diff == 0:
		print('Yes')
		continue
	elif diffs[0] == diffs[1]:
		print('Yes')
		continue
	else:
		print('No')
		continue


import sys, math
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	a = list(sys.stdin.readline().rstrip())
	b = list(sys.stdin.readline().rstrip())
	up = []
	lo = []
	can = False
	for i in range(n):
		if a[i] != b[i]:
			up.append(a[i])
			lo.append(b[i])
	if len(up) == 2 and len(lo) == 2:
		if up[0] == up[1] and lo[0] == lo[1]:
			can = True
	print('YES' if can else 'NO')


t = int(input())
for p in range(t):
	n = int(input())
	a = input()
	b = input()
	dic = {}
	for i in range(n):
		if a[i] in dic:
			dic[a[i]] += 1
		else:
			dic[a[i]] = 1
		if b[i] in dic:
			dic[b[i]] += 1
		else:
			dic[b[i]] = 1
	flag = 0
	for d in dic:
		if dic[d] % 2 != 0:
			flag = 1
	if flag == 1:
		print('No')
	else:
		print('Yes')
		ans = []
		for i in range(n):
			if a[i] != b[i]:
				x = a.find(a[i], i + 1)
				if x != -1:
					ans.append([x + 1, i + 1])
					a = a[:x] + b[i] + a[x + 1:]
					b = b[:i] + a[i] + b[i + 1:]
				else:
					s = b.find(a[i], i + 1)
					ans.append([s + 1, s + 1])
					ans.append([s + 1, i + 1])
					rd = a[s]
					a = a[:s] + b[i] + a[s + 1:]
					b = b[:i] + b[s] + b[i + 1:s] + rd + b[s + 1:]
		print(len(ans))
		for d in ans:
			print(*d)


import math
for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	x = []
	y = []
	for i in range(n):
		if a[i] != b[i]:
			x.append(a[i])
			y.append(b[i])
		if len(x) == 3:
			break
	if len(x) == 1 or len(x) == 3:
		print('No')
	elif len(x) == 0:
		print('Yes')
	else:
		(x[0], y[1]) = (y[1], x[0])
		if x == y:
			print('Yes')
		else:
			print('No')


from collections import Counter
k = int(input())
for task_index in range(k):
	n = int(input())
	(s, t) = (input(), input())
	(new_s, new_t) = ('', '')
	for letter_index in range(n):
		if s[letter_index] != t[letter_index]:
			(new_s, new_t) = (new_s + s[letter_index], new_t + t[letter_index])
	if len(new_s) != 2 or len(new_s) != len(new_t):
		print('No')
	elif new_s[0] + new_t[0] == new_s[1] + new_t[1]:
		print('Yes')
	else:
		print('No')


for i in ' ' * int(input()):
	n = int(input())
	s = input()
	t = input()
	counter = 0
	L = []
	for j in range(n):
		if s[j] != t[j]:
			counter += 1
			L.append(j)
	if counter != 0 and counter != 2:
		print('No')
		continue
	else:
		if counter == 0:
			print('Yes')
		else:
			(a, b) = L
			if s[a] == s[b] and t[a] == t[b]:
				print('Yes')
			else:
				print('No')
		continue


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	(lst1, lst2, count) = (list(), list(), 0)
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			lst1.append(s[i])
			lst2.append(t[i])
	if count != 2:
		print('No')
	elif lst1[0] == lst1[1] and lst2[0] == lst2[1]:
		print('Yes')
	else:
		print('No')


import sys

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

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

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

def swap(s, t, i, j):
	p.append((i + 1, j + 1))
	(s[i], t[j]) = (t[j], s[i])

def find(s, v, i):
	for j in range(i, len(s)):
		if s[j] == v:
			return j
	return -1

def solve():
	global p
	n = mint()
	s = list(minp())
	t = list(minp())
	c = [0] * 26
	for i in s:
		c[ord(i) - ord('a')] += 1
	for i in t:
		c[ord(i) - ord('a')] += 1
	same = True
	for i in range(26):
		if c[i] % 2 != 0:
			print('No')
			return
	p = []
	for z in range(100):
		for i in range(n):
			if s[i] != t[i]:
				if find(s, s[i], i + 1) != -1:
					swap(s, t, find(s, s[i], i + 1), i)
				elif find(t, t[i], i + 1) != -1:
					swap(s, t, i, find(t, t[i], i + 1))
				else:
					swap(s, t, i, i)
					if find(s, s[i], i + 1) != -1:
						swap(s, t, find(s, s[i], i + 1), i)
					elif find(t, t[i], i + 1) != -1:
						swap(s, t, i, find(t, t[i], i + 1))
	if len(p) <= 2 * n:
		print('Yes')
		print(len(p))
		for i in p:
			print(*i)
		return
	print('No')
for i in range(mint()):
	solve()


I = input
pr = print
s1 = s2 = ''
l = 0

def solve():
	c = ''
	for i in range(l):
		if s1[i] != s2[i] and len(c) < 4:
			if len(c) and (s1[i] != c[0] or s2[i] != c[1]):
				print('No')
				return
			else:
				c += s1[i] + s2[i]
		elif s1[i] != s2[i] and len(c) == 4:
			pr('No')
			return
	pr('YNeos'[len(c) != 4::2])
for _ in range(int(I())):
	l = int(I())
	s1 = I()
	s2 = I()
	solve()


for _ in range(int(input())):
	n = int(input())
	string1 = input()
	string2 = input()
	ar = [i for i in range(len(string1)) if string1[i] != string2[i]]
	if len(ar) == 0 or (len(ar) == 2 and string1[ar[0]] == string1[ar[1]] and (string2[ar[0]] == string2[ar[1]])):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	t_ind = [index for (index, char) in enumerate(t) if char != s[index]]
	s_ind = [index for (index, char) in enumerate(s) if char != t[index]]
	if len(s_ind) != 2 or len(t_ind) != 2:
		print('NO')
		continue
	(s[s_ind[0]], t[t_ind[1]]) = (t[t_ind[1]], s[s_ind[0]])
	str1 = ''.join(s)
	str2 = ''.join(t)
	if str1 == str2:
		print('YES')
	else:
		print('NO')


import sys, math, queue, collections
MOD = 10 ** 9 + 7

def equalize(i):
	if s[i] == t[i]:
		return True
	for j in range(i + 1, n):
		if s[j] == s[i]:
			ans.append((j + 1, i + 1))
			tc = s[j]
			s[j] = t[i]
			t[i] = tc
			return True
	for j in range(i + 1, n):
		if t[j] == s[i]:
			ans.append((n, j + 1))
			tc = s[-1]
			s[-1] = t[j]
			t[j] = tc
			ans.append((n, i + 1))
			tc = s[-1]
			s[-1] = t[i]
			t[i] = tc
			return True
	return False
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	stat = True
	ans = []
	for i in range(n):
		stat = stat and equalize(i)
	if stat:
		print('Yes')
		print(len(ans))
		for ai in ans:
			print(*ai)
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	simi = 0
	iff = 0
	l = []
	for i in range(n):
		if s[i] == t[i]:
			simi += 1
		else:
			iff += 1
			l.append(i)
	if iff == 0:
		print('Yes')
	elif iff == 2:
		if s[l[0]] == s[l[1]]:
			if t[l[1]] == t[l[0]]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for z in range(t):
	n = int(input())
	dict1 = {}
	dict2 = {}
	a = input()
	b = input()
	r = []
	for i in range(n):
		if a[i] != b[i]:
			r.append([a[i], b[i]])
	if len(r) != 2:
		print('No')
	elif r[0] == r[1]:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	fl = 0
	ind = 0
	for i in range(n):
		if s[i] != t[i]:
			fl += 1
			ind = i
			break
	for i in range(ind + 1, n):
		if s[i] != t[i]:
			fl += 1
			ind1 = i
	if fl == 2 and s[ind] == s[ind1] and (t[ind1] == t[ind]):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	(a, s, t) = (int(input()), input(), input())
	if len([False for n in [(s + t).count(i) for i in set(s + t)] if n % 2]):
		print('No')
	else:
		print('Yes')
		s = [' '] + [i for i in s]
		t = [' '] + [i for i in t]
		c = []
		while len(s):
			(r, d) = (s.pop(), t.pop())
			if r != d:
				try:
					n = t.index(d)
					c.append(str(len(s)) + ' ' + str(n))
					t[n] = r
				except:
					c.append(str(len(s)) + ' ' + str(len(s)))
					n = s.index(d)
					c.append(str(n) + ' ' + str(len(s)))
					s[n] = r
		print(len(c))
		for i in c:
			print(i)


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	neqc = []
	for i in range(n):
		if s1[i] != s2[i]:
			neqc.append(i)
	if len(neqc) != 0 and len(neqc) != 2:
		print('NO')
		continue
	if len(neqc) == 0:
		print('YES')
	elif s1[neqc[0]] == s1[neqc[1]] and s2[neqc[1]] == s2[neqc[0]]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	s1 = input()
	c = 0
	set1 = set()
	set2 = set()
	for i in range(n):
		if s[i] != s1[i]:
			c = c + 1
			set1.add(s[i])
			set2.add(s1[i])
	if c == 0:
		print('Yes')
		continue
	if c == 2:
		if len(set1) <= 1 and len(set2) <= 1:
			print('Yes')
			continue
	print('No')


I = input
for _ in range(int(I())):
	(n, s, t) = (int(I()), I(), I())
	diffs = [i for i in range(n) if s[i] != t[i]]
	if not diffs:
		print('Yes')
	elif len(diffs) == 2:
		(i, j) = diffs
		print('Yes' if s[i] == s[j] and t[i] == t[j] else 'No')
	else:
		print('No')


for _ in range(int(input())):
	input()
	a = [x + y for (x, y) in zip(input(), input()) if x != y]
	print('YNeos'[0 != len(a) != 2 or len(set(a)) > 1::2])


k = int(input())
for i in range(0, k):
	n = int(input())
	s1 = input()
	s2 = input()
	l = []
	for i in range(0, n):
		if s1[i] != s2[i]:
			l.append(i)
	if len(l) == 2 and s1[l[0]] == s1[l[1]] and (s2[l[1]] == s2[l[0]]):
		print('Yes')
	else:
		print('No')


k = int(input())
for I in range(k):
	n = int(input())
	s = input()
	t = input()
	diff = []
	count = 0
	ans = 'Yes'
	for j in range(n):
		if s[j] != t[j]:
			diff += [j]
			if len(diff) > 2:
				break
	if len(diff) > 2 or len(diff) == 1:
		ans = 'No'
	elif len(diff) == 2:
		if s[diff[0]] != s[diff[1]] or t[diff[0]] != t[diff[1]]:
			ans = 'No'
	print(ans)


def solve(s, t):
	count = 0
	a = []
	b = []
	for i in range(len(s)):
		if s[i] != t[i]:
			count += 1
			a.append(s[i])
			b.append(t[i])
	if count == 0:
		return 'Yes'
	if count != 2:
		return 'No'
	if a[0] == a[1] and b[0] == b[1]:
		return 'Yes'
	return 'No'
k = int(input())
for t in range(k):
	n = int(input())
	s = input()
	t = input()
	print(solve(s, t))


from collections import Counter
k = int(input())
for _ in range(k):
	n = int(input())
	a = input()
	b = input()
	diffs = []
	num = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			diffs.append([a[i], b[i]])
	if len(diffs) == 2 and diffs[0] == diffs[1]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	cnt = 0
	I = 0
	J = 0
	for i in range(n):
		if s1[i] != s2[i]:
			cnt += 1
			if cnt == 1:
				I = i
			if cnt == 2:
				J = i
		if cnt > 2:
			break
	if cnt != 2:
		print('No')
	elif s1[I] == s1[J] and s2[I] == s2[J]:
		print('Yes')
	else:
		print('No')


a = int(input())
l5 = []
while a > 0:
	c = int(input())
	l = [i for i in input().lower()[:c]]
	l1 = [j for j in input().lower()[:c]]
	(l3, l4) = ([], [])
	for i in range(c):
		if l[i] != l1[i]:
			l3.append(l[i])
			l4.append(l1[i])
		else:
			pass
	if len(l3) == 2 and l3[0] == l3[1] and (l4[1] == l4[0]):
		l5.append('Yes')
	else:
		l5.append('No')
	a -= 1
for i in l5:
	print(i)


def listdiff(li1, li2):
	counter = 0
	diff1 = set()
	diff2 = set()
	for i in range(len(li1)):
		if li1[i] == li2[i]:
			None
		else:
			diff1.add(li1[i])
			diff2.add(li2[i])
			counter += 1
	w = [counter, diff1, diff2]
	return w
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	t = input()
	if listdiff(s, t)[0] == 2 and len(listdiff(s, t)[1]) == len(listdiff(s, t)[2]) == 1:
		print('Yes')
	else:
		print('No')


k = int(input())
ans = []
for i in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	index = []
	for i in range(n):
		if s[i] != t[i]:
			index.append(i)
	if len(index) == 2:
		temp = s[index[0]]
		s[index[0]] = t[index[1]]
		t[index[1]] = temp
		s = ''.join(s)
		t = ''.join(t)
		if s == t:
			ans.append('YES')
		else:
			ans.append('NO')
	else:
		ans.append('NO')
print('\n'.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	c = 0
	flag = True
	for j in range(n):
		if a[j] != b[j]:
			c = c + 1
		if c == 1 and b[j] != a[j]:
			d = a[j]
			e = b[j]
		elif c == 2 and a[j] != b[j]:
			if d != a[j] or e != b[j]:
				flag = False
				break
		elif c > 2:
			flag = False
			break
	if flag == True and c == 0:
		print('YES')
	elif flag == True and c == 2:
		print('YES')
	else:
		print('NO')


x = int(input())
for __ in range(x):
	n = int(input())
	a = input()
	b = input()
	c = 0
	l = []
	for i in range(n):
		if a[i] != b[i]:
			c += 1
			l.append(i)
	if c == 2:
		if b[l[0]] == b[l[1]] and a[l[0]] == a[l[1]]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	m = input()
	b = False
	k = []
	for i in range(n):
		if s[i] != m[i]:
			k.append([s[i], m[i]])
	if len(k) != 2:
		print('NO')
	elif k[0] == k[1]:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	diff1 = ''
	diff2 = ''
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			diff1 += s1[i]
			diff2 += s2[i]
	if len(diff1) == 2:
		if diff1[0] + diff2[0] == diff1[1] + diff2[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


def solve():
	n = int(input())
	s = input()
	t = input()
	dif1 = []
	dif2 = []
	np = False
	for i in range(n):
		if s[i] == t[i]:
			continue
		dif1.append(i)
		if len(dif1) > 2:
			np = True
			break
	if np:
		print('No')
	elif len(dif1) == 2:
		i = dif1[0]
		j = dif1[1]
		if s[i] == s[j] and t[i] == t[j]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
t = int(input())
for _ in range(t):
	solve()


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	c = 0
	a = []
	b = []
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			a.append(s[i])
			b.append(t[i])
	if c == 2:
		if a[0] == a[1] and b[0] == b[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	x = []
	for i in range(n):
		if s[i] != t[i]:
			x.append(i)
	if len(x) != 2:
		print('No')
	elif s[x[0]] == s[x[1]] and t[x[0]] == t[x[1]]:
		print('Yes')
	else:
		print('No')


cases = int(input())
for _ in range(cases):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	swaps = 0
	order = []
	i = 0
	while i < n and swaps < 2 * n:
		if s1[i] == s2[i]:
			i += 1
		elif i == n - 1:
			swaps = 2 * n + 1
		else:
			for j in range(i + 1, n):
				if s1[i] == s1[j]:
					(s2[i], s1[j]) = (s1[j], s2[i])
					swaps += 1
					order.append((j, i))
					break
				elif s2[i] == s2[j]:
					(s1[i], s2[j]) = (s2[j], s1[i])
					swaps += 1
					order.append((i, j))
					break
				elif j == n - 1:
					(s1[i], s2[i]) = (s2[i], s1[i])
					swaps += 1
					order.append((i, i))
	if swaps >= 2 * n:
		print('No')
	else:
		print('Yes')
		print(swaps)
		for (a, b) in order:
			print(a + 1, b + 1)


n = int(input())
for i in range(n):
	cnt = 0
	size = int(input())
	s = input()
	d = input()
	swap = []
	for i in range(size):
		if s[i] != d[i]:
			cnt += 1
			swap.append(i)
	if cnt != 2:
		print('No')
		continue
	if s[:swap[0]] + d[swap[1]] + s[swap[0] + 1:] == d[:swap[1]] + s[swap[0]] + d[swap[1] + 1:]:
		print('Yes')
	else:
		print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	ans = False
	if s == t:
		print('Yes')
	else:
		for i in range(n):
			if s[i] != t[i]:
				for j in range(i + 1, n):
					if s[j] == t[j]:
						continue
					if s[j] != t[j] and s[i] == s[j] and (t[i] == t[j]):
						s1 = ''
						t1 = ''
						for k in range(n):
							if k == i:
								s1 += t[j]
								t1 += t[i]
							elif k == j:
								t1 += s[i]
								s1 += s[j]
							else:
								s1 += s[k]
								t1 += t[k]
						if s1 == t1:
							ans = True
							break
					else:
						break
		if ans:
			print('Yes')
		else:
			print('No')


import sys
input = sys.stdin.readline
for q in range(int(input())):
	N = int(input())
	s = list(input().rstrip())
	t = list(input().rstrip())
	ans = []
	for i in range(N - 1):
		if s[i] != t[i]:
			for j in range(i + 1, N):
				if s[j] == s[i]:
					ans.append((j + 1, i + 1))
					(s[j], t[i]) = (t[i], s[j])
					break
				if t[j] == s[i]:
					ans.append((i + 2, j + 1))
					(s[i + 1], t[j]) = (t[j], s[i + 1])
					ans.append((i + 2, i + 1))
					(s[i + 1], t[i]) = (t[i], s[i + 1])
					break
	flag = True
	for i in range(N):
		if s[i] != t[i]:
			flag = False
	if flag and ans:
		print('Yes')
		print(len(ans))
		for (u, v) in ans:
			print(u, v)
	elif flag and (not ans):
		print('Yes')
		print(1)
		print(1, 1)
	else:
		print('No')


k = int(input())
for q in range(k):
	n = int(input())
	sa = list(input())
	sb = list(input())
	occ = [0] * 26
	for c in sa:
		occ[ord(c) - ord('a')] += 1
	for c in sb:
		occ[ord(c) - ord('a')] += 1
	ok = True
	for o in occ:
		if o % 2 != 0:
			ok = False
	if ok:
		diff = []
		for i in range(len(sa)):
			if sa[i] != sb[i]:
				diff.append(i)
		swaps = []
		for (i, idx) in enumerate(diff):
			if sa[idx] == sb[idx]:
				continue
			if i == len(diff) - 1:
				ok = False
				break
			look = sa[idx]
			j = i + 1
			while j < len(diff):
				if sa[diff[j]] == look:
					break
				j += 1
			if j < len(diff):
				tmp = sa[diff[j]]
				sa[diff[j]] = sb[idx]
				sb[idx] = tmp
				swaps.append((diff[j], idx))
			else:
				j = i
				while j < len(diff):
					if sb[diff[j]] == look:
						break
					j += 1
				if j < len(diff) and j != i:
					tmp = sb[diff[j]]
					sb[diff[j]] = sa[diff[i + 1]]
					sa[diff[i + 1]] = tmp
					swaps.append((diff[i + 1], diff[j]))
					tmp = sa[diff[i + 1]]
					sa[diff[i + 1]] = sb[idx]
					sb[idx] = tmp
					swaps.append((diff[i + 1], idx))
				else:
					ok = False
					break
	if ok:
		print('Yes')
		print(len(swaps))
		for s in swaps:
			print('%d %d' % (s[0] + 1, s[1] + 1))
	else:
		print('No')


import sys
input = lambda : sys.stdin.readline().strip()
from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	t = input()
	if s == t:
		d = dict(Counter(s))
		for v in d.values:
			if v > 1:
				print('Yes')
		else:
			print('No')
	else:
		ls = [i for i in range(n) if s[i] != t[i]]
		cnt = len(ls)
		if cnt != 2:
			print('No')
		elif s[ls[0]] == s[ls[1]] and t[ls[0]] == t[ls[1]]:
			print('Yes')
		else:
			print('No')


import sys
from collections import Counter, defaultdict
input = sys.stdin.readline
k = int(input())
for _ in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	ctr = Counter(s) + Counter(t)
	possible = True
	for v in ctr.values():
		if v & 1:
			possible = False
			break
	if not possible:
		print('No')
		continue
	loc_s = defaultdict(list)
	loc_t = defaultdict(list)
	for (i, c) in enumerate(s):
		loc_s[c].append(i)
	for (i, c) in enumerate(t):
		loc_t[c].append(i)
	ans = []
	for j in range(n):
		c = s[j]
		if t[j] == c:
			continue
		for i in range(j + 1, n):
			if s[i] == c:
				(s[i], t[j]) = (t[j], s[i])
				ans.append((i, j))
				break
		else:
			for i in range(j + 1, n):
				if t[i] == c:
					(s[i], t[i]) = (t[i], s[i])
					ans.append((i, i))
					(s[i], t[j]) = (t[j], s[i])
					ans.append((i, j))
					break
	print('Yes')
	print(len(ans))
	for (i, j) in ans:
		print(i + 1, j + 1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	(z1, z2) = ([], [])
	cnt = 0
	for i in range(n):
		if a[i] != b[i]:
			z1.append(a[i])
			z2.append(b[i])
			cnt += 1
	if cnt != 2:
		print('No')
	elif z1[0] == z1[1] and z2[0] == z2[1]:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	s = str(input())
	t = str(input())
	ars = []
	art = []
	for i in range(n):
		if s[i] != t[i]:
			ars.append(s[i])
			art.append(t[i])
	if len(ars) == 2 and len(set(ars)) == 1 and (len(set(art)) == 1):
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	ans = True
	count = 2
	index = []
	if s == t:
		print('YES')
		break
	for i in range(n):
		if s[i] != t[i]:
			count -= 1
			if count < 0:
				ans = False
				break
			index.append(i)
	if ans == True:
		ans = False
		for i in range(len(index)):
			first = index[i]
			if ans:
				break
			for j in range(len(index)):
				second = index[j]
				if s[:first] + t[second] + s[first + 1:] == t[:second] + s[first] + t[second + 1:]:
					ans = True
					break
	print('Yes' if ans else 'No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	dif = []
	for i in range(len(s)):
		if s[i] != t[i]:
			dif.append(i)
	if len(dif) == 2:
		i1 = dif[0]
		i2 = dif[1]
		if s[i1] == s[i2] and t[i1] == t[i2]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for TT in range(1, int(input()) + 1):
	n = int(input())
	a = input()
	b = input()
	l = [[x, y] for (x, y) in zip(a, b) if x != y]
	res = len(l) == 0
	if len(l) == 2:
		res = l[0] == l[1]
	print('Yes' if res else 'No')


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input()
t = I()
for i in range(0, t):
	n = I()
	a = S()
	b = S()
	k = []
	for i in range(0, n):
		if a[i] != b[i]:
			k.append([a[i], b[i]])
	if len(k) != 2:
		print('NO')
	elif k[0][1] == k[1][1] and k[1][0] == k[0][0]:
		print('YES')
	else:
		print('NO')


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	s1 = list(s)
	s2 = list(t)
	cnt = 0
	y = []
	z = []
	for i in range(n):
		if s1[i] != s2[i]:
			cnt += 1
			y.append(s1[i])
			z.append(s2[i])
	if cnt == 0:
		print('YES')
	elif cnt == 2 and z[0] == z[1] and (y[0] == y[1]):
		print('YES')
	else:
		print('NO')


import sys

def I():
	return sys.stdin.readline().rstrip()
t = int(I())
for _ in range(t):
	n = int(I())
	s = [c for c in I()]
	t = [c for c in I()]
	ne = [0, 0]
	for i in range(n):
		if s[i] != t[i]:
			ne.append(i)
	(i, j) = (ne[-1], ne[-2])
	(s[i], t[j]) = (t[j], s[i])
	print('Yes' if ''.join(s) == ''.join(t) else 'No')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	same = False
	possible = True
	l = []
	for i in range(n):
		if s1[i] != s2[i]:
			l.append([s1[i], s2[i]])
		else:
			same = True
	if len(l) == 0 and same:
		print('Yes')
	elif len(l) == 2 and l[0][0] == l[1][0] and (l[0][1] == l[1][1]):
		print('Yes')
	else:
		print('No')


from collections import *
for _ in range(int(input())):
	n = int(input())
	A = list(input())
	B = list(input())
	swap = []
	ans = True
	C = Counter(A + B)
	for c in C:
		ans = ans and (not C[c] % 2)
	if not ans:
		print('No')
		continue
	for i in range(n):
		if A[i] == B[i]:
			continue
		for j in range(i + 1, n):
			if A[i] == A[j]:
				swap.append((j + 1, i + 1))
				(B[i], A[j]) = (A[j], B[i])
				break
			if A[i] == B[j]:
				swap.append((j + 1, j + 1))
				swap.append((j + 1, i + 1))
				(B[i], B[j], A[j]) = (B[j], A[j], B[i])
				break
	print('Yes')
	print(len(swap))
	for i in swap:
		print(str(i[0]) + ' ' + str(i[1]))


import math
t = int(input())
while t > 0:
	n = int(input())
	(a, b) = (input(), input())
	cnt = 0
	for i in range(n):
		if a[i] != b[i]:
			cnt += 1
			if cnt == 1:
				(ch1x, ch1y) = (a[i], b[i])
			else:
				(ch2x, ch2y) = (a[i], b[i])
	if cnt == 0 or (cnt == 2 and ch1x == ch2x and (ch1y == ch2y)):
		print('YES')
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	l = int(input())
	s = input()
	t = input()
	difs = 0
	s1 = ''
	t1 = ''
	for j in range(l):
		if s[j] != t[j]:
			difs += 1
			s1 += s[j]
			t1 += t[j]
	if difs == 0:
		print('Yes')
	elif difs == 2:
		if s1[0] + t1[1] == s1[1] + t1[0]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	b = input()
	(x, y) = ('', '')
	for i in range(n):
		if a[i] != b[i]:
			x = x + a[i]
			y += b[i]
	if len(set(x)) == 1 and len(set(y)) == 1 and (len(x) == 2) and (len(y) == 2):
		print('YES')
	else:
		print('NO')


testes = int(input())
for t in range(testes):
	n = int(input())
	ent1 = input()
	ent2 = input()
	if ent1 == ent2:
		print('Yes')
	else:
		c = 0
		D = []
		for k in range(n):
			if ent1[k] != ent2[k]:
				D.append(ent1[k])
				D.append(ent2[k])
				c += 1
			if c > 2:
				break
		if c > 2:
			print('No')
		elif len(D) <= 2:
			print('No')
		elif D[0] == D[2] and D[1] == D[3]:
			print('Yes')
		else:
			print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	h = 0
	j = 0
	L = []
	M = []
	d = 0
	for i in range(len(s)):
		if s[i] != t[i]:
			d += 1
			L.append(s[i])
			M.append(t[i])
			j += 1
		if d == 3:
			h = 1
			print('No')
			break
		if h == 1:
			break
	if d == 0 or d == 1 or L[0] != L[1] or (M[0] != M[1]):
		if h != 1:
			print('No')
	elif h != 1:
		print('Yes')


from collections import Counter
for i in range(int(input())):
	size = int(input())
	first = list(input())
	second = list(input())
	arr = []
	for i in range(size):
		if first[i] != second[i]:
			arr.append(i)
	if len(arr) == 2:
		(first[arr[0]], second[arr[1]]) = (second[arr[1]], first[arr[0]])
		if first == second:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations
from bisect import *

def main():
	for _ in range(int(input())):
		n = int(input())
		s = list(input().rstrip())
		t = list(input().rstrip())
		a = [0] * 26
		b = [0] * 26
		for i in s:
			a[ord(i) - 97] += 1
		for i in t:
			b[ord(i) - 97] += 1
		f = 0
		for i in range(26):
			if (a[i] + b[i]) % 2:
				f = 1
				break
		if f:
			print('No')
		else:
			print('Yes')
			c = []
			for i in range(n):
				if s[i] != t[i]:
					z = ord(s[i]) - 97
					y = ord(t[i]) - 97
					if a[z] != 1:
						ind = i
						for j in range(i + 1, n):
							if s[i] == s[j]:
								ind = j
								break
						c.append([ind + 1, i + 1])
						a[y] += 1
						a[z] -= 2
						b[y] -= 1
						s[ind] = t[i]
					elif b[y] != 1:
						ind = i
						for j in range(i + 1, n):
							if t[i] == t[j]:
								ind = j
								break
						c.append([i + 1, ind + 1])
						t[ind] = s[i]
						a[z] -= 1
						b[z] += 1
						b[y] -= 2
					else:
						ind = 0
						for j in range(i + 1, n):
							if s[i] == t[j]:
								ind = j
								break
						c.append([ind + 1, ind + 1])
						c.append([ind + 1, i + 1])
						x = ord(s[ind]) - 97
						a[z] -= 1
						b[y] -= 1
						a[y] += 1
						b[x] += 1
						a[x] -= 1
						b[z] -= 1
						t[ind] = s[ind]
						s[ind] = t[i]
				else:
					z = ord(s[i]) - 97
					a[z] -= 1
					b[z] -= 1
			print(len(c))
			for i in c:
				print(*i)
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()


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	r = input()
	cnt = 0
	l = []
	for i in range(n):
		if s[i] != r[i]:
			l.append(i)
			cnt += 1
	if cnt == 2:
		if s[l[0]] == s[l[1]] and r[l[0]] == r[l[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
	t -= 1


for tt in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			ind.append(i)
	if len(ind) == 2:
		if s[ind[0]] == s[ind[1]] and t[ind[0]] == t[ind[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
for kk in range(k):
	n = int(input())
	s = input()
	t = input()
	swap = []
	for i in range(n):
		if s[i] != t[i]:
			swap.append((s[i], t[i]))
	if len(swap) == 2 and swap[0] == swap[1]:
		print('Yes')
	else:
		print('No')


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	t = input()
	cnt = 0
	tmp = []
	for i in range(n):
		if s[i] != t[i]:
			cnt += 1
			tmp.append(i)
	if cnt == 0:
		print('Yes')
	elif cnt == 1:
		print('No')
	elif cnt == 2:
		if s[tmp[0]] == s[tmp[1]] and t[tmp[0]] == t[tmp[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	s = list(input())
	t = list(input())
	d = defaultdict(int)
	for x in s:
		d[x] += 1
	for x in t:
		d[x] += 1
	bad = False
	for key in list(d):
		if d[key] % 2:
			bad = True
	if bad:
		print('No')
		continue
	res = []
	for i in range(n):
		if s[i] != t[i]:
			if i == n - 1:
				bad = True
				break
			for j in range(i + 1, n):
				if t[i] == t[j]:
					(s[i], t[j]) = (t[j], s[i])
					res.append((i, j))
					break
			else:
				for j in range(i + 1, n):
					if t[i] == s[j]:
						(s[j], t[j]) = (t[j], s[j])
						(s[i], t[j]) = (t[j], s[i])
						res.append((j, j))
						res.append((i, j))
						break
	if bad:
		print('No')
		continue
	print('Yes')
	print(len(res))
	for (a, b) in res:
		print(a + 1, b + 1)


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	d = [0] * 26
	for i in s:
		d[ord(i) - 97] += 1
	for i in t:
		d[ord(i) - 97] += 1
	flag = 0
	for i in d:
		if i % 2:
			flag = 1
			break
	if flag:
		print('No')
	else:
		ans = []
		print('Yes')
		build = 0
		while build < n:
			if s[build] == t[build]:
				build += 1
				continue
			present = False
			for i in range(build + 1, n):
				if s[build] == s[i]:
					ans.append((i + 1, build + 1))
					(s[i], t[build]) = (t[build], s[i])
					present = True
					break
			if not present:
				findbelow = False
				for i in range(build + 1, n):
					if s[build] == t[i]:
						ans.append((build + 2, i + 1))
						ans.append((build + 2, build + 1))
						(s[build + 1], t[i]) = (t[i], s[build + 1])
						(s[build + 1], t[build]) = (t[build], s[build + 1])
						findbelow = True
						break
			build += 1
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


for _ in range(int(input())):
	(n, s, t) = (input(), input(), input())
	d = [(x, y) for (x, y) in zip(s, t) if x != y]
	print('YNEOS'[len(d) != 2 or d[0] != d[1]::2])


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	k = list(input())
	g = list(input())
	d = []
	c = 0
	for i in range(n):
		if k[i] != g[i]:
			c += 1
			d.append(k[i])
			d.append(g[i])
	if c == 2 and d[0] == d[2] and (d[1] == d[3]):
		print('Yes')
	else:
		print('No')


def solve(n, s, t):
	if s == t:
		return 'Yes'
	pair = None
	swapped = False
	for i in range(n):
		if s[i] != t[i]:
			if not pair:
				pair = [s[i], t[i]]
			elif not swapped:
				if pair == [s[i], t[i]]:
					swapped = True
				else:
					return 'No'
			else:
				return 'No'
	return 'Yes' if swapped else 'No'
for nt in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	print(solve(n, s, t))


for _ in range(int(input())):
	n = int(input())
	ch1 = input()
	ch2 = input()
	l = []
	for i in range(n):
		if ch1[i] != ch2[i]:
			l = l + [ch1[i] + ch2[i]]
	if len(l) != 2 or l[0] != l[1]:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	c = []
	d = []
	sum = 0
	for i in range(n):
		if a[i] == b[i]:
			continue
		else:
			sum += 1
			c.append(a[i])
			d.append(b[i])
	if sum == 0:
		print('YES')
	elif sum == 1:
		print('NO')
	elif sum > 2:
		print('NO')
	elif c.count(c[0]) == 2 and d.count(d[0]) == 2:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
y = int(input())
for i in range(y):
	n = int(input())
	s1 = input()
	s11 = []
	t1 = input()
	t11 = []
	d1 = {}
	count = 0
	for j in range(n):
		s11.append(s1[j])
		if d1.get(s1[j], 'l') == 'l':
			d1[s1[j]] = []
		else:
			d1[s1[j]].append(j)
		t11.append(t1[j])
	f = []
	for j in range(n):
		if s11[j] != t11[j]:
			for k in range(j + 1, n):
				if t11[k] == t11[j] and s11[k] != t11[k]:
					temp = t11[k]
					t11[k] = s11[j]
					s11[j] = temp
					f.append((j, k))
					count += 1
					break
			if s11[j] != t11[j]:
				for k in range(j + 1, n):
					if t11[j] == s11[k] and t11[k] != s11[k]:
						(s11[j], t11[k], s11[k]) = (s11[k], s11[j], t11[k])
						f.append((k, k))
						f.append((j, k))
						count += 2
						break
	lol = True
	if count > 2 ** n:
		lol = False
	for j in range(n):
		if s11[j] != t11[j]:
			lol = False
			break
	if lol == True:
		print('Yes')
		print(count)
		if len(f) > 0:
			for k in f:
				print(k[0] + 1, k[1] + 1)
	else:
		print('No')


nn = int(input())
answer = []
for _ in range(nn):
	n = int(input())
	s = input().strip()
	t = input().strip()
	a = []
	for i in range(n):
		if s[i] != t[i]:
			a.append(i)
			if len(a) > 2:
				answer.append('No')
				break
	else:
		if len(a) == 0:
			answer.append('Yes')
		elif len(a) == 1:
			answer.append('No')
		elif s[a[0]] == s[a[1]] and t[a[0]] == t[a[1]]:
			answer.append('Yes')
		else:
			answer.append('No')
for i in answer:
	print(i)


k = int(input())
for nt in range(k):
	n = int(input())
	s = input()
	t = input()
	diff = 0
	same = 0
	d = []
	for i in range(n):
		if s[i] == t[i]:
			same += 1
		else:
			diff += 1
			d.append([s[i], t[i]])
	if diff > 2:
		print('No')
	elif diff == 1:
		print('No')
	elif diff == 0:
		print('Yes')
	elif d[0][0] == d[1][0] and d[0][1] == d[1][1]:
		print('Yes')
	else:
		print('No')


k = int(input())
for nt in range(k):
	n = int(input())
	s = input()
	t = input()
	count = {}
	for i in range(n):
		if s[i] in count:
			count[s[i]] += 1
		else:
			count[s[i]] = 1
		if t[i] in count:
			count[t[i]] += 1
		else:
			count[t[i]] = 1
	flag = 0
	for i in count:
		if count[i] % 2 == 1:
			flag = 1
			print('No')
			break
	if flag == 1:
		continue
	print('Yes')
	ans = []
	for i in range(n - 1):
		if s[i] != t[i]:
			place = t.find(s[i], i + 1)
			if place != -1:
				ans.append([i + 2, place + 1])
				ans.append([i + 2, i + 1])
				ex = s[i + 1]
				s = s[0:i + 1] + t[i] + s[i + 2:]
				t = t[0:i] + t[place] + t[i + 1:place] + ex + t[place + 1:]
			else:
				place = s.find(s[i], i + 1)
				ans.append([place + 1, i + 1])
				s = s[0:place] + t[i] + s[place + 1:]
				t = t[0:i] + s[i] + t[i + 1:]
	print(len(ans))
	for i in ans:
		print(*i)


I = input
for _ in [0] * int(I()):
	I()
	a = [x + y for (x, y) in zip(I(), I()) if x != y]
	print('YNeos'[a != [a[0]] * 2::2])


k = int(input())
for i in range(k):
	n = int(input())
	a = str(input())
	b = str(input())
	s = 0
	j = 0
	q = 0
	x = ''
	y = ''
	z = ''
	t = ''
	while j < n:
		if a[j] != b[j]:
			s += 1
			if s > 2:
				q = 1
				break
			elif s == 1:
				x = x + a[j]
				y = y + b[j]
			else:
				z = z + a[j]
				t = t + b[j]
		j += 1
	if q == 1:
		print('No')
	elif s == 2:
		if x == z and y == t:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
while k:
	n = int(input())
	s = input()
	t = input()
	c = 0
	l = []
	for i in range(n):
		if s[i] != t[i]:
			l.append(i)
			c += 1
	if c == 2 or c == 0:
		if t[l[1]] == t[l[0]] and s[l[0]] == s[l[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
	k -= 1


t = int(input())
for j in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	k = 0
	kind = []
	deff = 0
	for i in range(n):
		if a[i] != b[i]:
			k += 1
			kind.append(i)
	if k != 2:
		print('NO')
	elif deff == 0:
		if a[kind[0]] == a[kind[1]] and b[kind[1]] == b[kind[0]]:
			print('YES')
		else:
			print('NO')


test = int(input())
for _ in range(test):
	n = int(input())
	s = input()
	t = input()
	it = 0
	j = -1
	f = ''
	g = ''
	for i in range(n):
		if s[i] == t[i]:
			pass
		elif j == -1:
			f = s[i]
			g = t[i]
			j = 0
		elif s[i] == f and t[i] == g and (j == 0):
			it = 1
			j = -9
		else:
			j = -10
	if it == 1 and j == -9:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = int(input())
	n = input()
	t = input()
	lst = []
	for i in range(l):
		if n[i] != t[i]:
			lst.append([n[i], t[i]])
	if len(lst) != 2:
		print('No')
	elif lst[0] == lst[1]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	word1 = input()
	word2 = input()
	count = 0
	dictionary = ''
	for i in range(n):
		if word1[i] != word2[i]:
			count += 1
			if not dictionary:
				dictionary = word1[i] + word2[i]
			elif word1[i] + word2[i] != dictionary:
				count = 3
	if count == 2:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	i = 0
	d = []
	while i < n:
		if s[i] != t[i]:
			d.append(i)
		i += 1
	if len(d) == 2:
		if s[d[0]] == s[d[1]] and t[d[0]] == t[d[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import sys, atexit
from io import BytesIO
inp = BytesIO(sys.stdin.buffer.read())
input = lambda : inp.readline().decode('ascii')
buf = BytesIO()
atexit.register(lambda : sys.__stdout__.buffer.write(buf.getvalue()))
for i in range(int(input())):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	l = []
	for i in range(n):
		if s1[i] != s2[i]:
			l.append(i)
	if len(l) == 0:
		print('Yes')
	if len(l) > 2 or len(l) == 1:
		print('No')
		continue
	f = False
	for i in range(2):
		(s1[l[i]], s2[l[i - 1]]) = (s2[l[i - 1]], s1[l[i]])
		if s1 == s2:
			f = True
			break
		(s1[l[i]], s2[l[i - 1]]) = (s2[l[i - 1]], s1[l[i]])
	if f:
		print('Yes')
	else:
		print('No')


def indexing(char, arr):
	for i in range(len(arr)):
		if arr[i] == char:
			return i
	return -1
t = int(input())
answer = []
alphabets = 'abcdefghijklmnopqrstuvwxyz'
for i in range(t):
	n = int(input())
	S = str(input())
	T = str(input())
	S1 = ''
	T1 = ''
	arr = []
	for j in range(n):
		if S[j] != T[j]:
			S1 += S[j]
			T1 += T[j]
			arr.append(j + 1)
	A = [0] * 26
	for j in range(len(S1)):
		A[alphabets.find(S1[j])] += 1
		A[alphabets.find(T1[j])] += 1
	check = True
	for j in range(26):
		if A[j] % 2 == 1:
			check = False
	if check:
		answer.append(['Yes'])
		count = 0
		S2 = []
		T2 = []
		for j in range(len(S1)):
			S2.append(S1[j])
			T2.append(T1[j])
		ans = []
		for j in range(len(S2)):
			if T2[j] == S2[j]:
				continue
			k = indexing(S2[j], S2[j + 1:])
			if k > -1:
				count += 1
				S2[k + j + 1] = T2[j]
				ans.append([arr[k + j + 1], arr[j]])
			else:
				count += 2
				k = indexing(S2[j], T2[j + 1:])
				T2[k + j + 1] = S2[k + j + 1]
				S2[k + j + 1] = T2[j]
				ans.append([arr[k + j + 1], arr[k + j + 1]])
				ans.append([arr[k + j + 1], arr[j]])
		answer.append([count])
		answer += ans
	else:
		answer.append(['No'])
for i in range(len(answer)):
	print(*answer[i], sep=' ')


k = int(input())
for w in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	dif1 = []
	dif2 = []
	pos = []
	for i in range(n):
		if s[i] != t[i]:
			pos.append(i)
			dif1.append(s[i])
			dif2.append(t[i])
	if len(set(pos)) == 0:
		print('YES')
		continue
	if len(set(pos)) == 1:
		print('NO')
		continue
	if len(set(pos)) == 2:
		if len(set(dif1)) == 1 and len(set(dif2)) == 1:
			print('YES')
		else:
			print('NO')
		continue
	print('NO')


for _ in range(int(input().strip())):
	n = int(input().strip())
	s1 = input().strip()
	s2 = input().strip()
	if s1 == s2:
		print('Yes')
	else:
		s1 = list(s1)
		s2 = list(s2)
		dif = 0
		idx = []
		for i in range(n):
			if s1[i] != s2[i]:
				dif += 1
				idx.append(i)
		if dif == 1 or dif > 2:
			print('No')
		elif s1[idx[0]] == s1[idx[1]] and s2[idx[0]] == s2[idx[1]]:
			print('Yes')
		else:
			print('No')


k = int(input())
m = []
for i in range(k):
	n = int(input())
	l1 = input()
	l2 = input()
	m.append([l1, l2])
for i in range(len(m)):
	l1 = m[i][0]
	l2 = m[i][1]
	k = 0
	s1 = ''
	s2 = ''
	e = 0
	for j in range(len(l1)):
		if not l1[j] == l2[j]:
			if s1 != '' and s2 != '':
				if s1 == l1[j] and s2 == l2[j]:
					e = 1
			s1 = l1[j]
			s2 = l2[j]
			k += 1
			if k > 2:
				break
	if k == 2 and e == 1:
		print('YES')
	else:
		print('NO')


k = int(input())
for i in range(k):
	n = int(input())
	sa = input()
	sb = input()
	diff = [[], []]
	for (a, b) in zip(sa, sb):
		if a != b:
			diff[0].append(a)
			diff[1].append(b)
	N = len(diff[0])
	if N == 0:
		print('Yes')
	elif N == 2:
		if diff[0][0] == diff[0][1] and diff[1][1] == diff[1][0]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	b = input()
	d1 = []
	d2 = []
	count = 0
	for i in range(n):
		if a[i] != b[i]:
			count += 1
			d1.append(a[i])
			d2.append(b[i])
		if count > 2:
			print('NO')
			break
	else:
		if count == 1:
			print('NO')
		elif count == 0:
			print('YES')
		elif d1[0] == d1[1] and d2[1] == d2[0]:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline
from bisect import *
t = int(input())
for _ in range(t):
	n = int(input())
	(s1, s2) = (list(input().strip()), list(input().strip()))
	opr = []
	g = 0
	for i in range(n):
		if s1[i] == s2[i]:
			continue
		a = i
		e = 0
		if s1[a] in s1[a + 1:]:
			b = s1[a + 1:].index(s1[a]) + a + 1
			(s2[a], s1[b]) = (s1[b], s2[a])
			opr.append((b + 1, a + 1))
		elif s1[a] in s2[a + 1:]:
			b = s2[a + 1:].index(s1[a]) + a + 1
			(s1[a], s2[a]) = (s2[a], s1[a])
			(s1[a], s2[b]) = (s2[b], s1[a])
			opr.append((a + 1, a + 1))
			opr.append((a + 1, b + 1))
		elif s2[a] in s2[a + 1:]:
			b = s2[a + 1:].index(s2[a]) + a + 1
			(s1[a], s2[b]) = (s2[b], s1[a])
			opr.append((a + 1, b + 1))
		elif s2[a] in s1[a + 1:]:
			b = s1[a + 1:].index(s2[a]) + a + 1
			(s2[a], s1[a]) = (s1[a], s2[a])
			(s2[a], s1[b]) = (s1[b], s2[a])
			opr.append((a + 1, a + 1))
			opr.append((b + 1, a + 1))
		else:
			g = 1
			break
	if g:
		print('NO')
	else:
		print('YES')
		print(len(opr))
		for i in opr:
			print(*i)


tc = int(input())
while tc > 0:
	n = int(input())
	s = input()
	t = input()
	(cnt, p1, p2) = (0, -1, -1)
	for i in range(n):
		if s[i] != t[i]:
			cnt += 1
			if cnt == 1:
				p1 = i
			elif cnt == 2:
				p2 = i
			elif cnt > 2:
				break
	if p1 != -1 and p2 != -1 and (cnt == 2):
		if s[p1] == s[p2] and t[p1] == t[p2]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	tc -= 1


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	n = ii()
	s1 = si()
	s2 = si()
	ind = []
	for i in range(n):
		if s1[i] != s2[i]:
			ind.append(i)
	if len(ind) == 2 and s1[ind[0]] == s1[ind[1]] and (s2[ind[0]] == s2[ind[1]]) or len(ind) == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	t = t - 1
	h = []
	n = int(input())
	a = input()
	b = input()
	for i in range(n):
		if a[i] != b[i]:
			h.append([a[i], b[i]])
	if len(h) != 2:
		print('NO')
	elif h[0] == h[1]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	d = []
	for i in range(n):
		if s[i] != t[i]:
			d.append(i)
	if len(d) != 2:
		print('No')
	else:
		(i, j) = d
		if s[i] == s[j] and t[i] == t[j]:
			print('Yes')
		else:
			print('No')


import sys

def case():
	str_l = int(sys.stdin.readline()[:-1])
	s = list(sys.stdin.readline()[:-1])
	t = list(sys.stdin.readline()[:-1])
	diff = []
	for i in range(0, str_l):
		if s[i] == t[i]:
			continue
		diff.append(i)
		if len(diff) > 2:
			print('No')
			return
	if len(diff) == 0:
		print('Yes')
		return
	if len(diff) == 1:
		print('No')
		return
	if len(diff) == 2:
		(s[diff[0]], t[diff[1]]) = (t[diff[1]], s[diff[0]])
		if s == t:
			print('Yes')
		else:
			print('No')
testcase_n = int(sys.stdin.readline()[:-1])
for _ in range(0, testcase_n):
	case()


for i in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	a = []
	curr = 0
	for i in range(n):
		curr += s1[i] != s2[i]
		if s1[i] != s2[i] and len(a) < 2:
			a.append(i)
	if s1 == s2:
		print('Yes')
	elif curr != 2:
		print('No')
	elif s1[a[0]] == s1[a[1]] and s2[a[1]] == s2[a[0]]:
		print('Yes')
	else:
		print('No')


from math import ceil, sqrt, gcd
from collections import deque, defaultdict

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
t1 = ii()
while t1:
	t1 -= 1
	n = ii()
	s = si()
	t = si()
	k = 0
	b = []
	for i in range(n):
		if s[i] != t[i]:
			b.append(i)
	s = list(s)
	t = list(t)
	if len(b) > 2:
		print('NO')
	elif len(b) == 0:
		print('YES')
	elif len(b) == 1:
		print('NO')
	else:
		p = s[b[0]]
		s[b[0]] = t[b[1]]
		t[b[1]] = p
		f = 0
		for i in range(n):
			if s[i] != t[i]:
				print('NO')
				f = 1
				break
		if f == 0:
			print('YES')


fk = int(input())
for _ in range(fk):
	n = int(input())
	l1 = list(str(input()))
	l2 = list(str(input()))
	l3 = l1.copy()
	l4 = l2.copy()
	c = 0
	w = 0
	k = 0
	for i in range(n):
		if l1[i] != l2[i]:
			c += 1
			for j in range(n):
				l3[i] = l4[j]
				l4[j] = l1[i]
				if l3 == l4:
					w += 1
					break
				l3[i] = l1[i]
				l4[j] = l2[j]
			if w != 1:
				for j in range(n):
					l4[i] = l3[j]
					l3[j] = l2[i]
					if l4 == l3:
						k += 1
						break
					l4[i] = l2[i]
					l3[j] = l1[j]
			if k != 1:
				break
			break
	if w == 1 or k == 1:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	q = list(input())
	w = list(input())
	e = []
	r = []
	for j in range(n):
		if q[j] != w[j]:
			e.append(q[j])
			r.append(w[j])
	if len(e) == 2 and len(set(e)) == 1 and (len(set(r)) == 1):
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s1 = input()
	t1 = input()
	arr = []
	arr1 = []
	i = flag = 0
	count = 1
	while i < n:
		if s1[i] != t1[i]:
			if len(arr) == 0:
				arr.append(s1[i])
				arr1.append(t1[i])
			elif arr[-1] == s1[i] and arr1[-1] == t1[i]:
				flag = 1
				count += 1
			else:
				flag = 2
				break
		i += 1
	if flag < 2 and count == 2:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = str(input())
	b = str(input())
	g = 0
	p = []
	pp = []
	for i in range(n):
		if a[i] == b[i]:
			g += 1
		else:
			p.append(a[i])
			pp.append(b[i])
	if g == n:
		print('Yes')
		continue
	elif g == n - 2:
		if p[0] == p[1] and pp[0] == pp[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	count = 0
	li = []
	for i in range(n):
		if s1[i] != s2[i]:
			li.append(i)
	if len(li) == 2 and (s1[li[0]] == s1[li[1]] and s2[li[1]] == s2[li[0]]):
		print('Yes')
	else:
		print('No')


from collections import Counter
import sys
import math
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())
for _ in range(val()):
	n = val()
	s1 = st()
	s2 = st()
	tot = 0
	curr = []
	for i in range(n):
		if s1[i] != s2[i]:
			tot += 1
			if len(curr) < 2:
				curr.append(i)
	print('YES' if not tot or (tot == 2 and (s1[curr[0]] == s1[curr[-1]] and s2[curr[0]] == s2[curr[-1]])) else 'NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	d = {}
	for i in range(ord('a'), ord('z') + 1):
		d[chr(i)] = 0
	for cs in s:
		d[cs] += 1
	for ct in t:
		d[ct] += 1
	ok = True
	for e in d:
		if d[e] % 2 == 1:
			ok = False
	if not ok:
		print('No')
	else:
		print('Yes')
		changes = []
		(s, t) = (list(s), list(t))
		for i in range(n - 1):
			if s[i] != t[i]:
				r = (0, -1)
				for j in range(i + 1, n):
					if s[j] == t[i]:
						r = (j, 0)
				for j in range(i + 1, n):
					if t[j] == t[i]:
						r = (j, 1)
				if r[1] == 0:
					changes += [(r[0], i + 1), (i, i + 1)]
					(s[r[0]], t[i + 1]) = (t[i + 1], s[r[0]])
					(s[i], t[i + 1]) = (t[i + 1], s[i])
				elif r[1] == 1:
					changes += [(i, r[0])]
					(s[i], t[r[0]]) = (t[r[0]], s[i])
		print(len(changes))
		for change in changes:
			(x, y) = change
			print(x + 1, y + 1)


from sys import stdin, stdout
for i in stdin:
	q = int(i)
	break
for i in range(q):
	for i in stdin:
		n = int(i)
		break
	for i in stdin:
		s = i.strip()
		break
	for i in stdin:
		t = i.strip()
		break
	k = 0
	f = 0
	(s1, s2, t1, t2) = (-1, -1, -1, -1)
	while n:
		if s[n - 1] != t[n - 1]:
			k += 1
			if k == 1:
				(s1, t1) = (s[n - 1], t[n - 1])
			elif k == 2:
				(s2, t2) = (s[n - 1], t[n - 1])
			else:
				f = 1
				break
		n -= 1
	if f == 1:
		stdout.write('No\n')
	elif s1 == s2 and t1 == t2:
		stdout.write('Yes\n')
	else:
		stdout.write('No\n')


def solve_b1(s, t):
	arr = list()
	if s == t:
		return 'YES'
	for i in range(len(s)):
		if s[i] != t[i]:
			arr.append((s[i], t[i]))
	if len(arr) != 2:
		return 'NO'
	else:
		st = set(arr)
		if len(st) == 1:
			return 'YES'
		else:
			return 'NO'
q = int(input())
for _ in range(q):
	n = input()
	s = input()
	t = input()
	print(solve_b1(s, t))


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	count = 0
	arr = []
	for x in range(n):
		if s1[x] != s2[x]:
			count += 1
			arr += [x]
	if count != 2 and count != 0:
		print('NO')
		continue
	if count == 0:
		print('YES')
		continue
	s1 = list(s1)
	s2 = list(s2)
	(x1, x2) = (arr[0], arr[1])
	(s1[x1], s2[x1]) = (s2[x1], s1[x1])
	if s1 == s2:
		print('YES')
		continue
	(s1[x1], s2[x1]) = (s2[x1], s1[x1])
	(s1[x1], s2[x2]) = (s2[x2], s1[x1])
	if s1 == s2:
		print('YES')
		continue
	(s1[x1], s2[x2]) = (s2[x2], s1[x1])
	(s1[x2], s2[x1]) = (s2[x1], s1[x2])
	if s1 == s2:
		print('YES')
		continue
	(s1[x2], s2[x1]) = (s2[x1], s1[x2])
	(s1[x2], s2[x2]) = (s2[x2], s1[x2])
	if s1 == s2:
		print('YES')
		continue
	(s1[x2], s2[x2]) = (s2[x2], s1[x2])
	print('NO')


import sys
from sys import stdout
import bisect as bi
import math
from collections import defaultdict as dd
from types import GeneratorType
input = sys.stdin.readline
mo = 10 ** 9 + 7
MOD = 998244353

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

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

def inin():
	return int(input())
for _ in range(inin()):
	n = inin()
	s = sin()
	t = sin()
	pos = []
	for i in range(n):
		if s[i] != t[i]:
			pos += [i]
	if len(pos) != 2:
		print('No')
	elif s[pos[0]] != s[pos[1]] or t[pos[0]] != t[pos[1]]:
		print('No')
	else:
		print('Yes')

def msb(n):
	n |= n >> 1
	n |= n >> 2
	n |= n >> 4
	n |= n >> 8
	n |= n >> 16
	n |= n >> 32
	n |= n >> 64
	return n - (n >> 1)

def pref(a, n, f):
	pre = [0] * n
	if f == 0:
		pre[0] = a[0]
		for i in range(1, n):
			pre[i] = a[i] + pre[i - 1]
	else:
		pre[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			pre[i] = pre[i + 1] + a[i]
	return pre

def kadane(A):
	maxSoFar = maxEndingHere = start = end = beg = 0
	for i in range(len(A)):
		maxEndingHere = maxEndingHere + A[i]
		if maxEndingHere < 0:
			maxEndingHere = 0
			beg = i + 1
		if maxSoFar < maxEndingHere:
			maxSoFar = maxEndingHere
			start = beg
			end = i
	return (maxSoFar, start, end)

def modFact(n, p):
	if n < 0:
		return 0
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def ncr(n, r, p):
	if n < r or n < 0:
		return 0
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = input()
	t = input()
	pos = [0] * 26
	flag = 0
	for i in range(0, len(s)):
		pos[ord(s[i]) - 97] += 1
	for i in range(0, len(t)):
		pos[ord(t[i]) - 97] += 1
	for i in range(26):
		if pos[i] % 2 != 0:
			flag = 1
			break
	if flag == 1:
		print('No')
	else:
		print('Yes')
		ans = []
		s1 = []
		s2 = []
		for i in range(0, len(s)):
			s1.append(s[i])
		for i in range(0, len(t)):
			s2.append(t[i])
		for i in range(0, len(s1)):
			if s1[i] != s2[i]:
				for j in range(i + 1, len(s2)):
					if s1[i] == s2[j]:
						temp = s2[j]
						s2[j] = s1[j]
						s1[j] = temp
						ans.append((j + 1, j + 1))
					if s1[i] == s1[j]:
						temp = s1[j]
						s1[j] = s2[i]
						s2[i] = temp
						ans.append((j + 1, i + 1))
						break
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


t = int(input())
while t != 0:
	a = int(input())
	b = input()
	c = input()
	count = 0
	d = []
	for i in range(0, a):
		if b[i] != c[i]:
			d.append(i)
			count += 1
			if count > 2:
				break
	if count == 2 and c[d[1]] == c[d[0]] and (b[d[0]] == b[d[1]]):
		print('Yes')
	else:
		print('No')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	s1 = [i for i in s1]
	s2 = [i for i in s2]
	freq = {}
	for i in s1:
		if i not in freq:
			freq[i] = 0
		freq[i] += 1
	for i in s2:
		if i not in freq:
			freq[i] = 0
		freq[i] += 1
	f = True
	for i in freq:
		if freq[i] % 2 != 0:
			f = False
			print('No')
			break
	if not f:
		continue
	pos = 0
	ans = []
	f = True
	while pos < len(s1):
		if s1[pos] == s2[pos]:
			pos += 1
			continue
		idx = -1
		for i in range(pos + 1, len(s1)):
			if s1[pos] == s1[i]:
				idx = i
				break
		if idx != -1:
			(s2[pos], s1[idx]) = (s1[idx], s2[pos])
			ans.append((idx + 1, pos + 1))
			pos += 1
			continue
		(s1[pos], s2[pos]) = (s2[pos], s1[pos])
		ans.append((pos + 1, pos + 1))
		idx = -1
		for i in range(pos + 1, len(s1)):
			if s1[pos] == s1[i]:
				idx = i
				break
		if idx != -1:
			(s2[pos], s1[idx]) = (s1[idx], s2[pos])
			ans.append((idx + 1, pos + 1))
			pos += 1
			continue
		(s1[pos], s2[pos]) = (s2[pos], s1[pos])
		ans.pop()
		idx = -1
		for i in range(pos + 1, len(s2)):
			if s2[i] == s2[pos]:
				idx = i
				break
		if idx == -1:
			f = False
			break
		(s1[pos], s2[idx]) = (s2[idx], s1[pos])
		ans.append([pos + 1, idx + 1])
	if f:
		print('Yes')
		print(len(ans))
		for i in ans:
			print(i[0], i[1])
	else:
		print('No')


k = int(input())
for test in range(k):
	leng = int(input())
	s = list(input())
	t = list(input())
	if s == t:
		print('Yes')
	else:
		d1 = 0
		d2 = 0
		i1 = []
		i2 = []
		for i in range(len(s)):
			if s[i] != t[i]:
				d1 += 1
				i1.append(i)
		if d1 == 2:
			if s[i1[0]] + t[i1[1]] == s[i1[1]] + t[i1[0]]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


import sys
sys.setrecursionlimit(2000)
from collections import Counter
from functools import reduce
t = [int(val) for val in sys.stdin.readline().split()][0]
for test in range(t):
	n = [int(val) for val in sys.stdin.readline().split()][0]
	s = [str(val) for val in sys.stdin.readline().split()][0]
	t = [str(val) for val in sys.stdin.readline().split()][0]
	diffs = []
	for ind in range(n):
		if s[ind] != t[ind]:
			diffs.append(ind)
	if len(diffs) != 2:
		print('No')
		continue
	j1 = diffs[0]
	j2 = diffs[1]
	if t[j1] != t[j2] or s[j1] != s[j2]:
		print('No')
		continue
	print('Yes')


import os
import sys
from io import BytesIO, IOBase

def solution(s, t, n):
	if s == t:
		write('YES')
		return
	(ne, ne_li) = (0, [])
	for i in range(n):
		if s[i] != t[i]:
			ne += 1
			ne_li.append([s[i] + t[i]])
	if ne == 2:
		if ne_li[0] == ne_li[1]:
			write('YES')
		else:
			write('NO')
	else:
		write('NO')

def main():
	for _ in range(r_int()):
		n = r_int()
		s = input()
		t = input()
		solution(s, t, n)
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

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

def r_int():
	return int(input())

def w_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			ind.append((s[i], t[i]))
	if len(ind) != 2:
		print('NO')
	elif ind[0] == ind[1]:
		print('YES')
	else:
		print('NO')


def make_them_same(n, s, t):
	invs = [(s[i], t[i]) for i in range(n) if s[i] != t[i]]
	if len(invs) == 0:
		return 'Yes'
	if len(invs) == 2 and len(set(s) ^ set(t)) < 3 and (invs[0] == invs[1]):
		return 'Yes'
	return 'No'
q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	t = input()
	print(make_them_same(n, s, t))


import sys
from collections import defaultdict as dc
import math
from bisect import bisect, bisect_left, bisect_right
for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	x = []
	c = 0
	for i in range(n):
		if s1[i] != s2[i]:
			if c < 2:
				x.append(i)
			c += 1
	if c < 2 or c > 2:
		print('No')
	elif s1[x[0]] == s1[x[1]] and s2[x[0]] == s2[x[1]]:
		print('Yes')
	else:
		print('No')


T = int(input())
for t in range(T):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	freq = [0] * 26
	for i in s1:
		freq[ord(i) - ord('a')] += 1
	for i in s2:
		freq[ord(i) - ord('a')] += 1
	ok = 1
	for i in range(26):
		if freq[i] & 1:
			ok = 0
	if ok == 0:
		print('No')
		continue
	freqa = [0] * 26
	mapa = [[] for i in range(26)]
	mapb = [[] for i in range(26)]
	for i in range(n):
		mapa[ord(s1[i]) - ord('a')].append(i)
		mapb[ord(s2[i]) - ord('a')].append(i)
	excessa = [[] for i in range(26)]
	excessb = [[] for i in range(26)]
	for i in range(26):
		if len(mapa[i]) > freq[i] // 2:
			for j in range(freq[i] // 2, len(mapa[i])):
				excessa[i].append(mapa[i][j])
		if len(mapb[i]) > freq[i] // 2:
			for j in range(freq[i] // 2, len(mapb[i])):
				excessb[i].append(mapb[i][j])
	alla = []
	for i in range(26):
		for j in excessa[i]:
			alla.append(j)
	allb = []
	for i in range(26):
		for j in excessb[i]:
			allb.append(j)
	op = []
	for ite in range(n):
		for i in range(n):
			if s1[i] == s2[i]:
				continue
			found = 0
			if found == 0:
				for j in range(i + 1, n):
					if s2[i] == s2[j]:
						found = 1
						op.append((i + 1, j + 1))
						(s1[i], s2[j]) = (s2[j], s1[i])
					if found:
						break
			for j in range(i - 1, -1, -1):
				if s1[j] == s2[i] and s1[j] != s2[j]:
					found = 1
					op.append((j + 1, j + 1))
					(s1[j], s2[j]) = (s2[j], s1[j])
					op.append((j + 1, i + 1))
					(s1[j], s2[i]) = (s2[i], s1[j])
				if found:
					break
	if s1 == s2:
		print('Yes')
		print(min(2 * n, len(op)))
		for i in op:
			print(*i)
	else:
		print('No')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
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')
k = int(input())
for nt in range(k):
	n = int(input())
	s = input()
	t = input()
	count = {}
	for i in range(n):
		if s[i] in count:
			count[s[i]] += 1
		else:
			count[s[i]] = 1
		if t[i] in count:
			count[t[i]] += 1
		else:
			count[t[i]] = 1
	flag = 0
	for i in count:
		if count[i] % 2 == 1:
			flag = 1
			print('No')
			break
	if flag == 1:
		continue
	print('Yes')
	ans = []
	for i in range(n - 1):
		if s[i] != t[i]:
			place = t.find(s[i], i + 1)
			if place != -1:
				ans.append([i + 2, place + 1])
				ans.append([i + 2, i + 1])
				ex = s[i + 1]
				s = s[0:i + 1] + t[i] + s[i + 2:]
				t = t[0:i] + t[place] + t[i + 1:place] + ex + t[place + 1:]
			else:
				place = s.find(s[i], i + 1)
				ans.append([place + 1, i + 1])
				s = s[0:place] + t[i] + s[place + 1:]
				t = t[0:i] + s[i] + t[i + 1:]
	print(len(ans))
	for i in ans:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	c = 0
	a = ''
	b = ''
	for i in range(n):
		if s1[i] != s2[i]:
			a += s1[i]
			b += s2[i]
			c += 1
	if c > 2:
		print('NO')
	else:
		a1 = len(set(a))
		b1 = len(set(b))
		a2 = len(a)
		b2 = len(b)
		if a1 == 1 and b1 == 1 and (a2 == 2) and (b2 == 2):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	str1 = input()
	str2 = input()
	str1 = list(str1)
	str2 = list(str2)
	s1 = []
	s2 = []
	for j in range(n):
		if str1[j] != str2[j]:
			s1.append(str1[j])
			s2.append(str2[j])
	if len(s1) == 2 and len(s2) == 2 and (s1[0] == s1[1]) and (s2[0] == s2[1]):
		print('YES')
	else:
		print('NO')


k = int(input())
while k:
	k -= 1
	n = int(input())
	s = input()
	t = input()
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			ind.append(i)
	if len(ind) != 2:
		print('No')
	elif s[ind[0]] != s[ind[1]]:
		print('No')
	elif t[ind[0]] != t[ind[1]]:
		print('No')
	else:
		print('Yes')


import sys
sys.setrecursionlimit(2000)
from collections import Counter
from functools import reduce
import code

def need_one_swap_to_equal(str1, str2):
	len1 = len(str1)
	len2 = len(str2)
	if len1 != len2:
		return False
	prev = -1
	curr = -1
	count = 0
	for i in range(len1):
		if str1[i] != str2[i]:
			count = count + 1
			if count > 2:
				return False
			prev = curr
			curr = i
	temp = str1[prev]
	str1[prev] = str2[curr]
	str2[curr] = temp
	return str1 == str2
n_test_cases = int(sys.stdin.readline().rstrip())
for _ in range(n_test_cases):
	n = int(sys.stdin.readline().rstrip())
	word1 = sys.stdin.readline().rstrip()
	word2 = sys.stdin.readline().rstrip()
	if need_one_swap_to_equal(list(word1), list(word2)):
		print('Yes')
	else:
		print('No')


for k in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	c = 0
	res = []
	for i in range(n):
		if t[i] != s[i]:
			res.append(i)
	if len(res) != 2:
		print('NO')
	elif s[res[0]] == s[res[1]] and t[res[0]] == t[res[1]]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	s = input()
	t = input()
	idx = [-1, -1]
	cnt = 0
	ans = 'YES'
	for i in range(N):
		if s[i] != t[i]:
			if cnt == 2:
				cnt = -1
				ans = 'NO'
				break
			idx[cnt] = i
			cnt += 1
	if cnt == 1:
		ans = 'NO'
	if cnt == 2:
		if s[idx[0]] != s[idx[1]] or t[idx[1]] != t[idx[0]]:
			ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = [*input()]
	l = [*input()]
	p = 0
	y = []
	for i in range(n):
		if l[i] != s[i]:
			p += 1
			y.append(i)
	if p > 2:
		print('No')
	elif p == 0:
		print('Yes')
	elif p == 1:
		print('No')
	else:
		w = l[y[0]]
		l[y[0]] = s[y[0]]
		s[y[0]] = w
		if l == s:
			print('Yes')
		else:
			w = l[y[0]]
			l[y[0]] = s[y[0]]
			s[y[0]] = w
			w = l[y[1]]
			l[y[1]] = s[y[1]]
			s[y[1]] = w
			if l == s:
				print('Yes')
			else:
				w = l[y[1]]
				l[y[1]] = s[y[1]]
				s[y[1]] = w
				w = l[y[1]]
				l[y[1]] = s[y[0]]
				s[y[0]] = w
				if l == s:
					print('Yes')
				else:
					w = l[y[1]]
					l[y[1]] = s[y[0]]
					s[y[0]] = w
					w = l[y[0]]
					l[y[0]] = s[y[1]]
					s[y[1]] = w
					if l == s:
						print('Yes')
					else:
						print('No')


for _ in range(int(input())):
	l = int(input())
	s1 = input()
	s2 = input()
	z = []
	x = []
	y = []
	for i in s1:
		x.append(i)
	for i in s2:
		y.append(i)
	for i in range(len(s1)):
		if x[i] != y[i]:
			z.append(i)
	if len(z) == 1:
		print('No')
	elif len(z) > 2:
		print('No')
	elif x[z[0]] != x[z[1]] or y[z[0]] != y[z[1]]:
		print('No')
	else:
		print('Yes')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	x = [0] * 26
	for j in a:
		x[ord(j) - ord('a')] += 1
	for j in b:
		x[ord(j) - ord('a')] += 1
	f = 1
	for j in x:
		if j % 2 != 0:
			f = 0
	if f:
		x = []
		for j in range(n):
			if a[j] == b[j]:
				continue
			else:
				for k in range(j + 1, n):
					if b[j] == b[k]:
						x.append([j + 1, k + 1])
						(a[j], b[k]) = (b[k], a[j])
						break
				if a[j] == b[j]:
					continue
				else:
					for k in range(j + 1, n):
						if b[j] == a[k]:
							x.append([k + 1, j + 2])
							(a[k], b[j + 1]) = (b[j + 1], a[k])
							x.append([j + 1, j + 2])
							(a[j], b[j + 1]) = (b[j + 1], a[j])
							break
		if len(x) > 2 * n:
			print('here')
		print('YES')
		print(len(x))
		for j in x:
			print(j[0], j[1])
	else:
		print('NO')


results = []
for _ in range(int(input())):
	input()
	s = input()
	t = input()
	ds = []
	dt = []
	for i in range(len(s)):
		if s[i] != t[i]:
			ds.append(s[i])
			dt.append(t[i])
	if len(ds) == 2 and ds[0] == ds[1] and (dt[0] == dt[1]):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	c = 0
	v = []
	x = input()
	y = input()
	for i in range(n):
		if x[i] != y[i]:
			c += 1
			v.append([x[i], y[i]])
	if c == 2 and v[0][0] == v[1][0] and (v[0][1] == v[1][1]) or c == 0:
		print('YES')
	else:
		print('NO')


mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
import random

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		s = sin()
		a = sin()
		s = list(s)
		a = list(a)
		an = 'Yes'
		i = 0
		ans = []
		while i < n:
			if s[i] == a[i]:
				i += 1
				continue
			else:
				c = 0
				for j in range(i + 1, n):
					if s[i] == s[j]:
						ans.append((j + 1, i + 1))
						(s[j], a[i]) = (a[i], s[j])
						c = 1
						break
				if c == 1:
					i += 1
					continue
				for j in range(i + 1, n):
					if a[i] == a[j]:
						ans.append((i + 1, j + 1))
						(s[i], a[j]) = (a[j], s[i])
						c = 1
						break
				if c == 1:
					i += 1
					continue
				for j in range(i + 1, n):
					if s[i] == a[j]:
						ans.append((j + 1, j + 1))
						(s[j], a[j]) = (a[j], s[j])
						c = 1
						break
				if c == 1:
					continue
				else:
					an = 'No'
					break
		print(an)
		if an == 'Yes':
			print(len(ans))
			for i in ans:
				print(*i)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	i = -1
	j = -1
	ans = False
	k = 0
	while k < n:
		if s[k] == t[k]:
			k += 1
			continue
		elif i == -1:
			i = k
		elif j == -1:
			j = k
		else:
			break
		k += 1
	if k < n:
		print('No')
	elif i == -1 or j == -1:
		print('No')
	elif s[i] == s[j] and t[i] == t[j]:
		print('Yes')
	else:
		print('No')


n = int(input())
for i in range(n):
	input()
	str1 = [x for x in input()]
	str2 = [x for x in input()]
	l = [[x, y] for (x, y) in zip(str1, str2) if x != y]
	if len(l) == 2 and l[0][0] == l[1][0] and (l[0][1] == l[1][1]):
		print('Yes')
	else:
		print('No')


k = int(input())

def solve(n, s, t):
	num_different = 0
	indices = []
	for i in range(n):
		if s[i] != t[i]:
			num_different += 1
			indices.append(i)
	if num_different != 2:
		return 'No'
	(i, j) = indices
	if s[i] == s[j] and t[i] == t[j]:
		return 'Yes'
	return 'No'
for case in range(k):
	n = int(input())
	s = input()
	t = input()
	print(solve(n, s, t))


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	kq = 0
	d = 0
	b = []
	for j in range(n):
		if s[j] != t[j]:
			b.append(j)
			d += 1
		if d > 2:
			break
	if d == 0:
		kq = 1
	elif d == 2:
		if s[b[0]] == s[b[1]] and t[b[0]] == t[b[1]]:
			kq = 1
		else:
			kq = 0
	else:
		kq = 0
	if kq == 0:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	k = 0
	c = []
	d = []
	for i in range(len(a)):
		if a[i] != b[i]:
			c.append(a[i])
			d.append(b[i])
			k += 1
	if k == 2 and len(list(set(c))) == 1 and (len(list(set(d))) == 1):
		print('Yes')
	else:
		print('No')


from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import random

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
k = I()
for _ in range(k):
	flg = 'Yes'
	n = I()
	s = StoI()
	t = StoI()
	u = s + t
	c = Counter(u)
	ans = []
	for i in c.items():
		if i[1] % 2 != 0:
			flg = 'No'
			break
	print(flg)
	if flg == 'No':
		continue
	for i in range(n):
		if s[i] == t[i]:
			continue
		else:
			for j in range(n - i - 1):
				scbrk = False
				if s[i + 1 + j] == s[i]:
					(s[i + 1 + j], t[i]) = (t[i], s[i + 1 + j])
					ans.append((1 + i + 1 + j, 1 + i))
					break
				else:
					for k in range(n - i - 1):
						if t[i + 1 + j] == s[i]:
							ans.append((1 + 1 + i, 1 + i + 1 + j))
							(t[i + 1 + j], s[i + 1]) = (s[i + 1], t[i + 1 + j])
							ans.append((1 + 1 + i, 1 + i))
							(t[i], s[1 + i]) = (s[1 + i], t[i])
							scbrk = True
						break
					if scbrk == True:
						break
	show(s, t)
	if len(ans) == 0:
		ans.append((1, 1))
	f = 0
	if s != t or len(ans) > 2 * n:
		show('NG')
		f = 'NG'
	else:
		show('OK??')
	print(len(ans))
	for i in ans:
		print(*i)
	if f == 'NG':
		break


def getInt():
	return int(input())

def getIntArray():
	return [int(x) for x in input().split(' ')]
tc = int(input())
for t in range(tc):
	n = int(input())
	s = input()
	t = input()
	mismatch = 0
	for i in range(n):
		if s[i] != t[i]:
			mismatch += 1
	if mismatch != 0 and mismatch != 2:
		print('No')
		continue
	if mismatch == 0:
		freq = {}
		for i in range(n):
			character = s[i]
			if character in freq.keys():
				freq[character] += 1
			else:
				freq[character] = 1
		flag = False
		for ch in freq.keys():
			if freq[ch] > 1:
				flag = True
		if flag:
			print('Yes')
		else:
			print('No')
	else:
		mis = []
		for i in range(n):
			if s[i] != t[i]:
				mis.append(i)
		if s[mis[0]] == s[mis[1]] and t[mis[1]] == t[mis[0]]:
			print('Yes')
		else:
			print('No')


from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	s1 = list(input())
	count = 0
	hash = defaultdict(int)
	for i in s:
		hash[i] += 1
	for i in s1:
		hash[i] += 1
	flag = 0
	for i in hash:
		if hash[i] % 2 != 0:
			flag = 1
			print('NO')
			break
	if not flag:
		hash = defaultdict(int)
		for i in range(n):
			if s[i] != s1[i]:
				hash[s[i], s1[i]] += 1
		cnt = 0
		for (a, b) in hash:
			if hash[a, b] == 2:
				cnt += 1
			if hash[a, b] % 2 != 0:
				cnt += 1000
		if cnt == 1 or cnt == 0:
			print('YES')
		else:
			print('NO')


k = int(input())
n = o = 0
s = t = ''
for c in range(k):
	n = int(input())
	s = input()
	t = input()
	for l in range(n):
		if s[l] != t[l]:
			if o == 0:
				i = l
			elif o == 1:
				j = l
			else:
				print('No')
				o = 0
				break
			o += 1
	if o == 2:
		if s[i] == s[j] and t[i] == t[j]:
			print('Yes')
		else:
			print('No')
		o = 0
	elif o == 1:
		print('No')


def check(s, t, n):
	l = []
	for i in range(n):
		if s[i] != t[i]:
			l.append(i)
	return l

def equalss(s1, t1, n):
	for i in range(n):
		if s1[i] != t1[i]:
			return False
	return True
for k in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	s1 = [ord(x) for x in s]
	t1 = [ord(x) for x in t]
	if equalss(s1, t1, n) == True:
		print('Yes')
	else:
		ans = check(s1, t1, n)
		if len(ans) == 2:
			(s1[ans[0]], t1[ans[1]]) = (t1[ans[1]], s1[ans[0]])
			if equalss(s1, t1, n):
				print('Yes')
			else:
				print('No')
		else:
			print('No')


n = int(input())
for i in range(n):
	m = int(input())
	s1 = input()
	s2 = input()
	kol = 0
	s = ''
	w = ''
	for j in range(m):
		if s1[j] != s2[j]:
			if kol == 2:
				kol = 3
				break
			elif kol == 1:
				if s1[j] == s and s2[j] == w:
					kol = 2
				else:
					kol = 3
					break
			else:
				s = s1[j]
				w = s2[j]
				kol = 1
	if kol == 2:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	lis = [0] * 2
	lis[0] = list(input())
	lis[1] = list(input())
	ans = []
	gg = 0
	for i in range(n):
		a = lis[0][i]
		ind = -1
		for j in range(i + 1, n):
			if a == lis[0][j]:
				ind = j
				break
		if ind != -1:
			ans.append([ind + 1, i + 1])
			(lis[1][i], lis[0][ind]) = (lis[0][ind], lis[1][i])
		else:
			for j in range(i, n):
				if a == lis[1][j]:
					ind = j
					break
			if ind != -1:
				ans.append([n, ind + 1])
				ans.append([n, i + 1])
				(lis[1][ind], lis[0][n - 1]) = (lis[0][n - 1], lis[1][ind])
				(lis[1][i], lis[0][n - 1]) = (lis[0][n - 1], lis[1][i])
			else:
				print('No')
				gg = 1
				break
	if gg == 0:
		print('Yes')
		print(len(ans))
		for i in range(len(ans)):
			print(*ans[i])


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	n = get_int()
	s = get_string()
	t = get_string()
	lst = []
	for i in range(n):
		if s[i] != t[i]:
			lst.append([s[i], t[i]])
	if len(lst) == 2:
		a = lst[0]
		b = lst[1]
		if a[0] == b[0] and a[1] == b[1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline
k = int(input())
for i in range(k):
	n = int(input())
	freq = [0] * 28
	s = [i for i in input()]
	t = [i for i in input()]
	for i in range(n):
		freq[ord(s[i]) - 97] += 1
		freq[ord(t[i]) - 97] += 1
	ok = True
	for i in range(len(freq)):
		if freq[i] % 2 == 1:
			ok = False
	counter = 0
	swap = []
	for i in range(n):
		if s[i] != t[i]:
			for j in range(i + 1, n):
				if s[i] == s[j]:
					swap.append([j + 1, i + 1])
					(s[j], t[i]) = (t[i], s[j])
					counter += 1
					break
				elif s[i] == t[j]:
					swap.append([j + 1, j + 1])
					swap.append([j + 1, i + 1])
					counter += 2
					(s[j], t[j]) = (t[j], s[j])
					(s[j], t[i]) = (t[i], s[j])
					break
	if ok == False:
		print('No')
	else:
		print('Yes')
		print(counter)
		for i in range(len(swap)):
			print(*swap[i])


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	x = []
	y = []
	for i in range(n):
		if s[i] != t[i]:
			x.append(s[i])
			y.append(t[i])
			c += 1
	if c > 2:
		print('NO')
	if c == 1:
		print('NO')
	if c == 2:
		if x[0] == x[1] and y[0] == y[1]:
			print('YES')
		else:
			print('NO')


q = int(input())
for i in range(q):
	w = int(input())
	e = input()
	r = input()
	ms = []
	for j in range(w):
		if e[j] != r[j]:
			ms.append(j)
	if len(ms) == 0:
		print('Yes')
	elif len(ms) == 2:
		if e[ms[0]] == e[ms[1]] and r[ms[1]] == r[ms[0]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for l in range(t):
	s = int(input())
	a = input()
	b = input()
	mis = 0
	arr = []
	for i in range(s):
		if a[i] != b[i]:
			mis += 1
			arr.append(tuple((a[i], b[i])))
	if mis == 2:
		if arr[0] == arr[1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


k = int(input())
ans = []
for kk in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	dif = '-'
	ind = 0
	err = 0
	for i in range(n):
		if s1[i] != s2[i]:
			if dif == '-':
				dif = s1[i] + s2[i]
			elif dif == s1[i] + s2[i]:
				ind += 1
			else:
				err += 1
	if (dif == '-' or ind == 1) and err == 0:
		ans.append('Yes')
	else:
		ans.append('No')
for kk in range(k):
	print(ans[kk])


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	c = 0
	inda = []
	indb = []
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			inda.append(i)
			indb.append(i)
			if c > 2:
				break
	if c == 0:
		print('Yes')
		continue
	if c == 2 and s[inda[0]] == s[inda[1]] and (t[indb[0]] == t[indb[1]]):
		print('Yes')
	else:
		print('No')


t = int(input())
for j in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	set1 = set()
	set2 = set()
	count = 0
	for i in range(n):
		if s1[i] != s2[i]:
			count = count + 1
			set1.add(s1[i])
			set2.add(s2[i])
	if len(set1) == 1 and len(set2) == 1 and (count == 2):
		print('Yes')
	else:
		print('No')


k = int(input())
while k:
	k -= 1
	n = int(input())
	s = input()
	t = input()
	z = set()
	cnt = 0
	for i in range(n):
		if s[i] != t[i]:
			cnt += 1
			z.add((s[i], t[i]))
	if cnt == 2 and len(z) == 1:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10 ** 9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def LF():
	return list(spf())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def spf():
	return map(int, input.readline().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def iseven(n):
	return n % 2 == 0

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	(ans, a, b) = (0, set(), set())
	for i in range(n):
		if t[i] != s[i]:
			ans += 1
			a.add(t[i])
			b.add(s[i])
	print('Yes' if ans == 0 or (ans == 2 and len(a) == 1 and (len(b) == 1)) else 'No')
endtime = time.time()


import sys, math
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	s.pop()
	t = list(input())
	t.pop()
	c = 0
	q = []
	w = []
	qw = 1
	for j in range(len(s)):
		if s[j] != t[j]:
			c = c + 1
			if c <= 2:
				q.append(s[j])
				w.append(t[j])
			else:
				qw = 0
				break
	if qw == 1:
		if len(q) == 1 and q[0] == w[0]:
			qw = 1
		elif len(q) == 2 and len(set(q)) == 1 and (len(set(w)) == 1):
			qw = 1
		else:
			qw = 0
	if qw == 1:
		print('Yes')
	else:
		print('No')


from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()
k = intput()
for _ in range(k):
	n = intput()
	s = input()
	t = input()
	diffs = []
	for i in range(n):
		if s[i] != t[i]:
			diffs.append(i)
	if len(diffs) == 2:
		if s[diffs[0]] == s[diffs[1]] and t[diffs[1]] == t[diffs[0]]:
			print('Yes')
			continue
	print('No')


for _ in range(int(input())):
	n = int(input())
	fSt = list(input())
	sSt = list(input())
	(flag, res) = (True, [])
	for i in range(n):
		if fSt[i] == sSt[i]:
			continue
		(fP, sP) = (-1, -1)
		for j in range(i + 1, n, 1):
			if fSt[j] != sSt[j] and fP == -1:
				fP = j
			if fSt[i] == sSt[j]:
				sP = j
				break
		if sP == -1:
			for j in range(i + 1, n, 1):
				if fSt[j] == fSt[i]:
					sP = j
					break
			if sP == -1:
				flag = False
				break
			res.append((sP + 1, i + 1))
			(fSt[sP], sSt[i]) = (sSt[i], fSt[sP])
		else:
			if fP == -1:
				fP = i + 1
			(fSt[fP], sSt[sP]) = (sSt[sP], fSt[fP])
			res.append((fP + 1, sP + 1))
			(fSt[fP], sSt[i]) = (sSt[i], fSt[fP])
			res.append((fP + 1, i + 1))
	if flag == False:
		print('No')
	else:
		print('Yes')
		print(len(res))
		for j in range(len(res)):
			print(res[j][0], res[j][1])


k = int(input())
while k:
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	l = [0] * 27
	d = {}
	for i in range(n):
		l[ord(s[i]) - 97] += 1
		l[ord(t[i]) - 97] += 1
	for i in l:
		if i % 2 != 0:
			c = 1
			break
	count = 0
	if c == 1:
		print('No')
	else:
		ans = []
		for i in range(n):
			if s[i] != t[i]:
				for j in range(i + 1, n):
					if t[j] == t[i]:
						t[j] = s[i]
						s[i] = t[i]
						d[i + 1] = 9
						ans.append(i + 1)
						ans.append(j + 1)
						break
				if d.get(i + 1, 0) == 0:
					for j in range(i + 1, n):
						if s[j] == t[i]:
							s[j] = t[i + 1]
							t[i + 1] = t[i]
							ans.append(j + 1)
							ans.append(i + 2)
							t[i + 1] = s[i]
							s[i] = t[i]
							ans.append(i + 1)
							ans.append(i + 2)
							break
		ll = len(ans) // 2
		if ll == 0:
			print('No')
		else:
			print('Yes')
			print(ll)
			m = 0
			for i in range(ll):
				print(ans[m], ans[m + 1], end=' ')
				m += 2
				print()
	k -= 1


k = int(input())
for i in range(k):
	l = int(input())
	s = input()
	t = input()
	d = 0
	sl = []
	tl = []
	for j in range(l):
		if s[j] != t[j]:
			d += 1
			sl.append(s[j])
			tl.append(t[j])
	if d == 0 or (d == 2 and sl[0] == sl[1] and (tl[0] == tl[1])):
		print('Yes')
	else:
		print('No')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(input())
	t = list(input())
	cnt = {}
	for i in range(n):
		if s[i] in cnt:
			cnt[s[i]] = cnt[s[i]] + 1
		else:
			cnt[s[i]] = 1
		if t[i] in cnt:
			cnt[t[i]] = cnt[t[i]] + 1
		else:
			cnt[t[i]] = 1
	flg = 0
	for key in cnt:
		if cnt[key] % 2 == 1:
			flg = 1
			break
	if flg:
		print('NO')
	else:
		m = 0
		sw = []
		for i in range(n):
			if s[i] == t[i]:
				continue
			m = m + 1
			for j in range(i + 1, n):
				if s[i] == s[j] and t[i] == t[j]:
					sw.append([j + 1, i + 1])
					tmp = s[j]
					s[j] = t[i]
					t[i] = tmp
					break
			if m > 1:
				break
		if m > 1:
			print('NO')
		else:
			print('YES')


t = int(input())
while t:
	t = t - 1
	n = int(input())
	s1 = input()
	s2 = input()
	lst1 = list()
	lst2 = list()
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			lst1.append(i)
	if len(lst1) != 2:
		print('No')
	else:
		(x, y) = (lst1[0], lst1[1])
		if s1[x] == s1[y] and s2[y] == s2[x]:
			print('Yes')
		else:
			print('No')


t = int(input())
for z in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	(x, y) = (-1, -1)
	ans = 0
	b = False
	for i in range(n):
		if s1[i] != s2[i]:
			ans += 1
			if ans == 1:
				x = i
			if ans == 2:
				y = i
		if ans > 2:
			print('No')
			b = True
			break
	if b:
		continue
	if s1[x] == s1[y] and s2[x] == s2[y] and (ans == 2):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	t = input()
	li = []
	li2 = []
	for j in range(n):
		if s[j] != t[j]:
			li.append(s[j])
			li2.append(t[j])
	if len(li) != 2:
		print('No')
	elif li[0] == li[1] and li2[1] == li2[0]:
		print('Yes')
	else:
		print('No')


k = int(input())
m = []
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	l = []
	for i in range(n):
		if s[i] != t[i]:
			l.append(i)
	if len(l) != 2:
		m.append('No')
	elif s[l[0]] == s[l[1]] and t[l[0]] == t[l[1]]:
		m.append('Yes')
	else:
		m.append('No')
for i in m:
	print(i)


Q = int(input())
for i in range(Q):
	n = int(input())
	s1 = input()
	s2 = input()
	NE = []
	for i in range(n):
		if s1[i] != s2[i]:
			NE.append(i)
	if len(NE) == 0:
		print('Yes')
	elif len(NE) == 2:
		if s1[NE[0]] == s1[NE[1]] and s2[NE[0]] == s2[NE[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


T = int(input())
for t in range(T):
	N = int(input())
	s = list(input())
	t = list(input())
	i = 0
	possible = True
	res = []
	while i < N:
		if s[i] != t[i]:
			j = i + 1
			found = False
			while j < N:
				if s[i] == s[j]:
					res.append((j, i))
					(s[j], t[i]) = (t[i], s[j])
					found = True
					break
				elif s[i] == t[j]:
					res.append((j, j))
					(s[j], t[j]) = (t[j], s[j])
					res.append((j, i))
					(s[j], t[i]) = (t[i], s[j])
					found = True
					break
				j += 1
			if not found:
				possible = False
				break
		i += 1
	if possible:
		print('Yes')
		print(len(res))
		for (i, j) in res:
			print(i + 1, j + 1)
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = str(input())
	s2 = str(input())
	ls1 = list(s1)
	ls2 = list(s2)
	l1 = []
	l2 = []
	ans = 0
	f = 0
	for i in range(97, 123):
		temp = chr(i)
		c = 0
		for j in range(n):
			if s1[j] == temp:
				c += 1
			if s2[j] == temp:
				c += 1
		if c % 2 != 0:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		for i in range(n):
			if ls1[i] != ls2[i]:
				v = 0
				for j in range(i + 1, n):
					if ls1[i] == ls1[j]:
						l1.append(j + 1)
						l2.append(i + 1)
						ans += 1
						t = ls1[j]
						ls1[j] = ls2[i]
						ls2[i] = t
						v = 1
						break
				if v == 0:
					for j in range(i + 1, n):
						if ls2[j] == ls1[i]:
							ans += 2
							l1.append(j + 1)
							l2.append(j + 1)
							l1.append(j + 1)
							l2.append(i + 1)
							t = ls1[j]
							ls1[j] = ls2[j]
							ls2[j] = t
							t = ls1[j]
							ls1[j] = ls2[i]
							ls2[i] = t
							break
		print('YES')
		print(ans)
		for i in range(ans):
			print(l1[i], l2[i])


k = int(input())
res = []
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	if s == t:
		res.append('Yes')
	else:
		counter = 0
		z = []
		for i in range(n):
			if s[i] != t[i]:
				counter += 1
				z.append(i)
		if counter == 2:
			if s[z[0]] == s[z[1]] and t[z[0]] == t[z[1]]:
				res.append('Yes')
			else:
				res.append('No')
		else:
			res.append('No')
for i in res:
	print(i)


for _ in range(int(input())):
	a = int(input())
	b = input()
	c = input()
	d = 0
	e = []
	for i in range(0, a):
		if b[i] != c[i]:
			d += 1
	if d == 2:
		for i in range(0, a):
			if b[i] != c[i]:
				e.append(i)
		if b[e[0]] == b[e[1]] and c[e[0]] == c[e[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	r = []
	u = []
	for i in range(n):
		if s[i] != t[i]:
			r.append(s[i])
			u.append(t[i])
	if len(r) == 2:
		if r[0] == r[1] and u[0] == u[1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())

def valid(a, b, n):
	firstFound = False
	(fs, ft) = ('', '')
	valid = False
	for c in range(n):
		if a[c] != b[c]:
			if not firstFound:
				firstFound = True
				fs = a[c]
				ft = b[c]
			elif valid:
				return False
			else:
				if a[c] != fs or b[c] != ft:
					return False
				valid = True
	return valid
for i in range(n):
	strLen = int(input())
	a = input()
	b = input()
	if valid(a, b, strLen):
		print('Yes')
	else:
		print('No')


k = int(input().strip())
for _ in range(k):
	n = int(input().strip())
	s = input().strip()
	t = input().strip()
	e = []
	for i in range(n):
		if s[i] != t[i]:
			e.append(i)
		if len(e) > 2:
			e = None
			break
	if e is None:
		print('No')
	elif len(e) == 0:
		print('Yes')
	elif len(e) == 2 and (s[e[0]] == s[e[1]] and t[e[0]] == t[e[1]]):
		print('Yes')
	else:
		print('No')


import math
from decimal import Decimal
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def Factor(n):
	Ans = []
	d = 2
	while d * d <= n:
		if n % d == 0:
			Ans.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		Ans.append(n)
	return Ans

def fact(a, b):
	c = []
	ans = 0
	f = int(math.sqrt(a))
	for i in range(1, f + 1):
		if a % i == 0:
			c.append(i)
	l = len(c)
	for i in range(l):
		c.append(a // c[i])
	for i in range(len(c)):
		if c[i] <= b:
			ans += 1
	if a / f == f and b >= f:
		return ans - 1
	return ans
k = int(input())
for i in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	kol = 0
	ind1 = 0
	ind2 = 0
	for j in range(n):
		if s1[j] != s2[j]:
			if kol == 0:
				ind1 = j
			elif kol == 1:
				ind2 = j
			kol += 1
	if kol == 0:
		if len(set(s1)) != n:
			print('Yes')
		else:
			print('No')
	elif kol > 2:
		print('No')
	else:
		if kol == 1:
			print('No')
			continue
		if s1[ind1] == s1[ind2] and s2[ind2] == s2[ind1]:
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			ind.append(i)
	if len(ind) != 2:
		print('No')
	else:
		a = ind[0]
		b = ind[1]
		if s[a] == s[b] and t[a] == t[b]:
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	c = 0
	p = ''
	q = ''
	for (i, j) in zip(s1, s2):
		if i != j:
			p += i
			q += j
			c += 1
	if c == 2 and p[0] == p[1] and (q[0] == q[1]):
		print('YES')
	else:
		print('NO')


import os, sys
from io import BytesIO, IOBase

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')
BUFSIZE = 8192
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
rstr = lambda : input().strip()
rstrs = lambda : [str(x) for x in input().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint = lambda : int(input())
rints = lambda : [int(x) for x in input().split()]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
for _ in range(rint()):
	(n, s, t) = (rint(), list(rstr()), list(rstr()))
	for i in range(n):
		if s[i] != t[i]:
			for j in range(i + 1, n):
				if s[j] == s[i] and t[i] == t[j]:
					(s[i], t[j]) = (t[j], s[i])
					break
			break
	print('Yes' if s == t else 'No')


from math import *
from collections import *
test = int(input())
for y in range(test):
	n = int(input())
	s = list(input())
	t = list(input())
	ans = []
	for i in range(n):
		if s[i] != t[i]:
			ans.append(i)
	if len(ans) == 2 or len(ans) == 0:
		if s[ans[0]] == s[ans[1]] and t[ans[0]] == t[ans[1]]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


tests_count = int(input())
for test in range(tests_count):
	words_len = int(input())
	(word1, word2) = (list(input()), list(input()))
	if word1 == word2:
		print('Yes')
	else:
		differs = []
		for i in range(words_len):
			if word1[i] != word2[i]:
				differs.append(i)
		if len(differs) != 2:
			print('No')
		else:
			(i, j) = differs
			(word1[i], word2[j]) = (word2[j], word1[i])
			if word1 == word2:
				print('Yes')
			else:
				print('No')


tc = int(input())
for _ in range(tc):
	n = int(input())
	st1 = list(input())
	st2 = list(input())
	l = []
	for i in range(n):
		if st2[i] != st1[i]:
			l.append(st2[i])
			l.append(st1[i])
	if len(l) == 4 and len(set(l)) == 2 and (l[0] == l[2]) and (l[1] == l[3]):
		print('yes')
	else:
		print('no')


import sys
import math
import itertools
import collections

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
k = ii()
for _ in range(k):
	n = ii()
	s = input()
	t = input()
	p = []
	c = 0
	for i in range(n):
		if s[i] != t[i]:
			p.append([s[i], t[i]])
			c += 1
	if c == 0 or (c == 2 and p[0] == p[1]):
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	diff = []
	for j in range(n):
		if s[j] != t[j]:
			diff.append(j)
	if len(diff) > 2 or len(diff) < 2:
		print('No')
	elif s[diff[0]] == s[diff[1]] and t[diff[0]] == t[diff[1]]:
		print('Yes')
	else:
		print('No')


n = int(input())
for i in range(n):
	l = int(input())
	str1 = input()
	str2 = input()
	d = 0
	dlist = []
	for j in range(l):
		if str1[j] != str2[j]:
			d += 1
			dlist.append(j)
	if d == 0:
		print('Yes')
	elif d == 1 or d >= 3:
		print('No')
	elif str1[dlist[0]] == str1[dlist[1]] and str2[dlist[0]] == str2[dlist[1]]:
		print('Yes')
	else:
		print('No')


for rpt in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	fn1 = []
	fn2 = []
	for i in range(n):
		fn1.append(s[i])
		fn2.append(t[i])
	s = fn1
	t = fn2
	res = []
	for i in range(n):
		if not s[i] == t[i]:
			if i + 1 == n:
				res = False
				break
			else:
				done = False
				for k in range(i + 1, n):
					if s[i] == t[k]:
						res.append((n, k + 1))
						res.append((n, i + 1))
						fn = t[k]
						t[k] = s[n - 1]
						s[n - 1] = t[i]
						s[i] = fn
						done = True
						break
					if s[i] == s[k]:
						res.append((k + 1, i + 1))
						fn = s[k]
						s[k] = t[i]
						t[i] = fn
						done = True
						break
				if done == False:
					res = False
					break
	if res == False:
		print('No')
	else:
		print('Yes')
		print(len(res))
		for i in res:
			print(str(i[0]) + ' ' + str(i[1]))


t = int(input())
for test_cases in range(t):
	n = int(input())
	a = input()
	b = input()
	idx = []
	for i in range(n):
		if a[i] != b[i]:
			idx.append(i)
	idx_len = len(idx)
	if idx_len > 2 or idx_len == 1:
		print('No')
		continue
	if idx_len == 0:
		print('Yes')
		continue
	(idx1, idx2) = (idx[0], idx[1])
	if b[idx1] == b[idx2] and a[idx1] == a[idx2]:
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	s1 = input()
	diff = 0
	a = []
	for i in range(n):
		if s[i] != s1[i]:
			diff += 1
			a.append(i)
	if diff != 2:
		print('No')
		continue
	p = list(s)
	q = list(s1)
	(p[a[0]], q[a[1]]) = (q[a[1]], p[a[0]])
	if p == q:
		print('Yes')
		continue
	p = list(s)
	q = list(s1)
	(p[a[1]], q[a[0]]) = (q[a[0]], p[a[1]])
	if p == q:
		print('Yes')
		continue
	print('No')


import sys
for _ in range(int(input())):
	n = int(input())
	arr1 = input()
	arr2 = input()
	(ara, arb) = ([], [])
	coun = 0
	flag = 'No'
	for i in range(n):
		if arr1[i] != arr2[i]:
			coun += 1
			ara.append(arr1[i])
			arb.append(arr2[i])
	if coun == 2:
		if len(set(ara)) == len(set(arb)) == 1:
			flag = 'Yes'
	elif coun == 0:
		flag = 'Yes'
	print(flag)


for T in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	if s == t:
		print('Yes')
		continue
	pos = []
	for i in range(n):
		if s[i] != t[i]:
			pos.append(i)
		if len(pos) >= 2:
			break
	if len(pos) == 1:
		print('No')
	elif len(pos) == 2:
		fir = pos[0]
		sec = pos[1]
		temp = s[fir]
		s[fir] = t[sec]
		t[sec] = temp
		if t == s:
			print('Yes')
		else:
			print('No')


def f(s1, s2):
	c = 0
	for j in range(len(s1)):
		if s1[j] != s2[j]:
			c += 1
		if c == 3:
			return 3
	if c == 1:
		return 1
	return 2

def ind(s1, s2):
	u = []
	for z in range(len(s1)):
		if s1[z] != s2[z]:
			u.append(z)
	return u
k = int(input())
need = []
for q in range(k):
	w = int(input())
	s = list(input())
	t = list(input())
	if f(s, t) == 2:
		if s[ind(s, t)[0]] == s[ind(s, t)[1]] and t[ind(s, t)[1]] == t[ind(s, t)[0]]:
			need.append('Yes')
		else:
			need.append('No')
	else:
		need.append('No')
for g in range(len(need)):
	print(need[g])


import re
for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	difa = []
	difb = []
	diffS = 0
	for i in range(0, n):
		if a[i] == b[i]:
			continue
		difa += [a[i]]
		difb += [b[i]]
		diffS += 1
		if diffS > 2:
			break
	if diffS < 2 or diffS > 2:
		print('No')
	elif difa[0] == difa[1] and difb[0] == difb[1] and (diffS == 2):
		print('Yes')
	else:
		print('No')


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import os
import sys
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for i in range(test):
	n = int_input()
	string1 = string_input()
	string2 = string_input()
	temp = []
	count = 0
	for i in range(n):
		if string1[i] != string2[i]:
			temp.append(i)
			count += 1
	if count == 2 and (string1[temp[0]] == string1[temp[1]] and string2[temp[1]] == string2[temp[0]]):
		print('Yes')
	else:
		print('No')


for k in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	(s1, t1) = ('', '')
	for x in range(n):
		if s[x] != t[x]:
			s1 += s[x]
			t1 += t[x]
	if len(s1) == len(t1) == 2 and s1[0] == s1[1] and (t1[0] == t1[1]):
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	arr = []
	l = 0
	for j in range(n):
		if s[j] != t[j]:
			l = l + 1
			arr.append(s[j])
			arr.append(t[j])
	if l == 2:
		if arr[0] == arr[2] and arr[1] == arr[3]:
			print('yes')
		else:
			print('no')
	else:
		print('no')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
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')
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	c1 = -1
	c2 = -1
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			if c1 != -1 and c2 == -1:
				c2 = i
			if c1 == -1:
				c1 = i
	if c != 0 and c != 2:
		print('No')
	elif c == 0:
		print('Yes')
	elif s[c1] == s[c2] and t[c1] == t[c2]:
		print('Yes')
	else:
		print('No')


m = int(input())
for i in range(0, m):
	length = int(input())
	str1 = input()
	str2 = input()
	list10 = list(str1)
	list20 = list(str2)
	zz = list10[:]
	zz.extend(list20)
	nlist = []
	klist = []
	for k in zz:
		if (k in klist) == False:
			number = zz.count(k)
			nlist.append(number)
			klist.append(k)
			if number % 2 != 0:
				print('No')
				break
	if number % 2 == 0:
		print('Yes')
		operation = 0
		list1 = []
		list2 = []
		for z in range(0, length - 1):
			if str1[z] != str2[z]:
				d = str2.find(str2[z], z + 1)
				if d != -1:
					(list20[d], list10[z]) = (list10[z], list20[d])
					str1 = ''.join(list10)
					str2 = ''.join(list20)
					operation += 1
					list1.append(z + 1)
					list2.append(d + 1)
				else:
					d = str1.find(str2[z], z + 1)
					(list20[length - 1], list10[d]) = (list10[d], list20[length - 1])
					(list20[length - 1], list10[z]) = (list10[z], list20[length - 1])
					operation += 2
					str1 = ''.join(list10)
					str2 = ''.join(list20)
					list1.extend([d + 1, z + 1])
					list2.extend([length, length])
		print(operation)
		for j in range(operation):
			print(list1[j], end=' ')
			print(list2[j])


k = int(input())
for ki in range(k):
	n = int(input())
	s = input()
	t = input()
	count = 0
	a = []
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			a.append([s[i], t[i]])
	if count == 2:
		if a[0][0] == a[1][0] and a[0][1] == a[1][1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
while t > 0:
	n = int(input())
	a = input()
	b = input()
	pos = []
	i = 0
	while i < n:
		if a[i] != b[i]:
			pos.append(i)
		i += 1
	if len(pos) != 2:
		print('No')
	elif a[pos[0]] == a[pos[1]] and b[pos[0]] == b[pos[1]] and (a[pos[0]] + a[pos[0]] != b[pos[0]] + b[pos[0]]):
		print('Yes')
	else:
		print('No')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	c = 0
	S = []
	T = []
	for i in range(n):
		if s[i] != t[i]:
			S.append(s[i])
			T.append(t[i])
			c += 1
	if len(set(T)) == 1 and c == 2 and (len(set(S)) == 1):
		print('YES')
	elif c == 0:
		print('YES')
	else:
		print('NO')


import string
results = []
for _ in range(int(input())):
	d = dict.fromkeys(string.ascii_lowercase, 0)
	input()
	s = input().rstrip('\n')
	t = input().rstrip('\n')
	ds = []
	dt = []
	diff = 0
	for i in range(len(s)):
		d[s[i]] += 1
		d[t[i]] += 1
		if s[i] != t[i]:
			diff += 1
	no = False
	for i in d.values():
		if i != 0 and i % 2 != 0:
			no = True
			break
	if no:
		results.append(False)
		continue
	resultss = []
	while diff > 0 and len(resultss) < 2 * len(s):
		for i in range(len(s)):
			if s[i] != t[i]:
				swapped = False
				for j in range(i + 1, len(s)):
					if s[j] != t[j] and s[i] == s[j] and (t[i] == t[j]):
						tmp = s[i]
						s = s[:i] + t[j] + s[i + 1:]
						t = t[:j] + tmp + t[j + 1:]
						diff -= 2
						swapped = True
						resultss.append((i + 1, j + 1))
						break
				if swapped == False:
					for j in range(i + 1, len(s)):
						if s[j] != t[j] and (s[i] == s[j] or t[i] == t[j]):
							tmp = s[i]
							s = s[:i] + t[j] + s[i + 1:]
							t = t[:j] + tmp + t[j + 1:]
							diff -= 1
							swapped = True
							resultss.append((i + 1, j + 1))
							break
				if swapped == False:
					tmp = s[i]
					s = s[:i] + t[i] + s[i + 1:]
					t = t[:i] + tmp + t[i + 1:]
					resultss.append((i + 1, i + 1))
					break
	if diff > 0:
		results.append(False)
	else:
		results.append(resultss)
for i in results:
	if i == False:
		print('No')
	else:
		print('Yes')
		print(len(i))
		for j in i:
			print(str(j[0]) + ' ' + str(j[1]))


for _ in range(int(input())):
	n = int(input())
	s = [char for char in input()]
	t = [char for char in input()]
	countChar = [0] * 27
	for i in range(n):
		countChar[ord(s[i]) - 97] += 1
		countChar[ord(t[i]) - 97] += 1
	for i in countChar:
		if i % 2 != 0:
			print('No')
			break
	else:
		print('Yes')
		ans = []
		for i in range(n):
			if s[i] != t[i]:
				for j in range(i + 1, n):
					if s[i] == s[j]:
						(s[j], t[i]) = (t[i], s[j])
						ans.append((j + 1, i + 1))
						break
					elif s[i] == t[j]:
						(s[j], t[j]) = (t[j], s[j])
						(s[j], t[i]) = (t[i], s[j])
						ans.append((j + 1, j + 1))
						ans.append((j + 1, i + 1))
						break
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


import collections

def solve(n, s, t):
	d = collections.defaultdict(int)
	for i in range(n):
		d[s[i]] += 1
		d[t[i]] += 1
	for k in d.keys():
		if d[k] % 2 == 1:
			print('No')
			return
	swap = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		for j in range(i + 1, n):
			if s[j] == s[i]:
				swap.append([j, i])
				(s[j], t[i]) = (t[i], s[j])
				break
			elif t[j] == s[i]:
				swap.append([j, j])
				swap.append([j, i])
				(s[j], t[j]) = (t[j], s[j])
				(s[j], t[i]) = (t[i], s[j])
				break
	print('Yes')
	print(len(swap))
	for (a, b) in swap:
		print(a + 1, b + 1)
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	solve(n, s, t)


k = int(input())
while k:
	k -= 1
	n = int(input())
	ss = input()
	tt = input()
	s = []
	t = []
	for i in range(n):
		s.append(ss[i])
		t.append(tt[i])
	count = 0
	ans = []
	ch = 0
	for i in range(n):
		if s[i] != t[i]:
			check = 0
			for j in range(i + 1, n):
				if s[j] == s[i]:
					count += 1
					(s[j], t[i]) = (t[i], s[j])
					ans.append([j + 1, i + 1])
					check = 1
					break
			if check == 0:
				for j in range(i + 1, n):
					if t[j] == s[i]:
						check = 1
						count += 2
						(s[j], t[j]) = (t[j], s[j])
						ans.append([j + 1, j + 1])
						(s[j], t[i]) = (t[i], s[j])
						ans.append([j + 1, i + 1])
						break
			if check == 0:
				ch = 1
				break
	if ch:
		print('No')
	elif count > 2 * n:
		print('No')
	else:
		print('Yes')
		print(count)
		for i in ans:
			print(*i)


from collections import Counter
from collections import defaultdict
import math
g = int(input())
for _ in range(0, g):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	c = 0
	l = list()
	f = 1
	for i in range(0, n):
		if f == 0:
			break
		if s1[i] != s2[i]:
			c = c + 1
			f = 0
			for j in range(i + 1, n):
				if s1[i] == s2[j]:
					f = 1
					l.append([i + 1, j])
					l.append([i + 1, i])
					t = s1[i + 1]
					s1[i + 1] = s2[j]
					s2[j] = t
					t = s1[i + 1]
					s1[i + 1] = s2[i]
					s2[i] = t
					break
				elif s1[i] == s1[j]:
					f = 1
					l.append([j, i])
					t = s1[j]
					s1[j] = s2[i]
					s2[i] = t
					break
	if f == 1:
		print('Yes')
		print(len(l))
		for (i, j) in l:
			print(i + 1, j + 1)
	else:
		print('No')


import sys

def read_numbers():
	return [int(x) for x in sys.stdin.readline()[:-1].split(' ')]

def read_str():
	return sys.stdin.readline()[:-1]

def test_case():
	str_len = read_numbers()[0]
	str_a = list(read_str())
	str_b = list(read_str())
	not_common_a = list()
	not_common_b = list()
	for i in range(str_len):
		if str_a[i] != str_b[i]:
			not_common_a.append(str_a[i])
			not_common_b.append(str_b[i])
		if len(not_common_a) > 2:
			return False
	if len(not_common_a) != 2:
		return False
	return not_common_a[0] == not_common_a[1] and not_common_b[0] == not_common_b[1]

def main():
	test_cases = read_numbers()[0]
	for i in range(test_cases):
		print('Yes' if test_case() else 'No')
main()


for _ in range(int(input())):
	a = input()
	b = input()
	c = input()
	ans = set()
	count = 0
	for (i, j) in zip(b, c):
		if i != j:
			count += 1
			ans.add((i, j))
	print(['No', 'Yes'][count == 2 and len(ans) == 1])


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	changed_pairs = []
	changes = 0
	for i in range(n):
		if s[i] != t[i]:
			changes += 1
			changed_pairs.append(s[i] + t[i])
		if changes > 2:
			break
	if changes == 0 or (changes == 2 and changed_pairs[0] == changed_pairs[1]):
		print('Yes')
	else:
		print('No')


def solve(s1, s2, n):
	if s1 == s2:
		return 'Yes'
	num_diff = 0
	(d1, d2) = (set(), set())
	for i in range(n):
		if s1[i] != s2[i]:
			num_diff += 1
			d1.add(s1[i])
			d2.add(s2[i])
			if num_diff > 2:
				return 'No'
	if num_diff == 2 and len(d1) == 1 and (len(d2) == 1):
		return 'Yes'
	return 'No'
for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	print(solve(s1, s2, n))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	c = dict()
	for j in range(n):
		if ord(a[j]) - 97 in c.keys():
			c[ord(a[j]) - 97] += 1
		else:
			c[ord(a[j]) - 97] = 1
		if ord(b[j]) - 97 in c.keys():
			c[ord(b[j]) - 97] += 1
		else:
			c[ord(b[j]) - 97] = 1
	p = 0
	for j in range(n):
		if c[ord(a[j]) - 97] % 2 != 0:
			p = 1
			break
		if c[ord(b[j]) - 97] % 2 != 0:
			p = 1
			break
	if p == 1:
		print('No')
	else:
		d = []
		e = []
		f = []
		for j in a:
			e.append(j)
		for j in b:
			f.append(j)
		a = e.copy()
		b = f.copy()
		for i in range(n):
			if a[i] == b[i]:
				pass
			else:
				for j in range(i + 1, n):
					if a[j] == a[i]:
						d.append([j + 1, i + 1])
						e = a[j]
						a[j] = b[i]
						b[i] = e
						break
					elif b[j] == a[i]:
						d.append([j + 1, j + 1])
						e = a[j]
						a[j] = b[j]
						b[j] = e
						d.append([j + 1, i + 1])
						e = a[j]
						a[j] = b[i]
						b[i] = e
						break
		print('Yes')
		print(len(d))
		for p in d:
			print(*p)


repeat = int(input())
answer = []
for _ in range(repeat):
	n = input()
	first = input()
	second = input()
	a = first
	b = second
	for i in range(len(first)):
		if first[i] != second[i]:
			for j in range(i, len(second)):
				a = first[:i] + second[j] + first[i + 1:]
				b = second[:j] + first[i] + second[j + 1:]
				if a == b:
					answer.append('Yes')
					a = True
					break
				if a != b:
					if j == len(second) - 1:
						answer.append('No')
						a = True
						break
					continue
			if a:
				break
for n in range(repeat):
	print(answer[n])


k = int(input())
a = []
for i in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	(ms, mt, c, cm) = ([], [], 0, [])
	for x in s:
		ms.append(x)
	for x in t:
		mt.append(x)
	for i in range(n):
		if ms[i] != mt[i]:
			c += 1
			cm.append(i)
	if c == 2 and ms[cm[0]] == ms[cm[1]] and (mt[cm[0]] == mt[cm[1]]):
		a.append('YES')
	else:
		a.append('NO')
for x in a:
	print(x)


k = int(input())
for i in range(k):
	ind_f = 0
	ind_s = 0
	c = 0
	n = int(input())
	s = input()
	t = input()
	for j in range(n):
		if s[j] != t[j]:
			ind_s = ind_f
			ind_f = j
			c += 1
	if c > 2:
		print('NO')
	elif c == 1:
		print('NO')
	elif c == 2:
		if s[ind_s] == s[ind_f] and t[ind_f] == t[ind_s]:
			print('YES')
		else:
			print('NO')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for i in range(inp()):
	n = inp()
	s = input()
	t = input()
	cnt = 0
	li = []
	for i in range(n):
		if s[i] != t[i]:
			li.append(i)
			cnt += 1
	if cnt == 0:
		if len(set(s)) == n:
			print('No')
		else:
			print('Yes')
	elif cnt == 2:
		(a, b) = li
		if s[a] == s[b] and t[a] == t[b]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


q = int(input())
for _ in range(q):
	n = int(input())
	s1 = input()
	s2 = input()
	(dp1, dp2) = ([], [])
	i = 0
	while i < len(s1):
		if s1[i] != s2[i]:
			dp1.append(s1[i])
			dp2.append(s2[i])
		i += 1
	if len(dp1) != 2:
		print('No')
	elif dp1[0] == dp1[1] and dp2[0] == dp2[1]:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	if a == b:
		print('Yes')
	else:
		c = 0
		d = []
		e = []
		for j in range(n):
			if a[j] == b[j]:
				c = c + 1
			else:
				d.append(a[j])
				e.append(b[j])
		if c == n - 2:
			if d[0] == d[1] and e[0] == e[1]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


for i in range(int(input())):
	size = int(input())
	first = list(input())
	second = list(input())
	arr = []
	for i in range(size):
		if first[i] != second[i]:
			arr.append(i)
	if len(arr) == 2:
		(first[arr[0]], second[arr[1]]) = (second[arr[1]], first[arr[0]])
		if first == second:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	k = int(input())
	s = input()
	t = input()
	sum = 0
	(a, b, c, d) = ('', '', '', '')
	for x in range(k):
		if s[x] != t[x]:
			sum += 1
			if sum == 1:
				a = s[x]
				b = t[x]
			elif sum == 2:
				c = s[x]
				d = t[x]
	if sum > 2:
		print('NO')
	elif a == c and b == d:
		print('YES')
	else:
		print('NO')


k = int(input())
for p in range(k):
	b = []
	b.clear()
	c = 0
	f = 0
	n = int(input())
	s = input()
	t = input()
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			if c == 3:
				break
			b.append(s[i])
			b.append(t[i])
		if c >= 3:
			break
	if c == 2 and (b[0] == b[1] and b[2] == b[3] or (b[0] == b[2] and b[1] == b[3])):
		print('Yes')
	else:
		print('No')


n = int(input())
for i in range(n):
	s = int(input())
	w = input()
	x = input()
	b = []
	for j in range(len(w)):
		if w[j] != x[j]:
			b.append(w[j])
			b.append(x[j])
	if len(b) == 4:
		if b[0] == b[2] and b[1] == b[3]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	num = 0
	index = []
	for i in range(n):
		if s[i] != t[i]:
			num += 1
			index.append(i)
		else:
			continue
	if num != 2:
		print('No')
	elif s[index[0]] == s[index[1]] and t[index[0]] == t[index[1]]:
		print('Yes')
	else:
		print('No')


from collections import Counter
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	S1 = list(input())
	S2 = list(input())
	Query.append((N, S1, S2))
for (N, S1, S2) in Query:
	C = Counter(S1 + S2)
	ok = True
	for v in C.values():
		if v % 2 != 0:
			ok = False
	if not ok:
		print('No')
	else:
		print('Yes')
		ans = []
		for i in range(N):
			(s1, s2) = (S1[i], S2[i])
			if s1 != s2:
				for j in range(i + 1, N):
					if S1[j] == S2[j]:
						continue
					if S1[j] == s1:
						ans.append((j + 1, i + 1))
						S1[j] = s2
						break
					elif S2[j] == s1:
						ans.append((j + 1, j + 1))
						ans.append((j + 1, i + 1))
						S2[j] = S1[j]
						S1[j] = s2
						break
		print(len(ans))
		for (a, b) in ans:
			print(a, b)


for _ in range(int(input())):
	n = int(input())
	na = list(input())
	nb = list(input())
	k = 0
	zz = len(na)
	ans = []
	for i in range(zz):
		f = 0
		if na[i] == nb[i]:
			f = 1
		if not f:
			for j in range(i + 1, zz):
				if na[j] == na[i]:
					ans.append((j + 1, i + 1))
					na[j] = nb[i]
					f = 1
					break
		if not f:
			for j in range(i + 1, zz):
				if na[i] == nb[j]:
					ans.append((j + 1, j + 1))
					ans.append((j + 1, i + 1))
					nb[j] = na[j]
					na[j] = nb[i]
					f = 1
					break
		if not f:
			k = 1
			break
	if k:
		print('NO')
	else:
		print('YES')
		print(len(ans))
		for t in ans:
			print(t[0], t[1])


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	r = input()
	ch = 0
	ans = []
	for i in range(len(s)):
		if s[i] != r[i]:
			ans.append(i)
			ch += 1
	if ch > 2:
		print('No')
	elif ch == 1:
		(x, y) = ('', '')
		for i in range(len(s)):
			if i == ans[0]:
				x += r[i]
			else:
				x += s[i]
		for i in range(len(r)):
			if i == ans[0]:
				y += s[i]
			else:
				y += r[i]
		if x == y:
			print('Yes')
		else:
			print('No')
	else:
		(x, y) = ('', '')
		for i in range(len(s)):
			if i == ans[0]:
				x += r[ans[1]]
				y += r[i]
			elif i == ans[1]:
				x += s[i]
				y += s[ans[0]]
			else:
				x += s[i]
				y += r[i]
		flag = 0
		if x == y:
			flag = 1
		if flag == 0:
			(x, y) = ('', '')
			for i in range(len(s)):
				if i == ans[0]:
					x += s[ans[1]]
					y += s[i]
				elif i == ans[1]:
					x += r[i]
					y += r[ans[0]]
				else:
					x += s[i]
					y += r[i]
		if x == y:
			flag = 1
		if flag:
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	d = []
	for i in range(n):
		if a[i] != b[i]:
			d += (i,)
			if len(d) > 2:
				print('No')
				break
	else:
		if d:
			if len(d) == 1:
				print('No')
			else:
				(x, y) = d
				print('Yes' if a[x] == a[y] and b[x] == b[y] else 'No')
		else:
			print('Yes')


for k in range(int(input())):
	n = int(input())
	s = str(input())
	t = str(input())
	differ_type1 = ''
	differ_type2 = ''
	dif = 0
	for i in range(len(s)):
		if s[i] != t[i]:
			if dif == 0:
				differ_type1 = s[i] + t[i]
				dif += 1
				continue
			if dif == 1:
				differ_type2 = s[i] + t[i]
				if differ_type2 != differ_type1:
					break
				dif += 1
				continue
			dif += 1
			break
	if dif == 0 or dif == 2:
		print('Yes')
	else:
		print('No')


def solve(s, t, n):
	diff = []
	for i in range(n):
		if s[i] != t[i]:
			diff.append((s[i], t[i]))
	if len(diff) not in [0, 2]:
		print('No')
		return
	if len(diff) == 0:
		print('Yes')
		return
	if diff[0] == diff[1]:
		print('Yes')
		return
	print('No')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		t = input()
		solve(s, t, n)
main()


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	r = [[x, y] for (x, y) in zip(a, b) if x != y]
	ans = len(r) == 0
	if len(r) == 2:
		ans = r[0] == r[1]
	print('Yes' if ans else 'No')


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

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

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	n = int(input())
	q = [0] * 26
	ss = list(input())
	tt = list(input())
	ans = []
	dd = len(ss)
	se = [0] * dd
	for i in range(n):
		if ss[i] != tt[i]:
			for j in range(i + 1, n):
				if ss[i] == ss[j]:
					(tt[i], ss[j]) = (ss[j], tt[i])
					ans.append([j + 1, i + 1])
					break
				if ss[i] == tt[j]:
					(tt[j], ss[j]) = (ss[j], tt[j])
					ans.append([j + 1, j + 1])
					(tt[i], ss[j]) = (ss[j], tt[i])
					ans.append([j + 1, i + 1])
					break
	if ss == tt:
		print('Yes')
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print('No')


import sys
input = lambda : sys.stdin.readline().rstrip()
k = int(input())
for _ in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	isYes = False
	k = 0
	w_li = []
	while len(w_li) != 2 and k != n:
		if s[k] != t[k]:
			w_li.append(k)
		k += 1
	for i in w_li:
		for j in w_li:
			(s[i], t[j]) = (t[j], s[i])
			if s == t:
				isYes = True
				break
			(s[i], t[j]) = (t[j], s[i])
		if isYes:
			break
	if isYes:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	count = 0
	flag = 0
	list_i = []
	list_j = []
	for i in range(n):
		if s[i] != t[i]:
			if count <= 2:
				list_i.append(i)
				list_j.append(i)
			else:
				flag = 1
				break
			count += 1
	if flag == 1 or count < 2:
		print('No')
	else:
		s1 = s[:]
		t1 = t[:]
		s2 = s[:]
		t2 = t[:]
		temp = s1[list_j[0]]
		s1[list_j[0]] = t1[list_j[1]]
		t1[list_j[1]] = temp
		temp = s2[list_j[1]]
		s2[list_j[1]] = t2[list_j[0]]
		t2[list_j[0]] = temp
		if s1 == t1 or s2 == t2:
			print('Yes')
		else:
			print('No')


k = int(input())
for tt in range(k):
	n = int(input())
	s = input().strip()
	t = input().strip()
	f = [0] * 26
	arr = []
	brr = []
	for i in s:
		arr.append(i)
	for i in t:
		brr.append(i)
	pos1 = []
	pos2 = []
	for i in range(len(s)):
		if s[i] != t[i]:
			pos1.append(i)
			pos2.append(i)
			f[ord(s[i]) - ord('a')] += 1
			f[ord(t[i]) - ord('a')] += 1
	flag = True
	for i in range(26):
		if f[i] % 2 == 1:
			flag = False
			break
	if not flag:
		print('No')
		continue
	ans = []
	i = 0
	j = 0
	while i < len(pos1) and j < len(pos2):
		fl = False
		for ii in range(i + 1, len(pos1)):
			if arr[pos1[i]] == arr[pos1[ii]]:
				ans.append([pos1[ii], pos2[j]])
				temp = arr[pos1[ii]]
				arr[pos1[ii]] = brr[pos2[j]]
				brr[pos2[j]] = temp
				fl = True
				break
		if fl:
			i += 1
			j += 1
			continue
		for ii in range(j + 1, len(pos2)):
			if brr[pos2[j]] == brr[pos2[ii]]:
				ans.append([pos1[i], pos2[ii]])
				temp = arr[pos1[i]]
				arr[pos1[i]] = brr[pos2[ii]]
				brr[pos2[ii]] = temp
				fl = True
				break
		if fl:
			i += 1
			j += 1
			continue
		ans.append([pos1[i], pos2[j]])
		temp = arr[pos1[i]]
		arr[pos1[i]] = brr[pos2[j]]
		brr[pos2[j]] = temp
		fl = False
		for jj in range(j + 1, len(pos2)):
			if brr[pos2[jj]] == brr[pos2[j]]:
				temp = brr[pos2[jj]]
				brr[pos2[jj]] = arr[pos1[i]]
				arr[pos1[i]] = temp
				ans.append([pos1[i], pos2[jj]])
				fl = True
				break
		if not fl:
			ans.pop()
			temp = arr[pos1[i]]
			arr[pos1[i]] = brr[pos2[j]]
			brr[pos2[j]] = temp
			for jj in range(j + 1, len(pos2)):
				if brr[pos2[jj]] == brr[pos2[j]]:
					temp = brr[pos2[jj]]
					brr[pos2[jj]] = arr[pos1[i]]
					arr[pos1[i]] = temp
					ans.append([pos1[i], pos2[jj]])
					break
		i += 1
		j += 1
	fl = True
	for i in range(len(arr)):
		if arr[i] != brr[i]:
			fl = False
			break
	if not fl:
		print(s + t)
		continue
	print('Yes')
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0] + 1, ans[i][1] + 1)


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	dic = {}
	flag = 0
	for i in range(n):
		if s[i] in dic:
			dic[s[i]] += 1
		else:
			dic[s[i]] = 1
		if t[i] in dic:
			dic[t[i]] += 1
		else:
			dic[t[i]] = 1
	for (key, value) in dic.items():
		if value % 2 != 0:
			flag = 1
	if flag == 1:
		print('No')
	else:
		swap = []
		i = 0
		while i < n:
			if s[i] == t[i]:
				i += 1
			else:
				for j in range(i + 1, n):
					if s[j] == s[i]:
						(t[i], s[j]) = (s[j], t[i])
						swap.append((j + 1, i + 1))
						i += 1
						break
				else:
					for j in range(i + 1, n):
						if t[j] == s[i]:
							(t[j], s[j]) = (s[j], t[j])
							swap.append((j + 1, j + 1))
							break
		if s == t and len(swap) <= 2 * n:
			print('Yes')
			print(len(swap))
			for (x, y) in swap:
				print(x, y)
		else:
			print('No')


from math import inf as inf
from math import *
from collections import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = input().rstrip('\n')
	b = input().rstrip('\n')
	a = list(a)
	b = list(b)
	f = {chr(97 + i): set() for i in range(26)}
	f1 = {chr(97 + i): set() for i in range(26)}
	ff = 0
	c = 0
	for i in a:
		f[i].add(c)
		c += 1
	c = 0
	for i in b:
		f1[i].add(c)
		c += 1
	for i in f.keys():
		if (len(f1[i]) + len(f[i])) % 2:
			print('No')
			ff = 1
			break
	if ff:
		continue
	print('Yes')
	r = []
	for i in range(n):
		if a[i] == b[i]:
			f[a[i]].remove(i)
			f1[a[i]].remove(i)
			continue
		if len(f[a[i]]) > 1:
			for i1 in f[a[i]]:
				if i1 != i:
					ind1 = i1
					break
			r.append([ind1 + 1, i + 1])
			f1[b[i]].remove(i)
			f[a[i]].remove(ind1)
			f[b[i]].add(ind1)
			f1[a[i]].add(i)
			(b[i], a[ind1]) = (a[ind1], b[i])
		elif len(f1[b[i]]) > 1:
			for i1 in f1[b[i]]:
				if i1 != i:
					ind1 = i1
					break
			r.append([i + 1, ind1 + 1])
			f1[b[i]].remove(ind1)
			f[a[i]].remove(i)
			f1[a[i]].add(ind1)
			(a[i], b[ind1]) = (b[ind1], a[i])
		elif len(f[a[i]]) <= 1:
			for i1 in f1[a[i]]:
				ind1 = i1
				break
			r.append([i + 2, ind1 + 1])
			f[a[i + 1]].remove(i + 1)
			f1[a[i]].remove(ind1)
			f1[a[i + 1]].add(ind1)
			f[a[i]].add(i + 1)
			(a[i + 1], b[ind1]) = (b[ind1], a[i + 1])
			r.append([i + 2, i + 1])
			f1[b[i]].remove(i)
			f[a[i + 1]].remove(i + 1)
			f[b[i]].add(i + 1)
			(a[i + 1], b[i]) = (b[i], a[i + 1])
		else:
			for i1 in f[b[i]]:
				ind1 = i1
				break
			r.append([ind1 + 1, i + 2])
			f1[b[i + 1]].remove(i + 1)
			f1[b[i]].add(i + 1)
			f[b[i]].remove(ind1)
			f[b[i + 1]].add(ind1)
			(b[i + 1], a[ind1]) = (a[ind1], b[i + 1])
			r.append([i + 1, i + 2])
			f[a[i]].remove(i)
			f1[b[i + 1]].remove(i + 1)
			f1[a[i]].add(i + 1)
			(a[i], b[i + 1]) = (b[i + 1], a[i])
		try:
			f[a[i]].remove(i)
		except:
			pass
		try:
			f1[b[i]].remove(i)
		except:
			pass
	print(len(r))
	for i in r:
		print(*i)


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	s = list(s)
	t = list(t)
	a = []
	c = 0
	for i in range(n):
		if s[i] != t[i]:
			a.append(s[i])
			a.append(t[i])
			c += 2
			if c > 4:
				break
	if c == 4:
		if a[0] == a[2]:
			if a[1] == a[3]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	(s, si) = (input(), input())
	li = list()
	for i in range(n):
		if s[i] not in si[i]:
			li.append(i)
	if len(li) != 2:
		print('No')
	elif si[li[0]] == si[li[1]] and s[li[0]] == s[li[1]]:
		print('Yes')
	else:
		print('No')


t = int(input())

def f(a, b, n):
	s = []
	s1 = []
	for i in range(n):
		if a[i] != b[i]:
			s.append(a[i])
			s1.append(b[i])
		else:
			continue
	if len(set(s)) == 1 and len(set(s1)) == 1:
		if s.sort() == s1.sort() and len(s) == 2:
			print('yes')
		else:
			print('no')
	elif len(s) == 0:
		print(0)
	else:
		print('no')
for j in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	f(a, b, n)


for _ in range(int(input())):
	(n, s, t) = (int(input()), input(), input())
	i = 0
	while s[i] == t[i]:
		i += 1
	j = i + 1
	while j < len(t) and s[j] == t[j]:
		j += 1
	if j == len(t) or s[j + 1:] != t[j + 1:] or (t[j] != t[i] or s[i] != s[j]):
		ans = 'No'
	else:
		ans = 'Yes'
	print(ans)


n = int(input())

def solve():
	contador = 0
	size = int(input())
	cadena1 = input()
	cadena2 = input()
	caracter1 = ''
	caracter2 = ''
	flag = True
	for i in range(size):
		if cadena1[i] != cadena2[i] and caracter1 == '':
			contador += 1
			caracter1 = cadena1[i]
			caracter2 = cadena2[i]
		elif cadena1[i] != cadena2[i] and caracter1 != '':
			contador += 1
			if caracter1 != cadena1[i] or caracter2 != cadena2[i]:
				flag = False
	if contador != 2 or flag == False:
		print('NO')
	else:
		print('YES')
for i in range(n):
	solve()


def f():
	q = int(input())
	for qq in range(q):
		n = int(input())
		s = input()
		t = input()
		ss = ''
		tt = ''
		for i in range(n):
			if s[i] != t[i]:
				ss += s[i]
				tt += t[i]
		if len(ss) == len(tt) == 2 and ss[0] == ss[1] and (tt[0] == tt[1]):
			print('Yes')
		else:
			print('No')
f()


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	isFirst = True
	first_string_char = ''
	second_string_char = ''
	isSecond = False
	swaps = 1
	for i in range(len(a)):
		if a[i] != b[i] and isFirst:
			isFirst = False
			isSecond = True
			first_string_char = a[i]
			second_string_char = b[i]
			continue
		elif a[i] != b[i] and isSecond:
			if first_string_char == a[i] and second_string_char == b[i] and (swaps > 0):
				swaps -= 1
				isFirst = True
				isSecond = False
			else:
				break
	if swaps == 0 and (not isSecond):
		print('Yes')
	else:
		print('No')


from collections import defaultdict

def solve():
	n = int(input())
	s = input().strip()
	t = input().strip()
	lcount = defaultdict(int)
	for letter in s + t:
		lcount[letter] += 1
	possible = all((c % 2 == 0 for c in lcount.values()))
	if not possible:
		print('No')
	else:
		print('Yes')
		swaps = list()
		s = list(s)
		t = list(t)
		sletters = defaultdict(list)
		for (pos, letter) in enumerate(s):
			sletters[letter].append(pos)
		tletters = defaultdict(list)
		for (pos, letter) in enumerate(t):
			tletters[letter].append(pos)

		def swap(i, j):
			swaps.append((i, j))
			temp = s[i]
			s[i] = t[j]
			t[j] = temp
			sletters[temp].remove(i)
			sletters[s[i]].append(i)
			tletters[s[i]].remove(j)
			tletters[temp].append(j)
		alphabet = 'abcdefghijklmnopqrstuvwxyz'
		remove_from_s = []
		remove_from_t = []
		for letter in alphabet:
			remove_from_s.extend(sletters[letter][lcount[letter] // 2:])
			remove_from_t.extend(tletters[letter][lcount[letter] // 2:])
		for (i, j) in zip(remove_from_s, remove_from_t):
			swap(i, j)
		target = s
		positions_to_fix = [pos for pos in range(n) if t[pos] != target[pos]]
		destinations = []
		for pos in positions_to_fix:
			possible_destinations = [p for p in positions_to_fix if target[p] == t[pos] and p not in destinations]
			destinations.append(possible_destinations[0])
		destination_map = dict()
		for (pos, dest) in zip(positions_to_fix, destinations):
			destination_map[pos] = dest
		pivot_contents = None
		while len(positions_to_fix) > 0:
			if pivot_contents == None:
				pos = positions_to_fix[0]
				swap(0, pos)
				pivot_contents = pos
			else:
				dest = destination_map[pivot_contents]
				swap(0, dest)
				positions_to_fix.remove(pivot_contents)
				if dest in positions_to_fix:
					pivot_contents = dest
				else:
					pivot_contents = None
		print(len(swaps))
		for (i, j) in swaps:
			print('%d %d' % (i + 1, j + 1))
k = int(input())
for i in range(k):
	solve()


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	i = 0
	f = True
	while s[i] == t[i]:
		if i == n - 1:
			f = False
			break
		i += 1
	if not f:
		print('Yes')
		continue
	for j in range(i + 1, n):
		if s[i] == s[j] and t[i] == t[j]:
			s1 = s[:i] + t[j] + s[i + 1:]
			t1 = t[:j] + s[i] + t[j + 1:]
			if t1 == s1:
				print('Yes')
				f = False
				break
	if f:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	dic = {}
	flag = 0
	for i in range(n):
		if s[i] in dic:
			dic[s[i]] += 1
		else:
			dic[s[i]] = 1
		if t[i] in dic:
			dic[t[i]] += 1
		else:
			dic[t[i]] = 1
	for (key, value) in dic.items():
		if value % 2 != 0:
			flag = 1
	if flag == 1:
		print('No')
	else:
		mismatch = 0
		dif = []
		for i in range(n):
			if s[i] == t[i]:
				None
			else:
				mismatch += 1
				dif.append(i)
		if mismatch == 2:
			(s[dif[0]], t[dif[1]]) = (t[dif[1]], s[dif[0]])
			if s == t:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	l = [[g, h] for (g, h) in zip(a, b) if g != h]
	res = len(l) == 0
	if len(l) == 2:
		res = l[0] == l[1]
	print('NYOE S'[res::2])


k = int(input())
for i in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	c = 0
	to_del = []
	for i in range(n):
		if s[i] == t[i]:
			c += 1
			to_del.append(i)
	if c == n - 2:
		to_del = set(to_del)
		full = set(range(n))
		indices = list(full.difference(to_del))
		a = indices[0]
		b = indices[1]
		if s[a] == s[b] and t[a] == t[b]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	cnt = 0
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	for i in range(n):
		if s[i] != t[i]:
			a[cnt] = s[i]
			b[cnt] = t[i]
			cnt += 1
	if cnt != 2:
		print('No')
		continue
	elif a[0] == a[1] and b[0] == b[1]:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	(s, t) = (list(input()), list(input()))
	(index1, index2) = (-1, -1)
	for i in range(n):
		if s[i] != t[i]:
			index1 = i
			break
	if index1 == -1:
		print('Yes')
		continue
	for i in range(n):
		if i != index1 and t[i] == t[index1] and (t[i] != s[i]):
			index2 = i
			break
	if index2 == -1:
		print('No')
	else:
		(s[index1], t[index2]) = (t[index2], s[index1])
		if s == t:
			print('Yes')
		else:
			print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	s1 = list(s)
	t1 = list(t)
	arr = []

	def func(s, t, j, arr):
		if s1[j] != t1[j]:
			flag = False
			for l in range(j + 1, n):
				if s1[l] == s1[j]:
					flag = True
					break
			if flag == True:
				(s1[l], t1[j]) = (t1[j], s1[l])
				arr.append(str(l + 1) + ' ' + str(j + 1))
			else:
				for l in range(j + 1, n):
					if t1[l] == s1[j]:
						break
				(s1[j + 1], t1[l]) = (t1[l], s1[j + 1])
				arr.append(str(j + 2) + ' ' + str(l + 1))
				(s1[j + 1], t1[j]) = (t1[j], s1[j + 1])
				arr.append(str(j + 2) + ' ' + str(j + 1))
	dic = {}
	for j in s:
		if j not in dic:
			dic[j] = 1
		else:
			dic[j] += 1
	for j in t:
		if j not in dic:
			dic[j] = 1
		else:
			dic[j] += 1
	flag = False
	for j in dic:
		if dic[j] % 2 != 0:
			flag = True
			break
	if flag == True:
		print('No')
	else:
		for j in range(0, n - 1):
			func(s, t, j, arr)
		print('Yes')
		print(len(arr))
		for j in arr:
			print(j)


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	flag = 1
	s_new = []
	t_new = []
	for j in range(n):
		if s[j] != t[j]:
			s_new.append(s[j])
			t_new.append(t[j])
			flag = 0
	if flag:
		print('Yes')
		continue
	if len(s_new) != 2:
		print('No')
		continue
	if s_new[0] == s_new[1] and t_new[0] == t_new[1] and (s_new[0] != t_new[1]) and (s_new[1] != t_new[0]):
		print('Yes')
	else:
		print('No')


m = int(input())
for j in range(m):
	n = int(input())
	b = input()
	c = input()
	d = []
	k = 0
	for i in range(n):
		if b[i] != c[i]:
			k = k + 1
			d.append(b[i])
			d.append(c[i])
	if k == 2:
		if d[0] == d[2] and d[1] == d[3]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	l = []
	for i in range(n):
		if s[i] != t[i]:
			l.append(i)
			count += 1
	if count > 2 or count == 1:
		print('No')
	elif count == 0:
		print('Yes')
	elif s[l[0]] == s[l[1]] and t[l[0]] == t[l[1]]:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	c = []
	for i in range(n):
		if s1[i] != s2[i]:
			c.append([s1[i], s2[i]])
	if len(c) == 0:
		print('Yes')
	elif len(c) == 2:
		if c[0] == c[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import sys

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

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

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

def swap(s, t, i, j):
	s = s[:]
	t = t[:]
	(s[i], t[j]) = (t[j], s[i])
	return s == t

def solve():
	n = mint()
	s = list(minp())
	t = list(minp())
	p = []
	for i in range(n):
		if s[i] != t[i]:
			p.append(i)
			if len(p) > 2:
				print('No')
				return
	for i in p:
		for j in p:
			if swap(s, t, i, j):
				print('Yes')
				return
	print('No')
for i in range(mint()):
	solve()


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	n = int(input())
	s = [i for i in input()]
	t = [i for i in input()]
	d = defaultdict(int)
	for i in range(n):
		d[s[i]] += 1
		d[t[i]] += 1
	if len(d.keys()) > n or sum((i % 2 for i in d.values())):
		print('No')
	else:
		ans = []
		for i in range(n):
			if s[i] != t[i]:
				for j in range(i + 1, n):
					if s[j] != t[j]:
						if s[i] == s[j]:
							ans.append([j, i])
							(s[j], t[i]) = (t[i], s[j])
							break
						elif s[i] == t[j]:
							ans.append([j, j])
							(s[j], t[j]) = (t[j], s[j])
							ans.append([j, i])
							(s[j], t[i]) = (t[i], s[j])
							break
						elif t[i] == t[j]:
							ans.append([i, j])
							(s[i], t[j]) = (t[j], s[i])
							break
						elif t[i] == s[j]:
							ans.append([j, j])
							(s[j], t[j]) = (t[j], s[j])
							ans.append([i, j])
							(s[i], t[j]) = (t[j], s[i])
							break
		print('Yes')
		print(len(ans))
		for i in ans:
			print(i[0] + 1, i[1] + 1)


t = int(input())
for te in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	k = []
	for i in range(n):
		if s[i] != t[i]:
			k.append(i)
	if len(k) == 2:
		if s[k[0]] == t[k[1]] and s[k[1]] == t[k[0]]:
			print('NO')
			continue
		if s[k[0]] == s[k[1]] and t[k[0]] == t[k[1]]:
			print('YES')
			continue
	print('NO')


def main():
	global visited, adj, sets
	n = get_int()
	s1 = list(input())
	s2 = list(input())
	swaps = []

	def swp(s1_ptr, s2_ptr):
		swaps.append([s1_ptr + 1, s2_ptr + 1])
		(s1[s1_ptr], s2[s2_ptr]) = (s2[s2_ptr], s1[s1_ptr])
	for i in range(n):
		if s1[i] != s2[i]:
			fixed = False
			for j in range(i + 1, n):
				if s1[j] == s1[i]:
					swp(j, i)
					fixed = True
					break
			if not fixed:
				for j in range(i + 1, n):
					if s1[i] == s2[j]:
						swp(j, j)
						swp(j, i)
						break
	if s1 == s2:
		print('YES')
		print(len(swaps))
		[print(' '.join(map(str, x))) for x in swaps]
	else:
		print('NO')
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


def canDo(s, t, n):
	diff = 0
	i = j = -1
	for k in range(n):
		if s[k] != t[k]:
			if i == -1:
				i = k
			elif j == -1:
				j = k
			else:
				return 'No'
	if i == -1 or j == -1:
		return 'No'
	if s[i] == s[j] and t[i] == t[j]:
		return 'Yes'
	else:
		return 'No'
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	print('%s' % canDo(s, t, n))


for _ in range(int(input())):
	N = int(input())
	L1 = list(input())
	L2 = list(input())
	count = 0
	FLAG = 0
	(x, y, t, u) = (0, 0, 0, 0)
	for i in range(N):
		if L1[i] != L2[i]:
			if count == 0:
				t = L1[i]
				u = L2[i]
			if count == 1:
				x = L1[i]
				y = L2[i]
			count += 1
	if u == y and t == x and (count == 2):
		print('Yes')
	else:
		print('No')


def solve(s1, s2, n):
	index = []
	for i in range(n):
		if s1[i] != s2[i]:
			index.append(i)
	if len(index) != 2:
		return False
	elif s1[index[0]] == s1[index[1]] and s2[index[0]] == s2[index[1]]:
		return True
	else:
		return False
t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	if solve(s1, s2, n):
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(input())
	b = list(input())
	p = 0
	pp = 0
	w = 0
	flag = 0
	for i in range(n):
		if a[i] != b[i] and flag == 0:
			p = a[i]
			pp = b[i]
			flag += 1
			w = 1
			continue
		elif a[i] != b[i] and flag == 1:
			if p == a[i] and pp == b[i]:
				flag += 1
				w = 0
			else:
				w = 1
				break
		elif a[i] != b[i] and flag == 2:
			w = 1
			break
	print('Yes' if w == 0 else 'No')


I = input
for _ in [0] * int(I()):
	I()
	(s, t) = (I(), I())
	a = [i for (i, (x, y)) in enumerate(zip(s, t)) if x != y]
	print('YNeos'[a != [] and (len(a) != 2 or s[a[0]] + t[a[0]] != s[a[1]] + t[a[1]])::2])


for i in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	d = []
	count = 0
	f = 0
	count = 0
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			d.append(i)
	if count == 2:
		x = s[d[0]]
		s[d[0]] = t[d[1]]
		t[d[1]] = x
		if t == s:
			print('yes')
		else:
			print('no')
	else:
		print('no')


def main():
	global visited, adj, sets
	n = get_int()
	s1 = list(input())
	s2 = list(input())
	for i in range(n):
		if s1[i] != s2[i]:
			fixed = False
			for j in range(i + 1, n):
				if s2[j] == s2[i] and s1[j] == s1[i]:
					(s2[j], s1[i]) = (s1[i], s2[j])
					fixed = True
					break
			if fixed:
				break
	if s1 == s2:
		print('Yes')
	else:
		print('No')
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	e = []
	no = False
	for j in range(n):
		if s[j] != t[j]:
			e.append(j)
			if len(e) == 3:
				no = True
				break
	if not no and (len(e) != 2 or s[e[0]] != s[e[1]] or t[e[0]] != t[e[1]]):
		no = True
	print('No' if no else 'Yes')


import sys
from collections import Counter
inp = sys.stdin.readline
ans = ''
for _ in range(int(inp())):
	n = int(inp())
	s = inp().strip()
	t = inp().strip()
	counter = Counter(s + t)
	flag = 0
	for i in counter.values():
		if i % 2 == 1:
			flag = 1
	if flag:
		ans += 'No\n'
		continue
	lis = []
	for i in range(n):
		if s[i] != t[i]:
			if len(lis) < 2:
				lis.append(i)
			else:
				flag = 1
				break
	if flag:
		ans += 'No\n'
	elif len(lis) == 2 and t[lis[0]] == t[lis[1]]:
		ans += 'Yes\n'
	elif not lis:
		ans += 'Yes\n'
	else:
		ans += 'No\n'
print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(input())
	t = list(input())
	memo = {}
	for i in range(n):
		if s[i] not in memo:
			memo[s[i]] = 1
		else:
			memo[s[i]] += 1
		if t[i] not in memo:
			memo[t[i]] = 1
		else:
			memo[t[i]] += 1
	for i in memo:
		if memo[i] % 2 == 1:
			print('No')
			break
	else:
		ans = []
		for i in range(n):
			if s[i] == t[i]:
				continue
			for j in range(i + 1, n):
				if s[i] == s[j]:
					tmp1 = s[j]
					tmp2 = t[i]
					(t[i], s[j]) = (tmp1, tmp2)
					ans.append((j + 1, i + 1))
					break
			if s[i] == t[i]:
				continue
			for j in range(i + 1, n):
				if s[i] == t[j]:
					tmp1 = s[j]
					tmp2 = t[j]
					(t[j], s[j]) = (tmp1, tmp2)
					ans.append((j + 1, j + 1))
					tmp1 = s[j]
					tmp2 = t[i]
					(t[i], s[j]) = (tmp1, tmp2)
					ans.append((j + 1, i + 1))
					break
		print('Yes')
		print(len(ans))
		for i in ans:
			print(*i)


from collections import defaultdict
try:
	import pytest

	@pytest.mark.parametrize('items, result', [(('souse', 'houhe'), 'Yes'), (('cat', 'dog'), 'No'), (('aa', 'az'), 'No'), (('abc', 'bca'), 'No')])
	def test(items, result):
		assert solve(*items) == result
except Exception:
	pass

def solve(s: str, t: str) -> str:
	positions = defaultdict(list)
	for (i, (left, right)) in enumerate(zip(s, t)):
		if left != right:
			positions[left, right].append(i)
	if len(positions) == 1:
		(_, items) = positions.popitem()
		if len(items) == 2:
			return 'Yes'
	return 'No'

def main():
	for _ in range(int(input())):
		input()
		print(solve(input(), input()))
main()


for nt in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	d = 0
	ind = []
	for i in range(n):
		if a[i] != b[i]:
			d += 1
			ind.append(i)
	if d != 2:
		print('NO')
		continue
	if a[ind[0]] == a[ind[1]] and b[ind[1]] == b[ind[0]]:
		print('YES')
	else:
		print('NO')


k = int(input())
for i in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	q = None
	for i in range(n):
		if s1[i] != s2[i]:
			if q is None:
				q = (s1[i], s2[i])
			elif q == (s1[i], s2[i]):
				q = 1
			else:
				print('No')
				break
	else:
		if q == 1:
			print('Yes')
		else:
			print('No')


for i in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	d = []
	r = []
	c = 0
	for i in range(n):
		if a[i] != b[i]:
			c = c + 1
			d.append(a[i])
			r.append(b[i])
	if c % 2 == 0 and len(set(d)) == 1 and (len(set(r)) == 1):
		print('YES')
	else:
		print('NO')


k = int(input())
for K in range(k):
	n = int(input())
	s = input().strip()
	t = input().strip()
	p = 0
	for i in range(n):
		if s[i] == t[i]:
			continue
		elif p == 1:
			print('NO')
			break
		elif p:
			if s[i] != p[0] or t[i] != p[1]:
				print('NO')
				break
			p = 1
		else:
			p = [s[i], t[i]]
	else:
		print('YES' if p == 1 else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	s1 = input()
	se = []
	for i in range(n):
		if s[i] == s1[i]:
			continue
		else:
			se.append(i)
	if len(se) != 2:
		print('No')
	elif s1[se[0]] == s1[se[1]] and s[se[0]] == s[se[1]]:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	b = input()
	isFirst = True
	first_char = ''
	secon_char = ''
	isSecond = False
	swaps = 1
	for i in range(len(a)):
		if a[i] != b[i] and isFirst:
			isFirst = False
			isSecond = True
			first_char = a[i]
			secon_char = b[i]
			continue
		elif a[i] != b[i] and isSecond:
			if first_char == a[i] and secon_char == b[i] and (swaps > 0):
				swaps -= 1
				isFirst = True
				isSecond = False
			else:
				break
	if swaps == 0 and (not isSecond):
		print('Yes')
	else:
		print('No')


from collections import Counter as ctr
inp = lambda : int(input())
strl = lambda : list(input().strip())
seq = lambda : list(map(int, input().strip().split()))

def results(s, t, n):
	cnt = 0
	ss = []
	tt = []
	for i in range(n):
		if s[i] != t[i]:
			cnt += 1
			ss.append(s[i])
			tt.append(t[i])
			if cnt > 2:
				return 'No'
	if len(ss) == len(tt) == 1:
		return 'No'
	if len(set(ss)) == len(set(tt)) == 1:
		return 'Yes'
	return 'No'

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		s = strl()
		t = strl()
		result = results(s, t, n)
		print(result)
main()


for i in range(int(input())):
	n = int(input())
	h = []
	s1 = input()
	s2 = input()
	for j in range(n):
		if s1[j] != s2[j]:
			h.append([s1[j], s2[j]])
	if len(h) != 2:
		print('No')
	elif h[0] == h[1]:
		print('Yes')
	else:
		print('No')


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
from math import gcd
(q,) = I()
while q:
	q -= 1
	(n,) = I()
	s = list(input())
	t = list(input())
	count = 0
	ans = 'No'
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			ind.append(i)
	if count >= 2:
		(s[ind[0]], t[ind[1]]) = (t[ind[1]], s[ind[0]])
	if s == t:
		ans = 'Yes'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	l = []
	for i in range(n):
		if s[i] != t[i]:
			l.append(i)
	if len(l) != 2:
		print('No')
	else:
		(s[l[0]], t[l[1]]) = (t[l[1]], s[l[0]])
		if s == t:
			print('Yes')
		else:
			print('No')


def isValid(s, t, n):
	i = 0
	count = 0
	unmatched = []
	while i < n:
		if s[i] != t[i]:
			count += 1
			if count > 2:
				return False
			unmatched.append(i)
		i += 1
	return count == 2 and s[unmatched[0]] == s[unmatched[1]] and (t[unmatched[0]] == t[unmatched[1]])
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	print('Yes' if isValid(s, t, n) else 'No')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		s = S()
		t = S()
		c = 0
		ss = set()
		ts = set()
		for (a, b) in zip(s, t):
			if a != b:
				c += 1
				ss.add(a)
				ts.add(b)
		rr.append(Yes(c == 0 or (c == 2 and len(ss) == 1 and (len(ts) == 1))))
	return JA(rr, '\n')
print(main())


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	p = 0
	a = []
	for j in range(n):
		if s[j] != t[j]:
			p += 1
			a.append(j)
	if p == 2:
		if s[:a[0]] + t[a[1]] + s[a[0] + 1:] == t[:a[1]] + s[a[0]] + t[a[1] + 1:] or s[:a[1]] + t[a[0]] + s[a[1] + 1:] == t[:a[0]] + s[a[1]] + t[a[0] + 1:]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = 0
	m1 = -1
	m2 = -1
	flag = True
	for i in range(n):
		if a[i] != b[i]:
			if c < 2:
				c += 1
				if c == 1:
					m1 = i
				if c == 2:
					m2 = i
			else:
				flag = False
				print('No')
				break
	if flag:
		if c == 0:
			print('Yes')
		elif c == 2:
			if a[m1] == a[m2] and b[m2] == b[m1]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


k = int(input())
while k > 0:
	n = int(input())
	s1 = input()
	s2 = input()
	a = [0] * 26
	b = [0] * 26
	flag = 0
	for i in range(n):
		if s1[i] != s2[i]:
			a[ord(s1[i]) - 97] += 1
			b[ord(s2[i]) - 97] += 1
	count1 = 0
	count2 = 0
	for i in range(26):
		if a[i] == 2:
			count1 += 1
		if b[i] == 2:
			count2 += 1
		elif a[i] > 0 and a[i] != 2 or (b[i] > 0 and b[i] != 2) or count1 + count2 > 2:
			flag = 1
			break
	if flag == 1:
		print('no')
	else:
		print('yes')
	k -= 1


nbt = int(input())
for _ in range(nbt):
	lens = int(input())
	src = input()
	tgt = input()
	dif = set()
	cnt = 0
	for (x, y) in zip(src, tgt):
		if x != y:
			cnt += 1
			dif.add((x, y))
	print(['No', 'Yes'][cnt == 2 and len(dif) == 1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	flag = 1
	ans = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		if i == n - 1:
			flag = 0
			break
		ff = 0
		for j in range(i + 1, n):
			if a[j] == a[i]:
				(a[j], b[i]) = (b[i], a[j])
				ff = 1
				ans.append((j, i))
			elif b[j] == b[i]:
				(b[j], a[i]) = (a[i], b[j])
				ff = 1
				ans.append((i, j))
			elif a[i] == b[j]:
				ff = 1
				ans.append((n - 1, j))
				ans.append((n - 1, i))
				(b[j], a[n - 1]) = (a[n - 1], b[j])
				(b[i], a[n - 1]) = (a[n - 1], b[i])
			elif b[i] == a[j]:
				ff = 1
				ans.append((j, n - 1))
				ans.append((i, n - 1))
				(a[j], b[n - 1]) = (b[n - 1], a[j])
				(a[i], b[n - 1]) = (b[n - 1], a[i])
			if ff:
				break
		if ff == 0:
			flag = 0
			break
	if flag == 0:
		print('No')
	else:
		print('Yes')
		print(len(ans))
		for pi in ans:
			print(pi[0] + 1, pi[1] + 1)


k = int(input())
for i in range(k):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	dif = list()
	for j in range(n):
		if s1[j] != s2[j]:
			dif.append(j)
	if len(dif) != 2:
		print('No')
	elif s1[dif[0]] == s1[dif[1]] and s2[dif[0]] == s2[dif[1]]:
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.readline

def main():
	q = int(input())
	for _ in range(q):
		N = int(input())
		S = input().strip()
		T = input().strip()
		c = 0
		x = []
		is_no = False
		for i in range(N):
			if S[i] != T[i]:
				x.append(i)
				c += 1
				if c >= 3:
					is_no = True
					break
		if is_no or c == 1:
			print('No')
		elif c == 0:
			print('Yes')
		elif S[x[0]] == S[x[1]] and T[x[0]] == T[x[1]]:
			print('Yes')
		else:
			print('No')
main()


n = int(input())
while n:
	n -= 1
	m = int(input())
	s = input()
	g = input()
	s1 = []
	g1 = []
	c = 0
	for i in range(0, m):
		if s[i] != g[i]:
			c += 1
			s1.append(s[i])
			g1.append(g[i])
	if c == 2 and s1[0] == s1[1] and (g1[0] == g1[1]):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	ans = []
	d1 = dict()
	d2 = dict()
	for i in range(n):
		try:
			d1[a[i]].add(i)
		except:
			d1[a[i]] = set([i])
		try:
			d2[b[i]].add(i)
		except:
			d2[b[i]] = set([i])
	f1 = 0
	for i in range(n):
		d1[a[i]].remove(i)
		d2[b[i]].remove(i)
		if a[i] != b[i]:
			flag = 0
			for j in d1[a[i]]:
				if a[j] != b[j]:
					ans.append([j + 1, i + 1])
					d1[a[j]].remove(j)
					(a[j], b[i]) = (b[i], a[j])
					try:
						d1[a[j]].add(j)
					except:
						d1[a[j]] = set([j])
					try:
						d2[b[j]].add(j)
					except:
						d2[b[j]] = set([j])
					flag = 1
					break
			if flag == 0:
				if a[i] in d2:
					for j in d2[a[i]]:
						if a[j] != b[j]:
							ans.append([j + 1, j + 1])
							d1[a[j]].remove(j)
							d2[b[j]].remove(j)
							(a[j], b[j]) = (b[j], a[j])
							try:
								d1[a[j]].add(j)
							except:
								d1[a[j]] = set([j])
							try:
								d2[b[j]].add(j)
							except:
								d2[b[j]] = set([j])
							d1[a[j]].remove(j)
							ans.append([j + 1, i + 1])
							(a[j], b[i]) = (b[i], a[j])
							try:
								d1[a[j]].add(j)
							except:
								d1[a[j]] = set([j])
							try:
								d2[b[j]].add(j)
							except:
								d2[b[j]] = set([j])
							flag = 1
							break
			if flag == 0:
				f1 = 1
				break
	if f1 == 0:
		print('Yes')
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print('No')


def sol():
	st = input()
	n = st
	n = int(n)
	for i in range(n):
		m = int(input())
		st1 = input()
		st2 = input()
		count = 0
		diffs = []
		for i in range(len(st1)):
			if st1[i] != st2[i]:
				count += 1
				diffs.append(i)
		if count == 0:
			print('Yes')
		elif count == 2:
			if st1[diffs[0]] == st1[diffs[1]] and st2[diffs[0]] == st2[diffs[1]]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
sol()


def solve(a, b):
	size = len(a)
	answer = []
	for i in range(size):
		if a[i] != b[i]:
			for j in range(i + 1, size):
				if a[j] == a[i]:
					answer.append([j + 1, i + 1])
					(b[i], a[j]) = (a[j], b[i])
					break
				elif b[j] == a[i]:
					answer.append([j + 1, j + 1])
					answer.append([j + 1, i + 1])
					(b[j], a[j]) = (a[j], b[j])
					(b[i], a[j]) = (a[j], b[i])
					break
	return answer
q = int(input())
for _ in range(q):
	n = int(input())
	s = list(input())
	t = list(input())
	char_shop = [0] * 26
	for i in range(n):
		char_shop[ord(s[i]) - 97] += 1
		char_shop[ord(t[i]) - 97] += 1
	fail = False
	for c in char_shop:
		if c % 2 != 0:
			fail = True
			break
	if fail:
		print('No')
		continue
	print('Yes')
	res = solve(s, t)
	print(len(res))
	for r in res:
		print(' '.join(map(str, r)))


from bisect import bisect_right
from collections import defaultdict
a = int(input())
for i in range(a):
	s = int(input())
	a1 = input()
	a2 = input()
	k1 = []
	k2 = []
	al = defaultdict(list)
	dl = defaultdict(list)
	for i in range(s):
		al[a1[i]].append(i)
		dl[a2[i]].append(i)
		k1.append(a1[i])
		k2.append(a2[i])
	glag = 0
	swap = []
	for i in range(s):
		if k1[i] == k2[i]:
			continue
		else:
			if len(al[k1[i]]) == 1 and len(dl[k1[i]]) == 0:
				glag = 1
				break
			flag = 0
			if len(al[k1[i]]) > 1:
				t1 = al[k1[i]]
				r = bisect_right(t1, i)
				if r < len(t1):
					index = t1[r]
					swap.append([index + 1, i + 1])
					temp = k2[i]
					k2[i] = k1[i]
					k1[index] = temp
					al = defaultdict(list)
					dl = defaultdict(list)
					for i in range(len(k1)):
						al[k1[i]].append(i)
						dl[k2[i]].append(i)
					flag = 1
			if flag == 0:
				if len(dl[k1[i]]):
					r = bisect_right(dl[k1[i]], i)
					if r < len(dl[k1[i]]):
						index = dl[k1[i]][r]
						temp = k2[i]
						k2[i] = k1[i]
						t2 = k1[index]
						k1[index] = temp
						k2[index] = t2
						swap.append([index + 1, index + 1])
						swap.append([index + 1, i + 1])
						al = defaultdict(list)
						dl = defaultdict(list)
						for i in range(len(k1)):
							al[k1[i]].append(i)
							dl[k2[i]].append(i)
						flag = 1
			if flag == 0:
				glag = 1
				break
	if glag == 1:
		print('No')
	else:
		print('Yes')
		print(len(swap))
		for i in range(len(swap)):
			print(' '.join(map(str, swap[i])))


def f(s, t):
	n = len(s)
	l = []
	for i in range(0, n):
		if s[i] == t[i]:
			pass
		else:
			l.append(i)
		if len(l) > 2:
			return 'No'
	if len(l) != 2:
		return 'No'
	if s[l[0]] == s[l[1]] and t[l[0]] == t[l[1]]:
		return 'Yes'
	else:
		return 'No'
k = int(input())
for i in range(0, k):
	n = input()
	s = input()
	t = input()
	print(f(s, t))


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	n = int(input())
	s1 = input()
	s2 = input()
	c = 0
	s3 = ''
	s4 = ''
	f = 0
	c = 0
	for i in range(0, n):
		if s1[i] != s2[i] and c == 0:
			s3 = s1[i]
			s4 = s2[i]
			c = c + 1
		elif s1[i] != s2[i]:
			if s1[i] == s3 and s2[i] == s4:
				f = 1
			c = c + 1
	if f == 1 and c == 2:
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = list(input())
	s1 = list(input())
	s2 = []
	s3 = []
	sum
	sum = 0
	flag = 0
	for i in range(n):
		if s[i] != s1[i]:
			sum += 1
			s2.append(s[i])
			s3.append(s1[i])
		if sum > 2:
			flag = 1
			break
	if flag == 1:
		print('no')
		continue
	m = len(s2)
	if sum < 2:
		print('no')
		continue
	if s2[0] == s2[1] and s3[0] == s3[1]:
		print('yes')
	else:
		print('no')


T = int(input())
for t in range(T):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	ct = 0
	idx = []
	for i in range(n):
		if s1[i] != s2[i]:
			ct += 1
			idx.append(i)
	if ct == 2:
		(s1[idx[0]], s2[idx[1]]) = (s2[idx[1]], s1[idx[0]])
		if s1 == s2:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	(sd, td) = ({}, {})
	(ks, kt) = (None, None)
	for i in range(n):
		if s[i] != t[i]:
			(ks, kt) = (s[i], t[i])
			if sd.get(s[i]) is None:
				sd[s[i]] = 1
			else:
				sd[s[i]] += 1
			if td.get(t[i]) is None:
				td[t[i]] = 1
			else:
				td[t[i]] += 1
	if len(sd) == len(td) == 1:
		if sd[ks] % 2 == 0 and td[kt] % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	t = input()
	ct = 0
	diff = []
	for i in range(n):
		if s[i] != t[i]:
			diff.append(i)
			ct += 1
	if ct != 2:
		print('NO')
	elif s[diff[0]] == s[diff[1]] and t[diff[0]] == t[diff[1]]:
		print('YES')
	else:
		print('NO')


def f(n, s, t):
	chars = []
	for i in range(n):
		if s[i] != t[i]:
			chars.append([s[i], t[i]])
		if len(chars) == 3:
			return 'No'
	if len(chars) != 2:
		return 'No'
	else:
		if chars[0][0] == chars[1][0] and chars[0][1] == chars[1][1]:
			return 'Yes'
		return 'No'
q = int(input())
for __ in range(q):
	n = int(input())
	s = input()
	t = input()
	print(f(n, s, t))


from collections import *
for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	if all((i % 2 == 0 for i in Counter(a + b).values())):
		print('Yes')
		op = []
		for i in range(n):
			if a[i] != b[i]:
				for j in range(i + 1, n):
					if a[i] == a[j]:
						op.append([j + 1, i + 1])
						(b[i], a[j]) = (a[j], b[i])
						break
					if a[i] == b[j]:
						op.append([i + 2, j + 1])
						(b[j], a[i + 1]) = (a[i + 1], b[j])
						op.append([i + 2, i + 1])
						(b[i], a[i + 1]) = (a[i + 1], b[i])
						break
		print(len(op))
		for (x, y) in op:
			print(x, y)
	else:
		print('No')


for u in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	pos = []
	for i in range(n):
		if s[i] != t[i]:
			for j in range(i + 1, n):
				if t[i] == t[j]:
					(s[i], t[j]) = (t[j], s[i])
					pos.append([i + 1, j + 1])
					break
				elif t[i] == s[j]:
					(t[j], s[j]) = (s[j], t[j])
					pos.append([j + 1, j + 1])
					(s[i], t[j]) = (t[j], s[i])
					pos.append([i + 1, j + 1])
					break
	if s == t and len(pos) <= 2 * n:
		print('Yes')
		print(len(pos))
		for i in pos:
			print(*i)
	else:
		print('No')


k = int(input())
i = 0
while i < k:
	n = int(input())
	s = input()
	S = s
	t = input()
	ind = []
	valid = 0
	j = 0
	lenght = 1
	while lenght <= n:
		if s[j] == t[j]:
			j += 1
			lenght += 1
			continue
		else:
			valid += 1
			if valid <= 2:
				ind.append(j)
		if valid >= 3:
			break
		j += 1
		lenght += 1
	if valid != 2:
		print('No')
	else:
		j = ind[0]
		z = ind[1]
		s1 = s[:j]
		s2 = s[j + 1:]
		s = s1 + t[z] + s2
		t1 = t[:z]
		t2 = t[z + 1:]
		t = t1 + S[j] + t2
		if s == t:
			print('Yes')
		else:
			print('No')
	i += 1


q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	t = input()
	count = 0
	first = -1
	second = -1
	for p in range(n):
		if s[p] != t[p] and count < 1:
			count += 1
			first = p
		elif s[p] != t[p] and count == 1:
			count += 1
			second = p
		elif s[p] != t[p] and count == 2:
			count = 3
			break
	if count != 2:
		print('No')
	elif s[first] == s[second] and t[second] == t[first]:
		print('Yes')
	else:
		print('No')


def swapChar(s1, s2, p1, p2):
	l1 = list(s1)
	l2 = list(s2)
	temp = l1[p1]
	l1[p1] = l2[p2]
	l2[p2] = temp
	s1 = ''.join(l1)
	s2 = ''.join(l2)
	return (s1, s2)
k = int(input())
for i in range(k):
	n = int(input())
	s = input()[0:n]
	t = input()[0:n]
	count = 0
	p1 = 0
	p2 = 0
	printed = False
	for j in range(n):
		if s[j] != t[j]:
			count += 1
			if count == 1:
				p1 = j
			elif count == 2:
				p2 = j
				(s, t) = swapChar(s, t, p1, p2)
				if s == t:
					print('YES')
					printed = True
				else:
					print('NO')
					printed = True
	if not printed:
		if count == 0:
			print('YES')
		else:
			print('NO')


n = int(input())
out = []
for i in range(n):
	t = int(input())
	a = input()
	b = input()
	if a == b:
		out.append('Yes')
		continue
	difren = []
	c = 0
	for i in range(t):
		if a[i] != b[i]:
			difren.append([a[i], b[i]])
			c += 1
			if c > 2:
				out.append('No')
				break
	if c > 2:
		continue
	elif c == 2 and difren[0][0] == difren[1][0] and (difren[0][1] == difren[1][1]):
		out.append('Yes')
	else:
		out.append('No')
for i in out:
	print(i)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	(s1, s2) = (list(input().strip()), list(input().strip()))
	dis = 0
	diff = []
	for i in range(n):
		if s1[i] != s2[i]:
			dis += 1
			diff.append(i)
	if dis == 2 and s1[diff[0]] == s1[diff[1]] and (s2[diff[1]] == s2[diff[0]]):
		print('YES')
	elif dis == 0:
		print('YES')
	else:
		print('NO')


tn = int(input())
for _ in range(tn):
	(n, s, t) = (int(input()), input(), input())
	not_equal = list(filter(lambda p: p[0] != p[1], ((x, y) for (x, y) in zip(s, t))))
	if len(not_equal) == 2 and not_equal[0][0] == not_equal[1][0] and (not_equal[0][1] == not_equal[1][1]):
		print('Yes')
	else:
		print('No')


import random

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

def prog():
	N = get_int()
	S = input()
	T = input()
	if S == T:
		print('Yes')
		return
	lst = [i for i in range(N) if S[i] != T[i]]
	print('Yes' if len(lst) == 2 and (S[lst[0]], T[lst[0]]) == (S[lst[1]], T[lst[1]]) else 'No')
q = get_int()
for _ in range(q):
	prog()


k = int(input())
for i in range(k):
	n = int(input())
	s = list(input().strip())
	t = list(input().strip())
	l = []
	for j in range(n - 1):
		if s[j] == t[j]:
			pass
		else:
			flag = 0
			for a in range(j + 1, n):
				if s[a] == s[j]:
					flag = 1
					l.append([a, j])
					s[a] = t[j]
					t[j] = s[j]
					break
			if flag == 0:
				for a in range(j + 1, n):
					if t[a] == s[j]:
						flag = 1
						l.append([a, a])
						temp = s[a]
						s[a] = t[a]
						t[a] = temp
						l.append([a, j])
						s[a] = t[j]
						t[j] = s[j]
						break
				if flag == 0:
					break
	if s == t:
		print('Yes', end='\n')
		print(len(l), end='\n')
		for z in range(len(l)):
			print(l[z][0] + 1, l[z][1] + 1)
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	l = []
	for i in range(n):
		if a[i] != b[i]:
			l.append(i)
	if len(l) == 0:
		print('YES')
	if len(l) > 2 or len(l) == 1:
		print('NO')
	elif a[l[0]] == a[l[1]] and b[l[0]] == b[l[1]]:
		print('YES')
	else:
		print('NO')


def Diff(s1, s2):
	if s1 == s2:
		return True
	Ret = True
	s = 0
	ss = ''
	for i in range(len(s1)):
		if s == 3:
			return False
		if s1[i] != s2[i]:
			ss += s1[i] + s2[i]
			s += 1
	try:
		return ss[0] == ss[2] and ss[1] == ss[3]
	except:
		return False
for _ in range(int(input())):
	s = input()
	s1 = input()
	s2 = input()
	print(['No', 'Yes'][Diff(s1, s2)])


def solve(n, s, t):
	r = []
	for i in range(n):
		if s[i] != t[i]:
			r.append(''.join([s[i], t[i]]))
	if len(r) == 2 and len(set(r)) == 1:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	print(solve(n, s, t))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	s1 = sys.stdin.readline()
	s2 = sys.stdin.readline()
	total = 0
	diff1 = -1
	out = 'Yes'
	for i in range(n):
		if s1[i] != s2[i]:
			total += 1
			if diff1 == -1:
				diff1 = i
			if s2[diff1] != s2[i] or s1[diff1] != s1[i]:
				out = 'No'
	if total == 1 and s2[diff1] != s1[diff1]:
		out = 'No'
	if total > 2:
		out = 'No'
	print(out)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	flag1 = 1
	steps = []
	for i in range(n):
		flag = 0
		if a[i] == b[i]:
			continue
		for j in range(i + 1, n):
			if a[j] != b[j] and a[j] == a[i]:
				steps.append((j + 1, i + 1))
				(a[j], b[i]) = (b[i], a[j])
				flag = 1
				break
		if flag == 0:
			for j in range(i + 1, n):
				if b[j] != a[j] and b[j] == a[i]:
					steps.append((j + 1, j + 1))
					(a[j], b[j]) = (b[j], a[j])
					steps.append((j + 1, i + 1))
					(a[j], b[i]) = (b[i], a[j])
					flag = 1
					break
		if flag == 0:
			flag1 = 0
			break
	if flag1 == 0:
		print('No')
	else:
		print('yes')
		print(len(steps))
		for i in steps:
			print(*i)


k = int(input())
for i in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	c = 0
	l = []
	for j in range(n):
		if s1[j] != s2[j]:
			c += 1
			l.append(j)
	if c == 0:
		print('Yes')
	elif c == 2 and s1[l[0]] == s1[l[1]] and (s2[l[0]] == s2[l[1]]):
		print('Yes')
	else:
		print('No')


import sys
import collections
import heapq
import math
input = sys.stdin.readline

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

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

def rint():
	return int(input().strip())

def rintas():
	return [int(i) for i in input().strip().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
k = rint()
for _ in range(k):
	n = rint()
	S = [i for i in rstr()]
	T = [i for i in rstr()]
	ans = []
	for i in range(n):
		if S[i] != T[i]:
			cont = False
			for j in range(i + 1, n):
				if S[j] != T[j] and S[i] == S[j]:
					(T[i], S[j]) = (S[j], T[i])
					ans.append([j, i])
					cont = True
					break
			if cont:
				continue
			for j in range(i + 1, n):
				if S[j] != T[j] and S[i] == T[j]:
					(T[j], S[j]) = (S[j], T[j])
					ans.append([j, j])
					(T[i], S[j]) = (S[j], T[i])
					ans.append([j, i])
					cont = True
					break
	if S == T:
		print('Yes')
		print(len(ans))
		for (i, j) in ans:
			print(i + 1, ' ', j + 1)
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = input()
	cont = 0
	(x, y) = (-1, -1)
	for i in range(n):
		if s[i] != t[i]:
			cont += 1
			if cont == 1:
				x = i
			if cont == 2:
				y = i
	if cont == 2 and s[x] == s[y] and (t[x] == t[y]):
		print('Yes')
	else:
		print('No')


import sys
import math

def main():
	for _ in range(int(input())):
		n = int(sys.stdin.readline())
		a = sys.stdin.readline()
		b = sys.stdin.readline()
		A = []
		B = []
		for i in range(n):
			if a[i] != b[i]:
				A.append(a[i])
				B.append(b[i])
		if len(A) == len(B) == 0:
			print('Yes')
		elif len(A) == len(B) == 2:
			if A[0] == A[1] and B[0] == B[1]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
main()


for _ in range(int(input())):
	N = int(input())
	s = [i for i in input()]
	t = [i for i in input()]
	charCount = [0] * 26
	for i in s:
		charCount[ord(i) - ord('a')] += 1
	for i in t:
		charCount[ord(i) - ord('a')] += 1
	flag = True
	for i in charCount:
		if i & 1:
			flag = False
			break
	ans = []
	if flag:
		print('Yes')
		for i in range(N - 1):
			if s[i] == t[i]:
				continue
			else:
				go = True
				for ss in range(i + 1, N):
					if s[ss] == s[i]:
						ans.append((ss + 1, i + 1))
						(t[i], s[ss]) = (s[ss], t[i])
						go = False
						break
				if go:
					for tt in range(i + 1, N):
						if t[tt] == s[i]:
							ans.append((tt + 1, tt + 1))
							(t[tt], s[tt]) = (s[tt], s[tt])
							ans.append((tt + 1, i + 1))
							(s[tt], t[i]) = (t[i], s[tt])
							break
		print(len(ans))
		for x in ans:
			print(*x)
	else:
		print('No')


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	ndiff = 0
	(aa, bb) = ([0] * 2, [0] * 2)
	for i in range(n):
		if a[i] != b[i]:
			ndiff += 1
			if ndiff == 3:
				break
			aa[ndiff - 1] = a[i]
			bb[ndiff - 1] = b[i]
	if ndiff == 1 or ndiff > 2:
		print('No')
	else:
		if ndiff == 2:
			if aa[0] != aa[1] or bb[1] != bb[0]:
				print('No')
				continue
		print('Yes')


from collections import defaultdict, Counter
for _ in range(int(input())):
	n = int(input())
	s = [i for i in input()]
	t = [i for i in input()]
	char_of_s = defaultdict(int)
	for s_i in s:
		char_of_s[s_i] += 1
	char_of_t = defaultdict(int)
	for t_i in t:
		char_of_t[t_i] += 1
	common_characters = Counter(s + t)
	if any((1 for key in common_characters if common_characters[key] % 2 == 1)):
		print('No')
	else:
		num_of_operations = 0
		indices = []
		ind = 0
		while ind < n:
			if s[ind] == t[ind]:
				char_of_s[s[ind]] -= 1
				char_of_t[t[ind]] -= 1
				ind += 1
			elif char_of_s[s[ind]] > 1:
				char_of_s[s[ind]] -= 2
				char_of_t[t[ind]] -= 1
				where_a_suitable_sym = s.index(s[ind], ind + 1)
				(s[where_a_suitable_sym], t[ind]) = (t[ind], s[where_a_suitable_sym])
				char_of_s[s[where_a_suitable_sym]] += 1
				indices.append([where_a_suitable_sym + 1, ind + 1])
				num_of_operations += 1
				ind += 1
			else:
				where_a_suitable_sym = t.index(s[ind], ind + 1)
				char_of_s[s[ind + 1]] -= 1
				char_of_t[t[where_a_suitable_sym]] -= 1
				(s[ind + 1], t[where_a_suitable_sym]) = (t[where_a_suitable_sym], s[ind + 1])
				char_of_s[s[ind + 1]] += 1
				char_of_t[t[where_a_suitable_sym]] += 1
				indices.append([ind + 2, where_a_suitable_sym + 1])
				num_of_operations += 1
		print('Yes')
		print(num_of_operations)
		for a_pair_of_indexes in indices:
			print(*a_pair_of_indexes)


ams = int(input())
for g in range(ams):
	am = int(input())
	str1 = input()
	str2 = input()
	eCount = 0
	eP = []
	for i in range(am):
		if not str1[i] == str2[i]:
			eCount += 1
			eP.append(i)
	if eCount >= 3 or eCount <= 1:
		print('No')
	elif str1[eP[0]] == str1[eP[1]] and str2[eP[0]] == str2[eP[1]]:
		print('Yes')
	else:
		print('No')


n = int(input())
for i in range(n):
	k = int(input())
	cnt = 0
	bad = []
	s = input()
	t = input()
	for i in range(k):
		if s[i] != t[i]:
			cnt += 1
			bad.append(i)
	if cnt != 2:
		print('No')
	elif s[bad[0]] != s[bad[1]] or t[bad[0]] != t[bad[1]]:
		print('No')
	else:
		print('Yes')


def process_case():
	n = int(input())
	s = input()
	t = input()
	if n <= 1:
		return False
	different_indices = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		different_indices.append(i)
	if len(different_indices) != 2:
		return False
	return s[different_indices[0]] == s[different_indices[1]] and t[different_indices[0]] == t[different_indices[1]]
test_count = int(input())
for _ in range(test_count):
	result = process_case()
	if result:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(0, t):
	n = int(input())
	first_string = input()
	second_string = input()
	diff_index = []
	for i in range(0, len(first_string)):
		if first_string[i] != second_string[i]:
			diff_index.append(i)
	if len(diff_index) != 2:
		print('No')
	elif first_string[diff_index[0]] == first_string[diff_index[1]] and second_string[diff_index[0]] == second_string[diff_index[1]]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	if s == t:
		print('YES')
	else:
		c = 0
		l1 = list((0 for i in range(26)))
		l2 = list((0 for i in range(26)))
		for i in range(n):
			if s[i] != t[i]:
				c += 1
				l1[ord(s[i]) - 97] += 1
				l2[ord(t[i]) - 97] += 1
			if c > 3:
				break
		if c != 2:
			print('NO')
		else:
			(x, y) = (0, 0)
			for i in range(26):
				if l1[i] > 0:
					x += 1
				if l2[i] > 0:
					y += 1
			if x == 1 and y == 1:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	n = int(input())
	s1 = str(input())
	t1 = str(input())
	(c, i) = (0, 0)
	s = list(s1)
	t = list(t1)
	l = []
	while i < n:
		if s[i] != t[i]:
			left = i + 1
			while left < n and s[left] != s[i]:
				left += 1
			if left < n:
				(t[i], s[left]) = (s[left], t[i])
				l.append((left, i))
				i += 1
			else:
				left = i + 1
				while left < n and t[left] != s[i]:
					left += 1
				if left < n:
					(s[left], t[left]) = (t[left], s[left])
					l.append((left, left))
				else:
					c = 1
					break
		else:
			i += 1
	if c == 1:
		print('No')
	else:
		print('Yes')
		t = len(l)
		if t <= 2 * n:
			print(t)
			for i in range(len(l)):
				print(l[i][0] + 1, l[i][1] + 1)
		else:
			print('No')


a = int(input())
for i in range(0, a):
	b = input()
	s = input()
	t = input()
	arr = []
	brr = []
	for i in s:
		arr.append(i)
	for j in t:
		brr.append(j)
	count = 0
	pivot = ''
	count = 0
	trr = []
	ttrr = []
	for i in range(0, len(arr)):
		if not arr[i] == brr[i] and count == 0:
			count = count + 1
			trr.append(arr[i])
			trr.append(brr[i])
		elif not arr[i] == brr[i] and count == 1:
			count = count + 1
			ttrr.append(arr[i])
			ttrr.append(brr[i])
		elif not arr[i] == brr[i]:
			count = count + 1
	if count == 2 and trr == ttrr:
		print('YES')
	else:
		print('NO')


def f():
	n = int(input())
	s = list(input())
	t = list(input())
	ans = []
	for i in range(n - 1):
		if s[i] != t[i]:
			j = i + 1
			while j < n and s[j] != s[i]:
				j += 1
			if j != n:
				(t[i], s[j]) = (s[j], t[i])
				ans += [[j + 1, i + 1]]
			else:
				j = i + 1
				while j < n and t[j] != s[i]:
					j += 1
				if j != n:
					(t[j], s[i + 1]) = (s[i + 1], t[j])
					ans += [[i + 2, j + 1]]
					(s[i + 1], t[i]) = (t[i], s[i + 1])
					ans += [[i + 2, i + 1]]
				else:
					print('No')
					return
	if s == t:
		print('Yes')
		print(len(ans))
		for e in ans:
			print(*e)
	else:
		print('No')
q = int(input())
for qq in range(q):
	f()


k = int(input())
while k:
	k -= 1
	n = int(input())
	s = input()
	t = input()
	rec_s = [None, 0]
	rec_t = [None, 0]
	ans = 'YES'
	for i in range(n):
		if s[i] == t[i]:
			continue
		if rec_s[0] is None and rec_t[0] is None:
			rec_s[0] = s[i]
			rec_s[1] += 1
			rec_t[0] = t[i]
			rec_t[1] += 1
			continue
		if rec_s[0] == s[i] and rec_t[0] == t[i] and (rec_s[1] == 1) and (rec_t[1] == 1):
			rec_s[1] += 1
			rec_t[1] += 1
			continue
		ans = 'NO'
		break
	if rec_s[1] != 2 or rec_t[1] != 2:
		ans = 'NO'
	print(ans)


k = int(input())
for i in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	index = []
	for i in range(n):
		if s1[i] != s2[i]:
			index.append(i)
	if len(index) == 2:
		(t1, t2) = (index[0], index[1])
		if s1[t1] == s1[t2] and s2[t2] == s2[t1]:
			print('yes')
		else:
			print('no')
	else:
		print('no')


t = int(input())
for i in range(t):
	a = int(input())
	b = list(input())
	c = list(input())
	d = []
	for i in range(a):
		if b[i] != c[i]:
			d.append(i)
			if len(d) == 2:
				break
	if len(d) == 2:
		e = d[0]
		f = d[1]
		(b[e], c[f]) = (c[f], b[e])
		if b == c:
			print('Yes')
			continue
		else:
			print('No')
			continue
	if len(d) < 2:
		print('No')
		continue


def solve(s, t, n, ans):
	s = list(s)
	t = list(t)
	moves = ['Yes']
	for i in range(n):
		if s[i] != t[i]:
			req = t[i]
			found = False
			for j in range(i + 1, n):
				if t[j] == req:
					index = j
					found = True
					break
			if not found:
				for j in range(i + 1, n):
					if s[j] == req:
						index = j
						found = True
						break
			else:
				moves.append(str(i + 1) + ' ' + str(index + 1))
				(s[i], t[index]) = (t[index], s[i])
				continue
			if not found:
				ans.append(['No'])
				return
			else:
				moves.append(str(index + 1) + ' ' + str(index + 1))
				(s[index], t[index]) = (t[index], s[index])
				moves.append(str(i + 1) + ' ' + str(index + 1))
				(s[i], t[index]) = (t[index], s[i])
	moves.insert(1, len(moves) - 1)
	ans.append(moves)

def main():
	ans = []
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		t = input()
		solve(s, t, n, ans)
	for i in ans:
		for j in i:
			print(j)
main()


t = int(input())
answer = []
for i in range(t):
	n = int(input())
	S = str(input())
	T = str(input())
	S1 = ''
	T1 = ''
	for j in range(n):
		if S[j] != T[j]:
			S1 += S[j]
			T1 += T[j]
	ans = 'No'
	if len(S1) == 0:
		ans = 'Yes'
	if len(S1) == 2:
		if S1[0] == S1[1] and T1[0] == T1[1]:
			ans = 'Yes'
	answer.append(ans)
for i in range(t):
	print(answer[i])


for i in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	(l, l1) = ([], [])
	for i in range(n):
		if s[i] != t[i]:
			l.append(s[i])
			l1.append(t[i])
	if len(l) == 2 and len(l1) == 2 and (len(set(l)) == 1) and (len(set(l1)) == 1):
		print('Yes')
	else:
		print('No')


q = int(input())
foo = []
for i in range(q):
	n = int(input())
	s = input()
	ss = input()
	q = 0
	jj = 0
	s1 = 'a'
	s2 = 'a'
	ss1 = 'a'
	ss2 = 'a'
	for j in range(n):
		if s[j] != ss[j]:
			s1 = s[j]
			s2 = ss[j]
			jj = j
			break
	for j in range(jj + 1, n):
		if s[j] != ss[j]:
			ss1 = s[j]
			ss2 = ss[j]
			jj = j
			break
	for j in range(jj + 1, n):
		if s[j] != ss[j]:
			q = 1
			break
	if q == 1:
		foo.append('No')
	elif s1 == ss1 and s2 == ss2:
		foo.append('Yes')
	else:
		foo.append('No')
for j in foo:
	print(j)


k = int(input())
for i in range(k):
	n = int(input())
	s = input().strip()
	t = input().strip()
	diff = 0
	l = []
	for j in range(n):
		if s[j] == t[j]:
			pass
		else:
			diff += 1
			l.append(j)
	if diff != 2:
		print('No')
	elif s[l[0]] == s[l[1]] and t[l[0]] == t[l[1]]:
		print('Yes')
	else:
		print('No')


import math
k = int(input())
for itt in range(k):
	n = int(input())
	s = input().strip()
	t = input().strip()
	arr = []
	brr = []
	for i in s:
		arr.append(i)
	for i in t:
		brr.append(i)
	a = []
	b = []
	for i in range(len(s)):
		if s[i] != t[i]:
			a.append(i)
			b.append(i)
	if len(a) > 2 or len(a) == 1:
		print('No')
		continue
	if len(a) == 0:
		print('Yes')
		continue
	lol = False
	for i in range(len(a)):
		for j in range(len(b)):
			ta = arr[a[i]]
			tb = brr[b[j]]
			temp = arr[a[i]]
			arr[a[i]] = brr[b[j]]
			brr[b[j]] = temp
			flag = True
			for ii in range(len(arr)):
				if arr[ii] != brr[ii]:
					flag = False
					break
			if flag:
				lol = True
				break
			arr[a[i]] = ta
			brr[b[j]] = tb
		if lol:
			break
	if lol:
		print('Yes')
	else:
		print('No')


import sys, math, queue, collections
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	miss = set()
	for i in range(n):
		if s[i] != t[i]:
			miss.add(i)
	if len(miss) == 1 or len(miss) > 2:
		print('No')
	elif len(miss) == 0:
		print('Yes')
	else:
		(x, y) = tuple(miss)
		if s[x] != s[y] or t[y] != t[x]:
			print('No')
		else:
			print('Yes')


for _ in range(int(input())):
	(n, s, t) = (int(input()), input(), input())
	c = []
	for i in range(n):
		if s[i] != t[i]:
			c.append(s[i])
			c.append(t[i])
	if len(sorted(set(c))) == 2 and len(c) == 4 and (c[1] != c[2]):
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from math import gcd, factorial
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = list(inp())
	b = list(inp())
	ind = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		ind.append(i)
	if len(ind) == 0:
		print('Yes')
		return
	if len(ind) == 1 or len(ind) > 2:
		print('No')
		return
	if a[ind[0]] == a[ind[1]] and b[ind[0]] == b[ind[1]]:
		print('Yes')
	else:
		print('No')
testcase(int(inp()))


def myFunction():
	k = int(input())
	for i in range(0, k):
		n = int(input())
		s = str(input())
		t = str(input())
		check = False
		counter = 0
		s_err = []
		t_err = []
		for i in range(0, n):
			if s[i] != t[i]:
				counter += 1
				s_err.append(s[i])
				t_err.append(t[i])
			if counter > 2:
				i = n
		tmp = len(s_err)
		if tmp == 0 or tmp == 2:
			if tmp == 0 or s_err[0] + t_err[0] == s_err[1] + t_err[1] or t_err[1] + s_err[1] == t_err[0] + s_err[0]:
				check = True
		if check:
			print('Yes')
		else:
			print('No')
myFunction()


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	n = int(I())
	s = list(I())
	t = list(I())
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			ind.append(i)
	if len(ind) == 2:
		if s[ind[0]] == s[ind[1]] and t[ind[1]] == t[ind[0]]:
			ans += 'Yes\n'
		else:
			ans += 'No\n'
	else:
		ans += 'No\n'
print(ans)


n = int(input())
for i in range(n):
	l = int(input())
	str1 = input()
	str2 = input()
	list01 = list(str1)
	list02 = list(str2)
	list0 = list01[:]
	list0.extend(list02)
	nlist = []
	alist = []
	for j in list0:
		if j not in alist:
			a = list0.count(j)
			nlist.append(a)
			alist.append(j)
			if a % 2 != 0:
				print('No')
				break
	if a % 2 == 0:
		print('Yes')
		op = 0
		list1 = []
		list2 = []
		for c in range(l - 1):
			if str1[c] != str2[c]:
				d = str2.find(str2[c], c + 1)
				if d != -1:
					(list02[d], list01[c]) = (list01[c], list02[d])
					str1 = ''.join(list01)
					str2 = ''.join(list02)
					op += 1
					list1.append(c + 1)
					list2.append(d + 1)
				else:
					d = str1.find(str2[c], c + 1)
					(list02[l - 1], list01[d]) = (list01[d], list02[l - 1])
					(list02[l - 1], list01[c]) = (list01[c], list02[l - 1])
					str1 = ''.join(list01)
					str2 = ''.join(list02)
					op += 2
					list1.extend([d + 1, c + 1])
					list2.extend([l, l])
		print(op)
		for k in range(op):
			print(list1[k], list2[k], sep=' ')


k = int(input())
for i in range(k):
	n = int(input())
	w1 = input()
	w2 = input()
	diff = []
	for p in range(n):
		if w1[p] == w2[p]:
			continue
		diff.append(p)
		if len(diff) > 2:
			break
	if len(diff) == 0:
		print('Yes')
	elif len(diff) != 2 or w1[diff[0]] != w1[diff[1]] or w2[diff[0]] != w2[diff[1]]:
		print('No')
	else:
		print('Yes')


def main():

	def solve():
		n = int(input())
		ss = list(input())
		tt = list(input())
		swaps = []
		for i in range(n):
			if ss[i] != tt[i]:
				for j in range(i + 1, n):
					if ss[j] == ss[i]:
						(tt[i], ss[j]) = (ss[j], tt[i])
						swaps.append((j, i))
						break
					if tt[j] == ss[i]:
						(tt[j], ss[j]) = (ss[j], tt[j])
						swaps.append((j, j))
						(tt[i], ss[j]) = (ss[j], tt[i])
						swaps.append((j, i))
						break
				else:
					print('No')
					return
		print('Yes')
		print(len(swaps))
		for (i, j) in swaps:
			print(i + 1, j + 1)
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = input()
	b = input()
	ch = []
	r = True
	for x in range(n):
		if a[x] == b[x]:
			pass
		else:
			ch.append(x)
		if len(ch) >= 3:
			r = False
			print('NO')
			break
	if r == True:
		if len(ch) == 0:
			print('YES')
		elif len(ch) == 1:
			print('NO')
		elif len(ch) == 2:
			k = ch[0]
			l = ch[1]
			a = list(a)
			b = list(b)
			(a[k], b[l]) = (b[l], a[k])
			if a == b:
				print('YES')
			else:
				print('NO')
	i = i + 1


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	b = list(input())
	possible = True
	different = []
	for i in range(n):
		if a[i] != b[i]:
			different.append(i)
		if len(different) > 2:
			possible = False
			break
	if not possible or len(different) != 2:
		print('No')
		continue
	if a[different[0]] == a[different[1]] and b[different[0]] == b[different[1]]:
		print('Yes')
	else:
		print('No')


n = int(input())
for x in range(n):
	l = int(input())
	s1 = str(input()).rstrip()
	s2 = str(input()).rstrip()
	count = 0
	ind = []
	for y in range(l):
		if s1[y] != s2[y]:
			ind.append(y)
			count += 1
	if count != 2:
		print('No')
	elif s1[ind[0]] == s1[ind[1]] and s2[ind[1]] == s2[ind[0]]:
		print('Yes')
	else:
		print('No')


t = int(input())
from collections import defaultdict, Counter
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	l = [0] * 26
	for j in range(n):
		l[ord(s1[j]) - 97] += 1
		l[ord(s2[j]) - 97] += 1
	ans = True
	c1 = Counter(s1)
	c2 = Counter(s2)
	for j in l:
		if j % 2 != 0:
			ans = False
			break
	if ans == False:
		print('No')
	else:
		d1 = defaultdict(list)
		d2 = defaultdict(list)
		l1 = list(s1)
		l2 = list(s2)
		ans = 0
		l = []
		for j in range(n):
			d1[s1[j]].append(j)
			d2[s2[j]].append(j)
		for j in range(n - 1):
			if l1[j] != l2[j]:
				if c1[l1[j]] <= c2[l1[j]]:
					a = n
					ans += 2
					for k in d2[l1[j]]:
						if k > j:
							a = k
							break
					l2[a] = l1[j + 1]
					l1[j + 1] = l2[j]
					l2[j] = l1[j]
					d1 = defaultdict(list)
					d2 = defaultdict(list)
					for k in range(n):
						d1[l1[k]].append(k)
						d2[l2[k]].append(k)
					c1[l2[a]] -= 1
					c1[l1[j + 1]] += 1
					c2[l2[a]] += 1
					c2[l1[j + 1]] -= 1
					l.append([j + 2, a + 1])
					l.append([j + 2, j + 1])
				else:
					k = n
					for x in d1[l1[j]]:
						if x > j:
							k = x
							break
					(l2[j], l1[k]) = (l1[k], l2[j])
					ans += 1
					c1[l1[j]] -= 1
					c1[l1[k]] += 1
					c2[l1[j]] += 1
					c2[l1[k]] -= 1
					d1 = defaultdict(list)
					d2 = defaultdict(list)
					for p in range(n):
						d1[l1[p]].append(p)
						d2[l2[p]].append(p)
					l.append([k + 1, j + 1])
		if ans > 2 * n:
			print('No')
		else:
			print('Yes')
			print(ans)
			if len(l) > 0:
				for j in l:
					print(*j)


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	a = ''
	b = ''
	nd = 0
	nk = 0
	for i in range(0, n):
		if s1[i] != s2[i] and nd == 0:
			a = s1[i]
			b = s2[i]
			nd += 1
		elif s1[i] != s2[i] and nd == 1:
			if a == s1[i] and b == s2[i]:
				pass
			else:
				nk = 1
				break
			nd += 1
		elif s1[i] != s2[i]:
			nk = 1
			break
	if nk == 0 and nd == 2:
		print('Yes')
	else:
		print('No')


from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
k = I()
for _ in range(k):
	n = I()
	s = input()
	t = input()
	cnt = 0
	p = []
	ans = 'No'
	for i in range(n):
		if s[i] != t[i]:
			cnt += 1
			p.append(i)
		if cnt > 2:
			ans = 'No'
			break
	if cnt == 2 and s[p[0]] == s[p[1]] and (t[p[1]] == t[p[0]]):
		ans = 'Yes'
	print(ans)


K = int(input())
for _ in range(K):
	N = int(input())
	S = input()
	T = input()
	diff = []
	for (c1, c2) in zip(S, T):
		if c1 != c2:
			diff.append((c1, c2))
	f = False
	if len(diff) == 2:
		((a, b), (c, d)) = diff
		if a == c and b == d:
			f = True
	print('Yes' if f else 'No')


for _ in range(int(input())):
	n = int(input())
	(s1, s2) = (list('*' + input()), list('*' + input()))
	result = []
	for i in range(1, n + 1):
		if s1[i] == s2[i]:
			continue
		for j in range(i + 1, n + 1):
			if s1[i] == s1[j]:
				(s1[j], s2[i]) = (s2[i], s1[j])
				result.append((j, i))
				break
			elif s2[i] == s2[j]:
				(s1[i], s2[j]) = (s2[j], s1[i])
				result.append((i, j))
				break
			elif s1[i] == s2[j]:
				(s1[j], s2[j]) = (s2[j], s1[j])
				(s1[j], s2[i]) = (s2[i], s1[j])
				result.extend([(j, j), (j, i)])
				break
			elif s1[j] == s2[i]:
				(s1[j], s2[j]) = (s2[j], s1[j])
				(s1[i], s2[j]) = (s2[j], s1[i])
				result.extend([(j, j), (i, j)])
				break
	if s1 != s2:
		print('No')
	else:
		print('Yes')
		print(len(result))
		for l in result:
			print(*l)


for _ in range(int(input())):
	(n, a, b) = (int(input()), input(), input())
	l = [i for (i, (c, d)) in enumerate(zip(a, b)) if c != d]
	if not l or (len(l) == 2 and a[l[0]] == a[l[1]] and (b[l[0]] == b[l[1]])):
		print('Yes')
	else:
		print('No')


def process(string1, string2):
	character_set = set()
	t_str1 = []
	t_str2 = []
	for i in range(len(string1)):
		if string1[i] != string2[i]:
			t_str1.append(string1[i])
			character_set.add(string1[i])
			t_str2.append(string2[i])
			character_set.add(string2[i])
	if len(t_str1) != 2:
		if len(t_str1) == 0:
			return 'Yes'
		else:
			return 'No'
	elif len(character_set) == 2 and t_str1[0] == t_str1[1] and (t_str2[0] == t_str2[1]):
		return 'Yes'
	else:
		return 'No'
sample_amount = int(input())
result = []
for i in range(sample_amount):
	_ = input()
	string1 = input()
	string2 = input()
	t = process(string1, string2)
	result.append(t)
for element in result:
	print(element)


def solve(s, t):
	neq1 = None
	neq2 = None
	for (i, c) in enumerate(s):
		if neq1 is None:
			if s[i] != t[i]:
				neq1 = i
		elif neq2 is None:
			if s[i] != t[i]:
				if s[neq1] == s[i] and t[i] == t[neq1]:
					neq2 = i
				else:
					return False
		elif s[i] != t[i]:
			return False
	return neq1 is not None and neq2 is not None
k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	if solve(s, t):
		print('Yes')
	else:
		print('No')


for u in range(int(input())):
	n = int(input())
	(s, r) = (input(), input())
	(x, y) = ([], [])
	if s == r:
		print('Yes')
	else:
		c = 0
		for i in range(n):
			if s[i] != r[i]:
				c = c + 1
				x.append(s[i])
				y.append(r[i])
		if c == 2:
			if x[0] == x[1] and y[1] == y[0]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


for rpt in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	diff = []
	for i in range(n):
		if s[i] != t[i]:
			diff.append(i)
	if len(diff) != 2:
		print('No')
	elif s[diff[0]] == s[diff[1]] and t[diff[0]] == t[diff[1]]:
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	count = 0
	x = []
	y = []
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			x.append(s[i])
			y.append(t[i])
	if count == 0:
		print('Yes')
	elif count == 2 and x[0] == x[1] and (y[0] == y[1]):
		print('YES')
	else:
		print('NO')


def s():
	k = int(input())
	for i in range(k):
		n = int(input())
		s = input()
		v = input()
		j = 0
		vv = []
		for i in range(n):
			if j == 2:
				break
			if s[i] != v[i]:
				vv.append(i)
				j += 1
		if len(vv) != 2 and s != v:
			print('No')
		elif s == v:
			print('Yes')
		else:
			(i, j) = (vv[0], vv[1])
			if s[i] == s[j] and v[i] == v[j] and (s[j + 1:] == v[j + 1:]):
				print('Yes')
			else:
				print('No')
s()


k = int(input())
for i in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	j = 0
	m = 0
	list1 = []
	while j != len(s):
		if s[j] != t[j]:
			m += 1
			list1.append(s[j])
			list1.append(t[j])
		j += 1
	if m == 2 and s != t[::-1] and (list1[0] == list1[2]) and (list1[1] == list1[3]):
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	b = int(input())
	c1 = input()
	c2 = input()
	k1 = []
	k2 = []
	c = 0
	for i in range(b):
		if c1[i] != c2[i]:
			c += 1
			k1.append(c1[i])
			k2.append(c2[i])
	if c == 0:
		print('Yes')
	elif c != 2:
		print('No')
	elif c == 2:
		if k1[0] == k1[1] and k2[0] == k2[1]:
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	d = 0
	temp = []
	flag = 1
	for i in range(n):
		if s1[i] != s2[i]:
			if d == 0:
				temp = [s1[i], s2[i]]
				flag = 0
			elif d > 1:
				flag = 0
				break
			elif temp != [s1[i], s2[i]]:
				flag = 0
				break
			else:
				flag = 1
			d += 1
	if flag == 1:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	c = []
	d = []
	count = 0
	flag = 0
	for j in range(n):
		if a[j] != b[j]:
			c.append(a[j])
			d.append(b[j])
			count = count + 1
		if count > 2:
			print('NO')
			flag = 1
			break
	if len(c) == 0 and flag == 0:
		print('YES')
		flag = 1
	elif len(c) > 2 and flag == 0:
		flag = 1
		print('NO')
	elif len(c) == 1 and flag == 0:
		print('NO')
		flag = 1
	elif c[0] == c[1] and d[0] == d[1] and (c != d[::-1]) and (flag == 0):
		print('YES')
		flag = 1
	elif flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	count = 0
	s = input()
	m = input()
	diff = []
	for j in range(n):
		if s[j] != m[j]:
			count += 1
			diff.append(s[j])
			diff.append(m[j])
	if count == 2 and diff[0] == diff[2] and (diff[1] == diff[3]):
		print('Yes')
	else:
		print('No')


for j in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	flag = 0
	for i in range(n):
		if s[i] != t[i]:
			if flag == 0:
				y = s[i] + t[i]
				flag = 1
			elif flag == 1:
				yy = s[i] + t[i]
				flag = 2
			else:
				flag = 5
				break
	if flag == 2 and y == yy:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	t = input()
	ds = ''
	dt = ''
	for (i, cs) in enumerate(s):
		if cs != t[i]:
			ds += cs
			dt += t[i]
	if len(ds) == len(dt) and len(ds) == 2:
		if ds[0] == ds[1] and dt[0] == dt[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for test in range(t):
	n = int(input())
	a = input()
	b = input()
	counter = 0
	idx = []
	for i in range(n):
		if a[i] != b[i]:
			counter += 1
			idx.append(i)
			if counter > 2:
				break
	if counter == 2:
		a = [e for e in a]
		b = [e for e in b]
		(a[idx[0]], b[idx[1]]) = (b[idx[1]], a[idx[0]])
		a = ''.join((str(e) for e in a))
		b = ''.join((str(e) for e in b))
		if a == b:
			print('yes')
		else:
			print('no')
	else:
		print('no')


Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	S1 = list(input())
	S2 = list(input())
	Query.append((N, S1, S2))
for (N, S1, S2) in Query:
	C = []
	for i in range(N):
		(s1, s2) = (S1[i], S2[i])
		if s1 != s2:
			C.append((s1, s2))
	if len(C) == 0:
		print('Yes')
	elif len(C) == 2:
		if C[0][0] == C[1][0] and C[0][1] == C[1][1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = str(input())
	t = str(input())
	ans = 0
	ns = list()
	nt = list()
	for j in range(n):
		if s[j] != t[j]:
			ans += 1
			ns.append(s[j])
			nt.append(t[j])
	if ans == 2:
		if ns[0] == ns[1] and nt[0] == nt[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


def solve():
	n = int(input())
	s = input()
	t = input()
	p1 = None
	p2 = None
	for i in range(n):
		if s[i] != t[i]:
			if not p1:
				p1 = (s[i], t[i])
			elif not p2:
				p2 = (s[i], t[i])
			else:
				return 0
	if p1 and p2 and (p1 == p2):
		return 1
	return 0
t = int(input())
for _ in range(t):
	if solve():
		print('YES')
	else:
		print('NO')


import sys, math, bisect

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		s = input()
		t = input()
		o = 0
		c = 0
		S = []
		T = []
		for k in range(n):
			if s[k] == t[k]:
				o += 1
			else:
				S.append(s[k])
				T.append(t[k])
		if len(S) != 2:
			print('No')
		elif len(set(S)) == len(set(T)) == 1:
			print('Yes')
		else:
			print('No')
main()


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

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

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	n = int(input())
	s = list(input())
	t = list(input())
	pos = []
	count = 0
	for i in range(n):
		if s[i] != t[i]:
			pos.append(i)
			count += 1
			if count > 2:
				print('No')
				return
	if count == 1:
		print('No')
		return
	if t[pos[0]] == t[pos[1]] and s[pos[0]] == s[pos[1]]:
		print('Yes')
		return
	print('No')
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	ss = list(s)
	tt = list(t)
	c = 0
	(fs, ft) = ([], [])
	for i in range(len(ss)):
		if ss[i] != tt[i]:
			fs.append(ss[i])
			ft.append(tt[i])
			c += 1
	if c == 2:
		if fs[0] == fs[1] and ft[0] == ft[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	l = int(input())
	a = list(input())
	b = list(input())
	fCount = [0] * 26
	sCount = [0] * 26
	ans = True
	for i in range(l):
		fCount[ord(a[i]) - 97] += 1
		sCount[ord(b[i]) - 97] += 1
	for i in range(26):
		if (fCount[i] + sCount[i]) % 2 != 0:
			ans = False
			break
	if not ans:
		print('No')
		continue
	print('Yes')
	ans = []
	for i in range(l):
		if a[i] != b[i]:
			for g in range(i + 1, l):
				if a[i] == a[g]:
					(a[g], b[i]) = (b[i], a[i])
					ans.append(str(g + 1) + ' ' + str(i + 1))
					break
			else:
				for g in range(i + 1, l):
					if b[g] == a[i]:
						ans.append(str(i + 1) + ' ' + str(i + 1))
						(a[i], b[i]) = (b[i], a[i])
						ans.append(str(i + 1) + ' ' + str(g + 1))
						(a[i], b[g]) = (b[g], a[i])
	print(len(ans))
	print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	arr = []
	for i in range(n):
		if s1[i] != s2[i]:
			arr.append((s1[i], s2[i]))
	if len(arr) == 0 or (len(arr) == 2 and arr[0][0] == arr[1][0] and (arr[0][1] == arr[1][1])):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	temp = []
	flag = 0
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			temp.append([s[i], t[i]])
		if count > 2:
			flag = 1
			break
	if flag == 1:
		print('No')
	elif count == 2:
		if temp[0][0] == temp[1][0] and temp[0][1] == temp[1][1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	l = [0] * 26
	for i in range(n):
		l[ord(s[i]) - ord('a')] += 1
		l[ord(t[i]) - ord('a')] += 1
	f = 1
	tups = []
	moves = 0
	ans = t
	for i in range(len(l)):
		if l[i] & 1:
			f = 0
			break
	if f:
		for i in range(n):
			if s[i] != t[i]:
				if s[i] in s[i + 1:]:
					r = s.index(s[i], i + 1)
					(t[i], s[r]) = (s[r], t[i])
					tups.append((r + 1, i + 1))
					moves += 1
				else:
					r = t.index(s[i], i)
					(s[i + 1], t[r]) = (t[r], s[i + 1])
					tups.append((i + 2, r + 1))
					(t[i], s[i + 1]) = (s[i + 1], t[i])
					tups.append((i + 2, i + 1))
					moves += 2
		print('YES')
		print(moves)
		for pair in tups:
			print(*pair)
	else:
		print('NO')


from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue
from statistics import median
from math import gcd, sqrt, floor, factorial, ceil, log2, log10
import copy
from copy import deepcopy
import sys
sys.setrecursionlimit(10 ** 7)
import math
import os
import bisect
import collections
mod = pow(10, 9) + 7

def ncr(n, r, p=mod):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)
t = int(input())
for i in range(t):
	n = int(input())
	l = list(input())
	m = list(input())
	if l == m:
		print('yes')
		continue
	dict = defaultdict(int)
	for j in range(len(l)):
		if l[j] != m[j]:
			dict[j] += 1
	no = 'No'
	yes = 'Yes'
	if len(dict) != 2:
		print(no)
	else:
		theta = list(dict)
		first = theta[0]
		second = theta[1]
		if l[first] == l[second] and m[first] == m[second]:
			print(yes)
		else:
			print(no)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	x = list(sys.stdin.readline().strip())
	y = list(sys.stdin.readline().strip())
	c = 0
	xx = []
	for j in range(n):
		if x[j] == y[j]:
			continue
		else:
			c += 1
			xx.append(j)
	if c == 2:
		if x[xx[0]] == x[xx[1]] and y[xx[1]] == y[xx[0]]:
			print('YES')
			continue
		print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	t = str(input())
	h = set()
	c = 0
	count = 0
	p = 0
	for i in range(n):
		if s[i] != t[i]:
			count += 1
			if count == 1:
				x = t[i]
				y = s[i]
			if count == 2:
				if x == t[i] and s[i] == y:
					p = 1
		if count > 2:
			print('NO')
			c = 1
			break
	if c == 0:
		if p == 1 and count == 2:
			print('YES')
		else:
			print('NO')


import sys
import math
from collections import defaultdict
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for i in range(int(input())):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	mydic = set([])
	count = 0
	for i in range(n):
		if s1[i] != s2[i]:
			mydic.add(s1[i] + s2[i])
			count += 1
	if count == 2 and len(mydic) == 1:
		print('Yes')
	else:
		print('No')


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
import bisect
t = ii()
for i in range(t):
	n = ii()
	s = list(si())
	t = list(si())
	l = []
	for i in range(n):
		if s[i] != t[i]:
			l.append(i)
	if len(l) > 2 or len(l) == 1:
		print('NO')
	elif len(l) == 2:
		if s[l[1]] == s[l[0]] and t[l[0]] == t[l[1]]:
			print('YES')
		else:
			print('NO')


from collections import Counter
K = int(input())
for _ in range(K):
	N = int(input())
	S = input()
	T = input()
	ST = []
	for (s, t) in zip(S, T):
		ST.append(s)
		ST.append(t)
	cnt = Counter(ST)
	for v in cnt.values():
		if v % 2:
			print('No')
			break
	else:
		print('Yes')
		Ans = []
		for i in range(0, 2 * N, 2):
			c = ST[i]
			if c != ST[i + 1]:
				idx = ST[i + 2:].index(c) + i + 2
				if idx % 2 == 0:
					(ST[i + 1], ST[idx]) = (ST[idx], ST[i + 1])
					Ans.append(f'{idx // 2 + 1} {i // 2 + 1}')
				else:
					(ST[i + 1], ST[i + 2], ST[idx]) = (ST[idx], ST[i + 1], ST[i + 2])
					Ans.append(f'{i // 2 + 2} {idx // 2 + 1}')
					Ans.append(f'{i // 2 + 2} {i // 2 + 1}')
		print(len(Ans))
		print('\n'.join(Ans))


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	parbl = []
	answer = 'Yes'
	for i in range(n - 1):
		if t[i] != s[i]:
			if t[i] in t[i + 1:]:
				idx = t[i + 1:].index(t[i]) + i + 1
				(s[i], t[idx]) = (t[idx], s[i])
				parbl.append((i + 1, idx + 1))
			elif t[i] in s[i + 1:]:
				idx = s[i + 1:].index(t[i]) + i + 1
				(s[idx], t[i + 1]) = (t[i + 1], s[idx])
				(s[i], t[i + 1]) = (t[i + 1], s[i])
				parbl.append((idx + 1, i + 2))
				parbl.append((i + 1, i + 2))
			else:
				answer = 'No'
				break
	if s[-1] != t[-1]:
		answer = 'No'
	print(answer)
	if answer == 'Yes':
		print(len(parbl))
		for p in parbl:
			print(p[0], p[1])


import sys
input = sys.stdin.readline
k = int(input())
for _ in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	compare = [int(s[i] != t[i]) for i in range(n)]
	if sum(compare) == 2:
		i = compare.index(1)
		j = compare.index(1, i + 1)
		if s[i] == s[j] and t[i] == t[j]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	s = [i for i in input()]
	t = [i for i in input()]
	index = []
	ok = False
	for i in range(n):
		if s[i] != t[i]:
			index.append(i)
	if len(index) == 2:
		if s[index[0]] == s[index[1]]:
			if t[index[0]] == t[index[1]]:
				ok = True
	if ok == True:
		print('Yes')
	else:
		print('No')


k = int(input())
for _ in range(k):
	n = int(input())
	A = input()
	B = input()
	X = []
	for i in range(n):
		if A[i] != B[i]:
			X.append(i)
	if len(X) == 0:
		print('Yes')
	elif len(X) == 2:
		(x, y) = X
		if A[x] == A[y] and B[y] == B[x]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


def find(a, b):
	pos = []
	count = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			count += 1
			pos.append(i)
	if count == 0:
		return True
	elif count == 2 and (a[pos[0]] == a[pos[1]] and b[pos[0]] == b[pos[1]]):
		return True
	else:
		return False
for t in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	if find(s, t):
		print('YES')
	else:
		print('NO')


from collections import defaultdict
k = int(input())
for _ in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	p = False
	if n == 1:
		if s[0] != t[0]:
			print('NO')
		else:
			print('YES')
	else:
		r = []
		for i in range(n):
			if s[i] != t[i]:
				r.append(i)
		if len(r) == 0:
			print('YES')
			continue
		if len(r) != 2:
			print('NO')
			continue
		else:
			c = s[r[0]]
			s[r[0]] = t[r[1]]
			t[r[1]] = c
			j = 0
			while j < n and (not p):
				if s[j] != t[j]:
					print('NO')
					p = True
					break
				j += 1
			if not p:
				print('YES')
				p = True


import sys
import itertools
import math
import collections
from collections import Counter

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

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def pos(s):
	return ord(s) - 97
t = ii()
for _ in range(t):
	n = ii()
	a = input()
	b = input()
	if a == b:
		print('Yes\n1\n1 1\n')
		continue
	c = Counter(a + b)
	if any((c[i] % 2 for i in c)):
		print('No')
		continue
	a = [i for i in a]
	b = [i for i in b]
	swaps = []
	for i in range(n - 1):
		if a[i] != b[i]:
			f = 1
			for j in range(i + 1, n):
				if a[i] == a[j]:
					(a[j], b[i]) = (b[i], a[j])
					swaps.append(f'{j + 1} {i + 1}')
					f = 0
					break
			if f:
				for j in range(i + 1, n):
					if a[i] == b[j]:
						(a[i + 1], b[j]) = (b[j], a[i + 1])
						(a[i + 1], b[i]) = (b[i], a[i + 1])
						swaps.append(f'{i + 2} {j + 1}')
						swaps.append(f'{i + 2} {i + 1}')
						break
	print('Yes')
	print(len(swaps))
	prr(swaps, '\n')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	count = 0
	for i in range(n):
		if s[i] != t[i]:
			if count == 0:
				first = i
				count += 1
			elif count == 1:
				second = i
				count += 1
			else:
				count += 1
	if count == 2:
		if s[first] == s[second] and t[first] == t[second]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	f = 0
	(idx1, idx2) = (-1, -1)
	for i in range(n):
		if s[i] != t[i]:
			f += 1
	if f > 2:
		print('No')
		continue
	if f == 0:
		print('Yes')
		continue
	if f == 1:
		print('No')
		continue
	f = 0
	for i in range(n):
		if s[i] != t[i]:
			if not f:
				idx1 = i
				f = 1
			else:
				idx2 = i
	if s[idx1] == s[idx2] and t[idx1] == t[idx2]:
		print('Yes')
	else:
		print('No')


from __future__ import print_function
from itertools import permutations as perm
from functools import cmp_to_key
from fractions import Fraction
from collections import *
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
ans = []

def find(ch, n, a, b, j):
	(ai, bi) = (-1, -1)
	for i in range(n):
		if i == j or a[i] == b[i]:
			continue
		if ai < 0 and a[i] == ch:
			ai = i
		elif bi < 0 and b[i] == ch:
			bi = i
	return (ai, bi)

def solve(n, a, b):
	ans.append('yes')
	mv = []
	for i in range(n):
		if a[i] != b[i]:
			(ai, bi) = find(a[i], n, a, b, i)
			if ai != -1:
				(a[ai], b[i]) = (b[i], a[ai])
				mv.append((ai + 1, i + 1))
			else:
				(a[bi], b[bi]) = (b[bi], a[bi])
				mv.append((bi + 1, bi + 1))
				(a[bi], b[i]) = (b[i], a[bi])
				mv.append((bi + 1, i + 1))
	ans.append(str(len(mv)))
	for (x, y) in mv:
		ans.append(str(x) + ' ' + str(y))
for _ in range(t):
	(n,) = gil()
	(a, b) = (gcl(), gcl())
	(fa, fb) = (Counter(a), Counter(b))
	s = 0
	for ch in 'abcdefghijklmnopqrstuvwxyz':
		(ai, bi) = (fa.get(ch, 0), fb.get(ch, 0))
		fi = (ai + bi) // 2
		s += fi
	if s == n:
		solve(n, a, b)
	else:
		ans.append('no')
print('\n'.join(ans))


n = int(input())
for _ in range(n):
	cnt = int(input())
	a = list(input())
	b = list(input())
	count = 0
	ans = 'No'
	index = []
	for i in range(cnt):
		if a[i] != b[i]:
			count += 1
			index.append(i)
	if count >= 2:
		(a[index[0]], b[index[1]]) = (b[index[1]], a[index[0]])
	if a == b:
		ans = 'Yes'
	print(ans)


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = input()
	b = input()
	count = 0
	s1 = ''
	s2 = ''
	flag = 0
	for i in range(0, n):
		if a[i] != b[i] and count == 0:
			s1 = a[i]
			s2 = b[i]
			count = count + 1
		elif a[i] != b[i]:
			if a[i] == s1 and b[i] == s2:
				flag = 1
			count = count + 1
	if flag == 1 and count == 2:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	count = 0
	flag = 1
	m = True
	p = '0'
	q = '0'
	for j in range(n):
		if s[j] != t[j]:
			count = count + 1
			if count == 1 and m:
				q = s[j]
				p = t[j]
				m = False
			if count == 2:
				if s[j] == q and t[j] == p:
					flag = 0
				else:
					flag = 1
					break
			if count == 3:
				flag = 1
				break
	if flag == 1:
		print('NO')
	elif flag == 0:
		print('YES')


import random

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

def put_equal_on(pos, S, T, swaps):
	if S[pos] == T[pos]:
		return True
	if not S[pos] in S[pos + 1:]:
		if not S[pos] in T[pos + 1:]:
			return False
		pos2 = pos + 1 + T[pos + 1:].index(S[pos])
		(T[pos2], S[pos2]) = (S[pos2], T[pos2])
		swaps.append((pos2, pos2))
	pos2 = pos + 1 + S[pos + 1:].index(S[pos])
	(T[pos], S[pos2]) = (S[pos2], T[pos])
	swaps.append((pos2, pos))
	return True

def prog():
	N = get_int()
	S = list(input())
	T = list(input())
	swaps = []
	for i in range(N - 1):
		if not put_equal_on(i, S, T, swaps):
			break
	if S != T:
		print('No')
	else:
		print('Yes')
		print(len(swaps))
		for (a, b) in swaps:
			print(a + 1, b + 1)
q = get_int()
for _ in range(q):
	prog()


import sys
for t in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	s1 = [ord(c) - 97 for c in sys.stdin.readline().strip()]
	s2 = [ord(c) - 97 for c in sys.stdin.readline().strip()]
	pl = []
	orde = True
	for i in range(26):
		st1 = {j for j in range(n) if s1[j] == i}
		st2 = {j for j in range(n) if s2[j] == i}
		if len(st2) > len(st1):
			(st1, st2) = (st2, st1)
			(s1, s2) = (s2, s1)
			orde = not orde
		rml = []
		for el in st2:
			if el in st1:
				rml.append(el)
		for el in rml:
			st1.remove(el)
			st2.remove(el)
		tot = len(st1) + len(st2)
		if tot & 1:
			pl = []
			break
		for k in st2:
			st1.add(k)
			pl.append((k, k))
			(s1[k], s2[k]) = (s2[k], s1[k])
		for j in range(tot // 2):
			k1 = st1.pop()
			k2 = st1.pop()
			pl.append((k1, k2) if orde else (k2, k1))
			(s1[k1], s2[k2]) = (s2[k2], s1[k1])
	if pl == []:
		print('No')
	else:
		print(f'Yes\n{len(pl)}\n' + ''.join([f'{tup[0] + 1} {tup[1] + 1}\n' for tup in pl]))


t = int(input())
for l in range(t):
	n = int(input())
	s = input()
	k = input()
	ds = list()
	dk = list()
	for i in range(n):
		if s[i] != k[i]:
			ds.append(s[i])
			dk.append(k[i])
	if len(dk) != 2:
		print('NO')
	elif dk[0] == dk[1] and ds[0] == ds[1]:
		print('YES')
	else:
		print('NO')


import sys
ip = lambda : sys.stdin.readline().rstrip()
from collections import *
for _ in range(int(ip())):
	n = int(ip())
	s = ip()
	t = ip()
	ct = 0
	d = Counter(s)
	e = Counter(t)
	fl = False
	for i in range(n):
		if s[i] != t[i]:
			ct += 1
			if ct == 1:
				prev1 = s[i]
				prev2 = t[i]
			if ct == 2:
				if s[i] == prev1 and t[i] == prev2:
					fl = True
	if ct == 2 and fl or ct == 0:
		print('yes')
	else:
		print('no')


def solve():
	n = int(input())
	(s, t) = (input(), input())
	if s == t:
		unique_letters = set(s)
		if len(unique_letters) == n:
			print('No')
		else:
			print('Yes')
	else:
		different = []
		for i in range(n):
			if s[i] != t[i]:
				different.append(i)
		if len(different) != 2:
			print('No')
		elif s[different[0]] == s[different[1]] and t[different[1]] == t[different[0]]:
			print('Yes')
		else:
			print('No')
k = int(input())
for i in range(k):
	solve()


for u in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	pos = []
	for i in range(n):
		if s[i] != t[i]:
			pos.append(i)
	if len(pos) != 2:
		print('No')
	else:
		(s[pos[0]], t[pos[1]]) = (t[pos[1]], s[pos[0]])
		if s == t:
			print('Yes')
		else:
			print('No')


k = int(input())

def replace(s1, s2):
	if s1 == s2:
		return 'YES'
	else:
		dif = 0
		l = []
		for j in range(n):
			if s1[j] != s2[j]:
				dif += 1
				l.append(j)
		if dif == 2:
			(a, b) = (l[0], l[1])
			if s1[a] == s1[b] and s2[a] == s2[b]:
				return 'YES'
		return 'NO'
for i in range(k):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	print(replace(s1, s2))


from collections import Counter
k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	c = Counter(s + t)
	f = False
	for key in c:
		if c[key] % 2 != 0:
			print('No')
			f = True
			break
	if f:
		continue
	else:
		print('Yes')
	op = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		f = True
		if t[i] in t[i + 1:]:
			idx = t[i + 1:].index(t[i]) + i + 1
			op.append((i + 1, idx + 1))
			(s, t) = (s[:i] + t[idx] + s[i + 1:], t[:idx] + s[i] + t[idx + 1:])
		else:
			idx = s[i + 1:].index(t[i]) + i + 1
			op.append((idx + 1, i + 1 + 1))
			op.append((i + 1, i + 1 + 1))
			(s, t) = (s[:idx] + t[i + 1] + s[idx + 1:], t[:i + 1] + s[idx] + t[i + 2:])
			(s, t) = (s[:i] + t[i + 1] + s[i + 1:], t[:i + 1] + s[i] + t[i + 2:])
	if not f:
		print('1')
		print('1 1')
	else:
		print(len(op))
		for sw in op:
			print(*sw)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	count = 0
	z = []
	for i in range(n):
		if a[i] != b[i]:
			count += 1
			z.append([a[i], b[i]])
	if count == 2 and z[0] == z[1]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	x = 0
	diff = []
	for i in range(n):
		if s[i] != t[i]:
			x += 1
			diff.append(i)
		if x == 3:
			break
	if x >= 3 or x < 2:
		print('No')
	elif s[diff[0]] == s[diff[1]] and t[diff[0]] == t[diff[1]]:
		print('Yes')
	else:
		print('No')


from datetime import datetime
import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	s = input()
	t = input()
	sa = []
	ta = []
	for i in range(n):
		if s[i] != t[i]:
			sa.append(s[i])
			ta.append(t[i])
	if len(sa) == 0:
		print('YES')
	elif len(sa) == 2 and sa[0] == sa[1] and (ta[0] == ta[1]):
		print('YES')
	else:
		print('NO')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	t = input()
	s1 = list(s)
	t1 = list(t)
	j = 0
	k = n - 1
	while j <= k:
		if s1[j] == t1[j]:
			j += 1
		if s1[k] == t1[k]:
			k -= 1
		if s1[j] != t1[j] and s1[k] != t1[k]:
			break
	if j == k:
		print('NO')
	else:
		a = s1[j]
		s1[j] = t1[k]
		t1[k] = a
		t2 = ''.join(t1)
		s2 = ''.join(s1)
		if s2 == t2:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	t = input()
	c = 0
	indx = []
	for j in range(0, n):
		if s[j] != t[j]:
			indx.append(j)
			c += 1
		if c > 2:
			break
	if c == 2:
		if s[indx[0]] == s[indx[1]] and t[indx[0]] == t[indx[1]]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


k = int(input())
result = []
for i in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	sum = 0
	tl = []
	save = ''
	s1 = list(s1)
	s2 = list(s2)
	for t in range(n):
		if s1[t] != s2[t]:
			sum += 1
			tl.append(t)
	if sum == 1:
		d = tl[0]
		save = s1[d]
		s1[d] = s2[d]
		s2[d] = save
		if s1 == s2:
			result.append('yes')
		else:
			result.append('no')
	elif sum == 2:
		d1 = tl[0]
		d2 = tl[1]
		save1 = s1[d1]
		s1[d1] = s2[d2]
		s2[d2] = save1
		if s1 == s2:
			result.append('yes')
		else:
			result.append('no')
	else:
		result.append('no')
for y in range(k):
	print(result[y])


import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
orda = ord('a')
k = int(input())
for i in range(k):
	n = int(input())
	s = input().rstrip()
	t = input().rstrip()
	snum = []
	tnum = []
	alpha = [0] * 26
	for (i, ch) in enumerate(s):
		alpha[ord(ch) - orda] += 1
		snum.append(ord(ch) - orda)
	for (i, ch) in enumerate(t):
		alpha[ord(ch) - orda] += 1
		tnum.append(ord(ch) - orda)
	ok = True
	for i in range(26):
		if alpha[i] % 2 == 1:
			ok = False
			break
	if ok:
		print('Yes')
		ans = []
		for i in range(n):
			if snum[i] == tnum[i]:
				continue
			elif tnum[i + 1:].count(tnum[i]) > 0:
				index = tnum[i + 1:].index(tnum[i]) + i + 1
				ans.append((i, index))
				(snum[i], tnum[index]) = (tnum[index], snum[i])
			else:
				index = snum[i + 1:].index(tnum[i]) + i + 1
				ans.append((index, n - 1))
				ans.append((i, n - 1))
				(snum[i], snum[index], tnum[n - 1]) = (snum[index], tnum[n - 1], snum[i])
		print(len(ans))
		ret = ''
		for (a, b) in ans:
			print(a + 1, b + 1)
	else:
		print('No')
		continue


k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	(c, c1, c2) = (0, [], [])
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			c1.append(s[i])
			c2.append(t[i])
	if c == 2 and len(set(c1)) == 1 and (len(set(c2)) == 1):
		print('YES')
	else:
		print('NO')


import collections
k = int(input())
for kk in range(k):
	n = int(input())
	s = list(input())
	t = list(input())
	operations = list()
	for i in range(n):
		if s[i] != t[i]:
			ok = False
			for j in range(i + 1, n):
				if s[i] == s[j]:
					ok = True
					operations.append((j, i))
					(s[j], t[i]) = (t[i], s[j])
					break
				if s[i] == t[j] and i + 1 < n:
					ok = True
					operations.append((i + 1, j))
					(t[j], s[i + 1]) = (s[i + 1], t[j])
					operations.append((i + 1, i))
					(s[i + 1], t[i]) = (t[i], s[i + 1])
					break
			if not ok:
				operations = None
				break
	if operations is None:
		print('No')
	else:
		assert s == t
		print('Yes')
		print(len(operations))
		for (i, j) in operations:
			print(1 + i, 1 + j)


from sys import stdin
from collections import Counter

def check(x):
	sor = x.most_common()
	top = sor[:2]
	bot = sor[:-3:-1]
	if (top[0][1] == 2) & (bot[0][1] == -2):
		if top[1][1] == bot[1][1] == 0:
			return True
		if (top[1][1] == -2) & (bot[1][1] == 2):
			return True
	return False

def doublecheck(a, b, l):
	d = 0
	for i in range(l):
		if a[i] != b[i]:
			d += 1
			if d > 2:
				return False
	return True
for _ in range(int(stdin.readline())):
	l = int(stdin.readline())
	s1 = stdin.readline().strip()
	s2 = stdin.readline().strip()
	if s1 == s2:
		print('Yes')
		continue
	a = Counter(s1)
	b = Counter(s2)
	a.subtract(b)
	if check(a):
		if doublecheck(s1, s2, l):
			print('Yes')
			continue
	print('No')


k = int(input())
while k:
	n = int(input())
	s = input()
	t = input()
	a = []
	for i in range(n):
		if s[i] != t[i]:
			a.append(i)
	if len(a) == 2 and s[a[0]] == s[a[1]] and (t[a[0]] == t[a[1]]):
		print('Yes')
	else:
		print('No')
	k -= 1


k = int(input())
for kk in range(k):
	n = int(input())
	s = input()
	t = input()
	i = None
	j = None
	ok = True
	for (l, (ss, tt)) in enumerate(zip(s, t)):
		if ss != tt:
			if i is None:
				i = l
			elif j is None:
				j = l
			else:
				ok = False
				break
	if ok and (i is None and j is None or (i is not None and j is not None and (s[i] == s[j]) and (t[j] == t[i]))):
		print('Yes')
	else:
		print('No')


def main():

	def solve():
		n = int(input())
		ss = input()
		tt = input()
		diffpos = []
		for i in range(n):
			if ss[i] != tt[i]:
				diffpos.append(i)
		if len(diffpos) > 2 or len(diffpos) == 1:
			print('No')
			return
		if len(diffpos) == 0:
			print('Yes')
			return
		if ss[diffpos[0]] == ss[diffpos[1]] and tt[diffpos[0]] == tt[diffpos[1]]:
			print('Yes')
		else:
			print('No')
	q = int(input())
	for _ in range(q):
		solve()
main()


k = int(input(''))
for tc in range(k):
	n = int(input(''))
	s = input('')
	t = input('')
	oop_pair = []
	for i in range(n):
		if s[i] != t[i]:
			oop_pair.append([s[i], t[i]])
	if len(oop_pair) == 2:
		if oop_pair[0] == oop_pair[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


import sys
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	k = int(input())
	s = list(input())[:-1]
	t = list(input())[:-1]
	x = -1
	y = -1
	f = 0
	for i in range(k):
		if s[i] != t[i]:
			if x == -1:
				x = i
			elif y == -1:
				y = i
			else:
				f = 1
	if f or (x != -1 and y == -1):
		print('No')
		continue
	if s[x] == s[y] and t[x] == t[y]:
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	n = int(input())
	a = input()
	b = input()
	ind = []
	for i in range(0, len(a)):
		if a[i] == b[i]:
			pass
		else:
			ind.append(i)
	if len(ind) > 2 or len(ind) == 1:
		print('No')
	elif a[ind[0]] == a[ind[1]] and b[ind[0]] == b[ind[1]]:
		print('Yes')
	else:
		print('No')
	t -= 1


def solve(s, t):
	diff = 0
	i1 = -1
	i2 = -1
	for i in range(len(s)):
		if s[i] != t[i]:
			if diff == 0:
				i1 = i
			else:
				i2 = i
			diff += 1
			if diff > 2:
				return 0
	if diff == 1:
		return 0
	if diff == 0:
		return 1
	if s[i1] == s[i2] and t[i1] == t[i2]:
		return 1
	return 0
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	t = input()
	if solve(s, t) == 0:
		print('No')
	else:
		print('Yes')


from collections import Counter, deque
import sys
import math
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())
for _ in range(val()):
	n = val()
	s1 = st()
	s2 = st()
	cnt = Counter(s1) + Counter(s2)
	ans = 'YES'
	for i in cnt:
		if cnt[i] & 1:
			ans = 'NO'
			break
	print(ans)
	if ans[0] == 'N':
		continue
	s1 = list(s1)
	s2 = list(s2)
	ans = []
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			curr = 0
			for j in range(i + 1, len(s1)):
				if s1[j] == s1[i]:
					s1[j] = s2[i]
					ans.append([j, i])
					curr = 1
					break
			if curr:
				continue
			for j in range(i + 1, len(s2)):
				if s2[j] == s1[i]:
					ans.append([j, j])
					ans.append([j, i])
					(s1[j], s2[j]) = (s2[j], s1[j])
					s1[j] = s2[i]
					curr = 1
					break
	print(len(ans))
	for i in ans:
		print(i[0] + 1, i[1] + 1)


import sys

def get(s, t):
	arr = [0] * 26
	ans = []
	n = len(s)
	for i in range(n):
		arr[ord(s[i]) - 97] += 1
		arr[ord(t[i]) - 97] += 1
	for i in range(26):
		if arr[i] % 2 != 0:
			return False
	for i in range(n):
		if s[i] == t[i]:
			pass
		else:
			z = True
			for k in range(i + 1, n):
				if s[k] == s[i]:
					z = False
					break
			if not z:
				(t[i], s[k]) = (s[k], t[i])
				ans.append([k, i])
				continue
			for k in range(i + 1, n):
				if t[k] == s[i]:
					z = False
					break
			if not z:
				ans.append([n - 1, k])
				(s[n - 1], t[k]) = (t[k], s[n - 1])
				ans.append([n - 1, i])
				(s[n - 1], t[i]) = (t[i], s[n - 1])
	return ans
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	s = list(sys.stdin.readline())[:-1]
	t = list(sys.stdin.readline())[:-1]
	a = get(s, t)
	if a:
		print('YES')
		print(len(a))
		for i in range(len(a)):
			print(a[i][0] + 1, a[i][1] + 1)
	else:
		print('no')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	prev1 = ''
	prev2 = ''
	c = 1
	flag = 1
	for i in range(n):
		if s[i] != t[i] and prev1 == '' and (prev2 == ''):
			prev1 = s[i]
			prev2 = t[i]
		elif s[i] != t[i] and prev1 == s[i] and (prev2 == t[i]):
			c += 1
			if c > 2:
				flag = 0
				break
		elif s[i] != t[i]:
			if prev1 != s[i] or prev2 != t[i]:
				c += 1
			c += 1
			if c > 2:
				flag = 0
				break
	if c != 2:
		flag = 0
	print(['NO', 'YES'][flag])


from collections import Counter
r = []
for jwwej in range(int(input())):
	n = int(input())
	s = list(input())
	t = list(input())
	g = 0
	if s == t:
		ff = list(Counter(s).values())
		ff.sort()
		if ff[len(ff) - 1] > 1:
			r.append('YES')
		else:
			r.append('NO')
	else:
		fs = []
		fr = []
		for i in range(0, n):
			if s[i] != t[i]:
				fs.append(s[i])
				fr.append(t[i])
			if len(fs) > 2:
				r.append('NO')
				break
		if len(fs) == 1:
			r.append('NO')
		elif len(fs) == 2:
			if fs[0] == fs[1] and fr[0] == fr[1]:
				r.append('YES')
			else:
				r.append('NO')
for i in r:
	print(i)


import math
t = int(input())
for _ in range(t):
	k = int(input())
	ans = False
	s1 = input()
	s2 = input()
	s1ptr = -1
	for i in range(k):
		if s1[i] != s2[i]:
			if s1ptr == -1:
				s1ptr = i
			else:
				temp = s2[i]
				s2 = s2[:i] + s1[s1ptr] + s2[i + 1:]
				if s1ptr == 0:
					s1 = temp + s1[s1ptr + 1:]
				else:
					s1 = s1[:s1ptr] + temp + s1[s1ptr + 1:]
				break
	if s1 == s2:
		print('Yes')
	else:
		print('No')


k = int(input())

def solve(n, s, t):
	d = []
	for i in range(n):
		if s[i] != t[i]:
			d.append(i)
	if len(d) == 2 and s[d[0]] == s[d[1]] and (t[d[1]] == t[d[0]]):
		return 'Yes'
	return 'No'
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	print(solve(n, s, t))


k = int(input())
for da in range(k):
	n = int(input())
	s1 = input()
	s2 = input()
	a = []
	for i in range(n):
		if s1[i] != s2[i]:
			a.append(i)
	if len(a) == 0:
		print('Yes')
		continue
	if len(a) != 2:
		print('No')
		continue
	if s1[a[0]] == s1[a[1]] and s2[a[0]] == s2[a[1]]:
		print('Yes')
	else:
		print('No')


import math
t = int(input())
for g in range(0, t):
	n = int(input())
	a = input()
	b = input()
	diff = 0
	char1 = []
	char2 = []
	breaks = 0
	for i in range(0, n):
		if a[i] != b[i]:
			diff += 1
			char1.append(a[i])
			char2.append(b[i])
		if diff > 2:
			print('No')
			breaks = 1
			break
	if breaks == 0:
		if diff != 2:
			print('No')
		else:
			char1.sort()
			char2.sort()
			if char1[0] == char1[1] and char2[1] == char2[0]:
				print('Yes')
			else:
				print('No')


t = int(input())
while t:
	n = int(input())
	s1 = input()
	s2 = input()
	l1 = []
	l2 = []
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			l1.append(s1[i])
			l2.append(s2[i])
	if (len(set(l1)) == 1 and len(set(l2)) == 1) and (len(l1) == 2 and len(l2) == 2):
		print('YES')
	else:
		print('NO')
	t -= 1


from math import floor, ceil
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input())
	b = list(input())
	us = defaultdict(set)
	ns = defaultdict(set)
	d = defaultdict(lambda : 0)
	ans = list()
	done = False
	for c in a + b:
		d[c] += 1
	for k in d:
		if d[k] % 2 != 0:
			print('No')
			done = True
			break
	if done:
		continue
	for (i, c) in enumerate(a):
		us[c].add(i)
	for (i, c) in enumerate(b):
		ns[c].add(i)
	for i in range(n - 1):
		for k in us:
			us[k].discard(i)
		for k in ns:
			ns[k].discard(i)
		if a[i] == b[i]:
			continue
		if len(us[a[i]]) > 0:
			pos = list(us[a[i]])[0]
			us[b[i]].add(pos)
			a[pos] = b[i]
			b[i] = a[i]
			us[a[i]].discard(pos)
			ans.append((pos + 1, i + 1))
		else:
			pos = list(ns[a[i]])[0]
			ns[a[i + 1]].add(pos)
			us[b[i]].add(i + 1)
			b[pos] = a[i + 1]
			a[i + 1] = b[i]
			b[i] = a[i]
			ns[a[i]].discard(pos)
			ans.extend([(i + 1 + 1, pos + 1), (i + 1 + 1, i + 1)])
	print('Yes')
	print(len(ans))
	for (a, b) in ans:
		print(a, b)


for i in range(int(input())):
	n = int(input())
	s = input()
	s = list(s)
	t = input()
	t = list(t)
	count = 0
	flag = 0
	ls = []
	for i in range(n):
		if s[i] != t[i]:
			if count < 2:
				ls.append(i)
				count += 1
			else:
				print('NO')
				flag = 1
				break
	if flag == 0:
		if len(ls) == 2:
			(s[ls[0]], t[ls[1]]) = (t[ls[1]], s[ls[0]])
			if ''.join(s) == ''.join(t):
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


from sys import stdin, stdout
from collections import Counter, deque
from bisect import bisect_left
from itertools import product
T = int(input())
for _ in range(T):
	n = int(input())
	(a, b) = (list(input()), list(input()))
	cc = Counter(a + b)
	if any([u % 2 for u in cc.values()]):
		print('No')
		continue
	res = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		if a[i] in a[i + 1:]:
			p = a[i + 1:].index(a[i])
			(b[i], a[i + p + 1]) = (a[i + p + 1], b[i])
			res.append((i + p + 1, i))
		else:
			p = b[i + 1:].index(a[i])
			(a[i + 1], b[i + p + 1]) = (b[i + p + 1], a[i + 1])
			(a[i + 1], b[i]) = (b[i], a[i + 1])
			res.append((i + 1, i + p + 1))
			res.append((i + 1, i))
	print('Yes')
	print(len(res))
	for (u, v) in res:
		print(str(u + 1) + ' ' + str(v + 1))


for z in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	ind = []
	for i in range(n):
		if s[i] != t[i]:
			ind.append(i)
	if len(ind) != 2 and len(ind) != 0:
		print('NO')
	elif len(ind) == 2 and (s[ind[0]] != s[ind[1]] or t[ind[1]] != t[ind[0]]):
		print('NO')
	else:
		print('YES')


def solve(s1, s2):
	L = [0] * 26
	n = len(s1)
	solution = []
	for i in s1:
		L[ord(i) - 97] += 1
	for j in s2:
		L[ord(j) - 97] += 1
	for i in L:
		if i % 2:
			return -1
	s1 = list(s1)
	s2 = list(s2)
	for i in range(n):
		if s1[i] != s2[i]:
			c = True
			for j in range(i + 1, n):
				if s1[i] == s1[j]:
					c = False
					(s1[j], s2[i]) = (s2[i], s1[j])
					solution.append((j + 1, i + 1))
					break
			if c:
				for j in range(i + 1, n):
					if s1[i] == s2[j]:
						(s1[j], s2[j]) = (s2[j], s1[j])
						solution.append((j + 1, j + 1))
						(s1[j], s2[i]) = (s2[i], s1[j])
						solution.append((j + 1, i + 1))
						break
	return solution
for i in ' ' * int(input()):
	n = int(input())
	s1 = input()
	s2 = input()
	s = solve(s1, s2)
	if s == -1:
		print('No')
	else:
		print('Yes')
		print(len(s))
		for i in s:
			(a, b) = i
			print(a, b)


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	t = input()
	ra = 0
	(a, c) = ('', '')
	ok = True
	for i in range(n):
		if ra > 2:
			break
		elif s[i] != t[i]:
			a += s[i]
			c += t[i]
			ra += 1
	if ra > 2:
		ok = False
	if ra < 2 or not ok:
		print('No')
	elif a[0] == a[1] and c[0] == c[1] and ok:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	lst = list()
	for i in range(n):
		if s1[i] != s2[i]:
			lst.append(i)
	if len(lst) == 2 and s1[lst[0]] == s1[lst[1]] and (s2[lst[0]] == s2[lst[1]]):
		print('YES')
	else:
		print('NO')


k = int(input())
for _ in range(k):
	n = int(input())
	(s, t) = (input(), input())
	(flag, diff1, diff2) = (0, '', '')
	for (c1, c2) in zip(s, t):
		if c1 != c2:
			if not flag:
				flag = 1
				diff1 = c1
				diff2 = c2
			elif flag == 1:
				if c1 != diff1 or c2 != diff2:
					break
				flag = 2
			else:
				break
	else:
		print('Yes' if flag == 2 else 'No')
		continue
	print('No')


for n in range(int(input())):
	c = int(input())
	g = 0
	ab = ''
	ba = ''
	a = list(input())
	b = list(input())
	if c == 2:
		a = set(a)
		b = set(b)
		if len(a ^ b) == 2:
			print('Yes')
			continue
		else:
			print('No')
			continue
	for i in range(c):
		if a[i] != b[i]:
			g += 1
			ab += a[i]
			ba += b[i]
	if g != 0 and g != 2:
		print('No')
	elif g == 2:
		if ab[0] + ba[1] == ab[1] + ba[0]:
			print('Yes')
		else:
			print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	length = int(input())
	str1 = str(input())
	str2 = str(input())
	indices = []
	diff = 0
	Yes = True
	for i in range(len(str1)):
		if str1[i] != str2[i]:
			diff += 1
			indices.append(i)
		if diff > 2:
			break
	if diff == 0 or (diff == 2 and str1[indices[0]] == str1[indices[1]] and (str2[indices[1]] == str2[indices[0]])):
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	maxVal = 0
	n = int(input())
	st1 = input()
	st2 = input()
	listO1 = []
	listO2 = []
	i = 0
	while i < n:
		if st1[i] != st2[i]:
			listO1.append(st1[i])
			listO2.append(st2[i])
		i += 1
	if len(listO1) == 2 and len(listO2) == 2:
		if len(set(listO1)) == 1 and len(set(listO2)) == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


tc = int(input())
for t in range(tc):
	n = int(input())
	s = [char for char in input()]
	t = [char for char in input()]
	freq = {}
	for i in range(n):
		if s[i] in freq.keys():
			freq[s[i]] += 1
		else:
			freq[s[i]] = 1
		if t[i] in freq.keys():
			freq[t[i]] += 1
		else:
			freq[t[i]] = 1
	isPossible = True
	for key in freq.keys():
		if freq[key] % 2 != 0:
			isPossible = False
	if isPossible == False:
		print('No')
		continue
	print('Yes')
	moves = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		else:
			found = False
			for j in range(i + 1, n):
				if s[j] == s[i]:
					moves.append((j, i))
					s[j] = t[i]
					t[i] = s[i]
					found = True
					break
			if found:
				continue
			for j in range(i + 1, n):
				if t[j] == s[i]:
					moves.append((j, j))
					temp = s[j]
					s[j] = t[j]
					t[j] = temp
					moves.append((j, i))
					s[j] = t[i]
					t[i] = s[i]
					break
	print(len(moves))
	for (i, j) in moves:
		print(str(i + 1) + ' ' + str(j + 1))


def yes(s, t):
	s = list(s)
	t = list(t)
	a = []
	for i in range(len(s)):
		if s[i] != t[i]:
			a.append(i)
	if len(a) == 0:
		return True
	elif len(a) == 1 or len(a) > 2:
		return False
	elif s[a[0]] == s[a[1]] and t[a[0]] == t[a[1]]:
		return True
	else:
		return False
for i in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	if yes(t, s):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	d = dict()
	for i in range(n):
		if s[i] != t[i] and (s[i], t[i]) not in d:
			d[s[i], t[i]] = 1
		elif s[i] != t[i] and (s[i], t[i]) in d:
			d[s[i], t[i]] += 1
	f = 0
	ct = 0
	for i in d:
		if d[i] != 2:
			f = 1
		ct += 1
	if f == 0 and ct == 1:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	c = input()
	s = 0
	m = 0
	for j in range(n):
		if b[j] != c[j] and s == 1:
			if p == b[j] and q == c[j]:
				m = 1
			s += 1
		elif b[j] != c[j] and s != 1:
			s += 1
			p = b[j]
			q = c[j]
	if s == 1:
		print('No')
	elif s > 2:
		print('No')
	elif s == 0:
		print('Yes')
	elif s == 2:
		if m == 1:
			print('Yes')
		else:
			print('NO')


ntest = int(input())
while ntest > 0:
	ntest = ntest - 1
	n = int(input())
	s1 = input()
	s2 = input()
	v = []
	for i in range(n):
		if s1[i] != s2[i]:
			v.append([s1[i], s2[i]])
	if len(v) != 2 and len(v) != 0:
		print('No')
	elif len(v) == 2:
		if v[0][0] == v[1][0] and v[0][1] == v[1][1]:
			print('Yes')
		else:
			print('No')
	else:
		print('Yes')


from collections import defaultdict

def case():
	n = int(input())
	s = input()
	s = [i for i in s]
	t = input()
	t = [i for i in t]
	d = defaultdict(int)
	for i in s:
		d[i] += 1
	for i in t:
		d[i] += 1
	for i in d.values():
		if i % 2:
			print('NO')
			return
	ans = []
	for i in range(n):
		flag = 0
		for j in range(i + 1, n):
			if s[i] == s[j]:
				(t[i], s[j]) = (s[j], t[i])
				ans.append([j + 1, i + 1])
				flag = 1
				break
		if flag:
			continue
		for j in range(i + 1, n):
			if s[i] == t[j]:
				(s[j], t[j]) = (t[j], s[j])
				ans.append([j + 1, j + 1])
				(t[i], s[j]) = (s[j], t[i])
				ans.append([j + 1, i + 1])
				flag = 1
				break
		if flag:
			continue
	print('YES')
	print(len(ans))
	for i in ans:
		print(*i)
for _ in range(int(input())):
	case()


def solve(s, t):
	ans = 'NO'
	inds = []
	for i in range(len(s)):
		if s[i] != t[i]:
			inds.append(i)
		if len(inds) > 2:
			break
	for i in inds:
		for j in inds:
			(tmp1, tmp2) = (list(s), list(t))
			(tmp1[i], tmp2[j]) = (t[j], s[i])
			if tmp1 == tmp2:
				ans = 'YES'
				break
		if ans == 'YES':
			break
	print(ans)
k = int(input())
for _ in range(k):
	n = int(input())
	s = input()
	t = input()
	solve(s, t)


for i in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	a = -1
	b = -1
	c = 0
	for j in range(n):
		if s[j] != t[j]:
			c += 1
			if a == -1:
				a = j
			else:
				b = j
	if s[a] == s[b] and t[a] == t[b] and (c == 2):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = [i for i in input()]
	b = [i for i in input()]
	d = 0
	buc = []
	for i in range(n):
		if a[i] != b[i]:
			d += 1
			buc.append(i)
	if d == 0:
		print('Yes')
	elif d == 1 or d > 2:
		print('No')
	else:
		ans = 'No'
		if a[buc[0]] == a[buc[1]] and b[buc[0]] == b[buc[1]]:
			ans = 'Yes'
		print(ans)


t = int(input())
for you in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	poss = 0
	let1 = 0
	let2 = 0
	count = 0
	for i in range(n):
		if s1[i] != s2[i] and let1 == 0:
			let1 = [s1[i], s2[i]]
		elif s1[i] != s2[i] and let2 == 0:
			let2 = [s1[i], s2[i]]
			if let1 == let2:
				poss = 1
			else:
				poss = 0
				break
		elif s1[i] != s2[i]:
			poss = 0
			break
	if poss:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	tt = input()
	cnt = 0
	inds = []
	for k in range(n):
		if s[k] != tt[k]:
			cnt += 1
			inds.append(k)
	if cnt != 2:
		print('NO')
	elif s[inds[0]] == s[inds[-1]] and tt[inds[0]] == tt[inds[-1]]:
		print('YES')
	else:
		print('NO')


k = int(input())
for _ in range(0, k):
	sss = []
	n = int(input())
	ss = input()
	tt = input()
	s = [i for i in ss]
	t = [i for i in tt]
	for i in range(0, n):
		if s[i] == t[i]:
			continue
		j = ss.find(s[i], i + 1)
		if j != -1:
			(s[j], t[i]) = (t[i], s[j])
			ss = ''.join(s)
			tt = ''.join(t)
			sss.append([j + 1, i + 1])
			continue
		j = tt.find(s[i], i + 1)
		if j != -1:
			(s[j], t[j]) = (t[j], s[j])
			sss.append([j + 1, j + 1])
			(s[j], t[i]) = (t[i], s[j])
			sss.append([j + 1, i + 1])
			ss = ''.join(s)
			tt = ''.join(t)
			continue
		j = tt.find(t[i], i + 1)
		if j != -1:
			(s[i], t[j]) = (t[j], s[i])
			sss.append([i + 1, j + 1])
			ss = ''.join(s)
			tt = ''.join(t)
			continue
		j = ss.find(t[i], i + 1)
		if j != -1:
			(s[j], t[j]) = (t[j], s[j])
			sss.append([j + 1, j + 1])
			(s[i], t[j]) = (t[j], s[i])
			sss.append([i + 1, j + 1])
			ss = ''.join(s)
			tt = ''.join(t)
			continue
	if s == t:
		print('YES')
		print(len(sss))
		for i in sss:
			print(*i)
	else:
		print('NO')


n = int(input())
for i in range(n):
	f = 0
	z = 0
	z1 = []
	n1 = int(input())
	s = str(input())
	t = str(input())
	for j in range(n1):
		if s[j] != t[j]:
			z = z + 1
			z1.append(j)
			if z > 2:
				break
	if z == 2 and s[z1[0]] == s[z1[1]] and (t[z1[0]] == t[z1[1]]):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	s = s1 + s2
	count = 0
	d1 = []
	d2 = []
	for j in range(n):
		if s1[j] != s2[j]:
			count += 1
			d1.append(s1[j])
			d2.append(s2[j])
		if count > 2:
			break
	if count == 2:
		if d1[0] == d1[1] and d2[0] == d2[1]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


def solve():
	n = int(input())
	a = input()
	b = input()
	(x, y) = ('', '')
	w = 0
	flag = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			if w == 0:
				x = a[i]
				y = b[i]
				w += 1
			elif w == 1:
				if x == a[i] and y == b[i]:
					flag = 2
					w += 1
				else:
					flag = 1
					break
			else:
				flag = 1
				break
	if flag == 1 or w == 1:
		return 'No'
	else:
		return 'Yes'
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	a = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		j = i + 1
		while j < n and t[i] != t[j]:
			j += 1
		if j < n:
			(t[j], s[i]) = (s[i], t[j])
			a.append([i + 1, j + 1])
			continue
		j = i + 1
		while j < n and t[i] != s[j]:
			j += 1
		if j < n:
			(t[i], s[i]) = (s[i], t[i])
			a.append([i + 1, i + 1])
			(t[i], s[j]) = (s[j], t[i])
			a.append([j + 1, i + 1])
	if s != t:
		print('No')
		continue
	print('Yes')
	print(len(a))
	for x in a:
		print(x[0], x[1])


for i in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	counter = 0
	(x, y) = ([], [])
	for (i, j) in zip(a, b):
		if i != j:
			counter += 1
			x.append(i)
			y.append(j)
	if len(set(x)) == len(set(y)) == 1 and counter == 2:
		print('Yes')
	else:
		print('No')


q = int(input())
for _ in range(q):
	n = int(input())
	s1 = input()
	s2 = input()
	b = 0
	ot = False
	t = 0
	for i in range(n):
		if s1[i] == s2[i]:
			t += 1
		if (s1[i] != s2[i]) & (b == 0):
			b = 1
			si1 = s1[i]
			si2 = s2[i]
		elif (s1[i] != s2[i]) & (b == 1):
			if (si1 == s1[i]) & (si2 == s2[i]):
				ot = True
	if (ot or s1 == s2) and t == n - 2:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	c = 0
	q = ''
	w = ''
	for i in range(len(s1)):
		if s1[i] == s2[i]:
			continue
		else:
			c += 1
	if c != 2:
		print('No')
	else:
		for i in range(len(s1)):
			if s1[i] == s2[i]:
				continue
			else:
				q = q + s1[i]
				w = w + s2[i]
		if q[0] == q[1] and w[0] == w[1]:
			print('Yes')
		else:
			print('No')


o = int(input())
for _ in range(o):
	n = int(input())
	s = list(input())
	t = list(input())
	x = 0
	a = []
	b = []
	for i in range(n - 1, -1, -1):
		if s[i] == t[i]:
			del s[i]
			del t[i]
	if len(s) == 0:
		print('Yes')
	elif len(s) == 2 and s[0] + t[0] == s[1] + t[1]:
		print('Yes')
	else:
		print('No')


n = int(input())
for i in range(n):
	k = int(input())
	a = input()
	b = input()
	count = 0
	f = []
	for i in range(len(a)):
		if a[i] != b[i]:
			count += 1
			f.append(i)
	if len(f) == 0:
		print('Yes')
	elif count > 2 or len(f) < 2:
		print('No')
	elif a[f[0]] == a[f[1]] and b[f[0]] == b[f[1]]:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = input()
	c = 0
	l = []
	for i in range(n):
		if s[i] != t[i]:
			c += 1
			l.append(i)
	if c == 2 or len(l) == 2:
		f = 0
		if s[l[0]] == s[l[1]] and t[l[0]] == t[l[1]]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	t = list(input())
	count = 0
	change = []
	for j in range(n):
		if s[j] != t[j]:
			change.append((s[j], t[j]))
			count += 1
	if count != 2:
		print('No')
	elif change[0][0] == change[1][0] and change[0][1] == change[1][1]:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	S1 = input()
	S2 = input()
	s1 = list(S1)
	s2 = list(S2)
	if S1 == S2:
		print('Yes')
	else:
		for j in range(n):
			if s1[j] == s2[j]:
				s1[j] = '0'
				s2[j] = '0'
		x = s1.count('0')
		for z in range(x):
			s1.remove('0')
			s2.remove('0')
		if len(s1) > 2:
			print('No')
		elif len(s1) == 2:
			if s1[0] == s1[1] and s2[0] == s2[1]:
				print('Yes')
			else:
				print('No')
		else:
			print('No')


ans = []
for i in [0] * int(input()):
	l = int(input())
	(a, b, x, y, mis) = (input(), input(), set(), set(), 0)
	for j in range(l):
		if a[j] != b[j]:
			x.add(a[j])
			y.add(b[j])
			mis += 1
	ans.append('no' if len(x) > 1 or len(y) > 1 or mis != 2 else 'yes')
print('\n'.join(ans))


q = int(input())
for i in range(q):
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	s1n = list()
	s2n = list()
	for i in range(n):
		if s1[i] != s2[i]:
			s1n.append(s1[i])
			s2n.append(s2[i])
	if len(s1n) == len(s2n) == 2 and s1n[0] == s1n[1] and (s2n[0] == s2n[1]) or len(s1n) == len(s2n) == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	s1 = input()
	diff = []
	for i in range(n):
		if s[i] != s1[i]:
			diff.append(i)
	diff_len = len(diff)
	if diff_len == 0:
		print('YES')
	elif diff_len == 2:
		if s[diff[0]] == s[diff[1]] and s1[diff[0]] == s1[diff[1]]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def replace_symb(n, word1, word2):
	letter_pairs = list(zip(word1, word2))
	stack = []
	count = 0
	for pair in letter_pairs:
		if pair[0] != pair[1]:
			count += 1
			if pair in stack:
				stack.remove(pair)
			else:
				stack.append(pair)
	print('No' if bool(stack) or count > 2 else 'Yes')
for i in range(int(input())):
	replace_symb(int(input()), input(), input())


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	i = 0
	(a, b) = ([], [])
	count = 0
	while i < n and count < 3:
		if s1[i] != s2[i]:
			a.append(s1[i])
			b.append(s2[i])
			count += 1
		i += 1
	if count == 2:
		if a[0] == a[1] and b[0] == b[1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


N = int(input())
for _ in range(N):
	n = int(input())
	s1 = input()
	s2 = input()
	diff_s1 = None
	diff_s2 = None
	for i in range(n):
		c1 = s1[i]
		c2 = s2[i]
		if c1 == c2:
			continue
		else:
			if diff_s1:
				if diff_s1 == c1 and diff_s2 == c2 and (s1[i + 1:] == s2[i + 1:]):
					print('Yes')
				else:
					print('No')
				break
			diff_s1 = c1
			diff_s2 = c2
	else:
		if diff_s1 or len(set(s1)) == n:
			print('No')


for i in range(int(input())):
	N = int(input())
	S1 = input()
	S2 = input()
	A = list()
	B = list()
	A.extend(S1)
	B.extend(S2)
	count = 0
	a = list()
	for (i, j) in zip(A, B):
		if i != j:
			count += 1
			a.append((i, j))
		if count > 2:
			break
	if count == 1 or count > 2:
		print('No')
	elif count == 2:
		if a[0] == a[1]:
			print('Yes')
		else:
			print('No')


t = int(input())

def equal(s, t):
	s = [x for x in s]
	t = [x for x in t]
	ans = []
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			if s[i] == s[j]:
				(s[j], t[i]) = (t[i], s[j])
				ans.append([j + 1, i + 1])
				break
			if s[i] == t[j]:
				(s[j], t[j]) = (t[j], s[j])
				ans += [[j + 1, j + 1]]
				(s[j], t[i]) = (t[i], s[j])
				ans += [[j + 1, i + 1]]
				break
	l = len(ans)
	ans = '\n'.join(['%s %s' % (x[0], x[1]) for x in ans])
	if s == t:
		return 'YES\n%s\n%s' % (l, ans)
	else:
		return 'NO'
for i in range(t):
	l = input()
	print(equal(input(), input()))


no_of_test_cases = int(input())
for test_cases in range(no_of_test_cases):
	length = int(input())
	s = input()
	t = input()
	check = [[x, y] for (x, y) in zip(s, t) if x != y]
	answer = len(check) == 0
	if len(check) == 2:
		answer = check[0] == check[1]
	print('Yes' if answer else 'No')


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	diff = 0
	t1 = ''
	t2 = ''
	for i in range(n):
		if s1[i] != s2[i]:
			diff += 1
			t1 += s1[i]
			t2 += s2[i]
	if diff > 2 or diff == 1:
		print('No')
		continue
	if t1[0] == t1[1] and t2[0] == t2[1]:
		print('Yes')
	else:
		print('No')


k = int(input())
for i in range(k):
	n = int(input())
	s = input()
	t = input()
	if s == t:
		print('YES')
		continue
	else:
		count = 0
		diff = []
		for j in range(n):
			if s[j] != t[j]:
				count += 1
				diff.append(j)
		if count == 2:
			if s[diff[0]] == s[diff[1]] and t[diff[1]] == t[diff[0]]:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


q = int(input())
while q > 0:
	q = q - 1
	n = int(input())
	s = input()
	t = input()
	a = [i for i in s]
	b = [i for i in t]
	aa = []
	bb = []
	c = 0
	for i in range(n):
		if a[i] != b[i]:
			c += 1
			aa.append(a[i])
			bb.append(b[i])
	if c != 2:
		print('No')
	elif aa[0] == aa[1] and bb[1] == bb[0]:
		print('Yes')
	else:
		print('No')


t = int(input())
for k in range(t):
	n = int(input())
	a = input()
	b = input()
	diff = []
	fail = 0
	for i in range(n):
		if a[i] != b[i]:
			if len(diff) >= 2:
				fail = 1
				break
			diff.append([a[i], b[i]])
	if fail or len(diff) == 1:
		print('NO')
		continue
	if (diff[0][0] == diff[1][0]) & (diff[0][1] == diff[1][1]):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from collections import Counter

def upar(ind, ch):
	for i in range(ind, n):
		if s[i] == ch:
			return i
	return -1

def neeche(ind, ch):
	for i in range(ind, n):
		if s1[i] == ch:
			return i
	return -1
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = list(input())
	s1 = list(input())
	d = Counter(s)
	f = 1
	d1 = Counter(s1)
	for asc in range(97, 123):
		ch = chr(asc)
		if d.get(ch, 0) + d1.get(ch, 0) & 1:
			f = 0
			break
	if f == 0:
		print('No')
		continue
	l = []
	for i in range(n):
		if s[i] == s1[i]:
			continue
		p = upar(i + 1, s[i])
		if p != -1:
			l += [[p + 1, i + 1]]
			(s[p], s1[i]) = (s1[i], s[p])
			continue
		p = neeche(i + 1, s1[i])
		if p != -1:
			l += [[i + 1, p + 1]]
			(s[i], s1[p]) = (s1[p], s[i])
			continue
		l += [[i + 1, i + 1]]
		(s[i], s1[i]) = (s1[i], s[i])
		p = upar(i + 1, s[i])
		l += [[p + 1, i + 1]]
		(s[p], s1[i]) = (s1[i], s[p])
	print('Yes')
	print(len(l))
	for (k, v) in l:
		print(k, v)