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

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


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


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


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


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


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


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


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


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


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


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


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


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(_)


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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)


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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)


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


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


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


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


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


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


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


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


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


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


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


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


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


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)


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


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)


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


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


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


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


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


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


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)


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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