#pragma comment(linker,"/STACK:60000000")
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <string.h>
#include <math.h>
#include <cmath>
#include <ctype.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <queue>

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

#define FOR(i,a,b,k) for (i=a;i<=b;i+=k)
#define RFOR(i,a,b,k) for (i=a;i>=b;i-=k)

#define vao(st) freopen(st,"r",stdin)
#define ra(st) freopen(st,"w",stdout)
#define dongvao fclose(stdin)
#define dongra fclose(stdout)

#define LL long long
#define I int
#define LI long int
#define VTI vector<int>
#define VTL vector<long int>
#define VTB vector<bool>
#define B bool
#define ST string

#define SQR(x) x*x
#define SQRT(x) sqrt(x)
#define length(s) s.size()
#define SE(a) a.size()

using namespace std;
LI n;
VTL a;
void read()
{
    cin>>n;
    a.resize(2);
    a[0]=0;a[1]=0;
    LI i;I j;
    FOR(i,1,n,1)
    {
        cin>>j;
        if (j==0) a[0]+=1; else a[1]+=1;
    }
}
void process()
{
    while ((5*a[1])%9!=0)
        a[1]--;
    if (a[1]==0) cout<<"0"; else
    {
        LI i;
        for(i=0;i<a[1];i++) cout<<"5";
        for(i=0;i<a[0];i++) cout<<"0";
    }
}
void write()
{
    process();
}
int main()
{
    read();
    write();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int i,flag,n,t,j;
	string a,b,s1,s2;
	for(cin>>t;t--;)
	{
		cin>>n>>a>>b;flag=0;
		sort(a.begin(),a.end());sort(b.begin(),b.end());
		for(i=0;i<n;i++)
		{
			if(a[i]!=b[i])
			{
				for(j=i;j<n;j++)
				{
				s1=a;s2=b;
				swap(s1[i],s2[j]);
				sort(s1.begin(),s1.end());sort(s2.begin(),s2.end());
				if(s1==s2)
				{
					flag=1;
					break;
				}
				}
			}
			if(flag)
				break;
		}
		if(flag)	cout<<"YES\n";
		else	cout<<"NO\n";
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	long long int i,flag,n,t,j;
	string a,b;
	for(cin>>t;t--;)
	{
		cin>>n>>a>>b;flag=0;
		vector<char> s1,s2,c,d;

		for(i=0;i<n;i++)
			if(a[i]!=b[i])
			{
				s1.push_back(a[i]);s2.push_back(b[i]);
			}
		for(i=0;i<s1.size();i++)
		{
			c=s1;d=s2;
			for(j=i+1;j<s1.size();j++)
			{
				swap(c[i],d[j]);
				if(c==d)
				{
					flag=1;	break;
				}
			}
			if(flag)	break;
		}
		if(flag)	cout<<"YES"<<endl;
		else	cout<<"NO"<<endl;
		}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int t,n,i,j,flag=0,flag2=0;
	string a,b;
	for(cin>>t;t--;)
	{
		cin>>n>>a>>b;flag=0;flag2=0;
		for(i=0;i<a.length();i++)
		{
			if(a[i]!=b[i] && flag2==0)
			{
				for(j=i+1;j<b.length();j++)
					if(a[j]==a[i])
					{
						string s=a;
						swap(s[i],b[j]);
						if(s==b)
						{
							flag=1;
							break;
						}
					}
				flag2=1;
			}
			if(flag)
				break;
		}
		if(flag)	cout<<"YES";
		else	cout<<"NO";
		cout<<endl;

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int t,n,i,j,flag=0,flag2=0;
	string a,b;
	for(cin>>t;t--;)
	{
		cin>>n>>a>>b;flag=0;flag2=0;
		if(a==b)	flag=1;
		else
		{
		for(i=0;i<a.length();i++)
		{
			if(a[i]!=b[i] && flag2==0)
			{
				for(j=i+1;j<b.length();j++)
					if(a[j]==a[i])
					{
						string s=a;
						swap(s[i],b[j]);
						if(s==b)
						{
							flag=1;
							break;
						}
					}
				flag2=1;
			}
			if(flag)
				break;
		}
		}
		if(flag)	cout<<"YES";
		else	cout<<"NO";
		cout<<endl;

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	int q;
	cin >> q;
	for (int a = 0; a < q; a++)
	{
		int n;
		cin >> n;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int i = 0; i < n; i++)
		{
			if (s1[i] != s2[i])
			{
				for (int j = i + 1; j < n; j++)
				{
					if (s2[j] == s1[i]) swap(s2[j] , s2[i]);
					break;
				}
			}
		}
		if (s1 == s2)
		{
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200 + 20;
int arr[maxn];

int main()
{
	int k , n;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		memset(arr,0,sizeof arr);
		cin >> n;
		bool flag = true;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int j = 0; j < n; j++)
		{
			arr[s1[j]]++;
		}
		for (int j = 0; j < n; j++)
		{
			arr[s2[j]]++;
		}
		for (int i = 0; i < maxn; i++)
		{
			if (arr[i] % 2)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		int cnt = 0;
		for (int j = 0; j < n; j++)
		{
			if (s1[j] != s2[j]) cnt++;
		}
		if (flag)
		{
			if (cnt > 2)
			{
				cout << "No" << endl;
			}
			else cout << "Yes" << endl;
		}
	}
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	int q;
	cin >> q;
	for (int a = 0; a < q; a++)
	{
		int n;
		cin >> n;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int i = 0; i < n; i++)
		{
			if (s1[i] != s2[i])
			{
				for (int j = i + 1; j < n; j++)
				{
					if (s2[j] == s2[i] && s1[j] == s1[i]) swap(s2[j] , s1[i]);
				}
				break;
			}
		}
		if (s1 == s2)
		{
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200 + 20;
int arr[maxn];

int main()
{
	int k , n;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		memset(arr,0,sizeof arr);
		cin >> n;
		bool flag = true;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int j = 0; j < n; j++)
		{
			arr[s1[j]]++;
		}
		for (int j = 0; j < n; j++)
		{
			arr[s2[j]]++;
		}
		int cnt = 0;
		for (int j = 0; j < n; j++)
		{
			if (s1[j] != s2[j]) cnt++;
		}
		if (flag)
		{
			if (cnt > 2)
			{
				cout << "No" << endl;
			}
			else cout << "Yes" << endl;
		}
	}
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200 + 20;
int arr[maxn];

int main()
{
	int k , n;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		memset(arr,0,sizeof arr);
		cin >> n;
		bool flag = true;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int j = 0; j < n; j++)
		{
			arr[s1[j]]++;
		}
		for (int j = 0; j < n; j++)
		{
			arr[s2[j]]++;
		}
		for (int i = 0; i < maxn; i++)
		{
			if (arr[i] % 2)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		int cnt = 0;
		for (int j = 0; j < n; j++)
		{
			if (s1[j] != s2[j]) cnt++;
		}
		if (flag)
		{
			if (cnt > 2 || cnt == 1)
			{
				cout << "No" << endl;
			}
			else cout << "Yes" << endl;
		}
	}
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200 + 20;

int main()
{
	int k , n;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		int arr[maxn];
		cin >> n;
		bool flag = true;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int j = 0; j < n; j++)
		{
			arr[s1[j]]++;
		}
		for (int j = 0; j < n; j++)
		{
			arr[s2[j]]++;
		}
		for (int i = 0; i < maxn; i++)
		{
			if (arr[i] % 2)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		if (flag) cout << "Yes" << endl;
	}

}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200 + 20;
int arr[maxn];

int main()
{
	int k , n;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		memset(arr,0,sizeof arr);
		cin >> n;
		bool flag = true;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int j = 0; j < n; j++)
		{
			arr[s1[j]]++;
		}
		for (int j = 0; j < n; j++)
		{
			arr[s2[j]]++;
		}
		for (int i = 0; i < maxn; i++)
		{
			if (arr[i] % 2)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		int cnt = 0;
		for (int j = 0; j < n; j++)
		{
			if (s1[j] != s2[j]) cnt++;
		}
		if (flag)
		{
			if (cnt > 2 && cnt == 1)
			{
				cout << "No" << endl;
			}
			else cout << "Yes" << endl;
		}
	}
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200 + 20;
int arr[maxn];

int main()
{
	int k , n;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> n;
		bool flag = true;
		string s1 , s2;
		cin >> s1 >> s2;
		for (int j = 0; j < n; j++)
		{
			arr[s1[j]]++;
		}
		for (int j = 0; j < n; j++)
		{
			arr[s2[j]]++;
		}
		for (int i = 0; i < maxn; i++)
		{
			if (arr[i] % 2)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		if (flag) cout << "Yes" << endl;
	}

}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

const int N = 1e4 + 5;
char s[N], t[N];
int n;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  for (cin >> k; k--;) {
    cin >> n >> s + 1 >> t + 1;
    vector<int> w;
    for (int i = 1; i <= n; ++i)
      if (s[i] != t[i])
        w.push_back(i);
    if (int(w.size()) == 0) cout << "Yes\n";
    else if (int(w.size()) != 2) cout << "No\n";
    else {
      if ((s[w[0]] == s[w[1]]) && (t[w[0]] == t[w[1]])) cout << "Yes\n";
      else cout << "No\n";
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 5;
char a[N], b[N];
int k, n;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> k; k--;) {
    cin >> n >> a >> b;
    int cnt = 0, w[2];
    for (int i = 0; i < n; ++i)
      if (a[i] != b[i]) {
        w[cnt] = i;
        cnt++;
      }
    bool ans = (cnt == 0);
    if (cnt == 2) {
      if (a[w[0]] == b[w[1]] && a[w[1]] == b[w[0]])
        ans = true;
      if (a[w[0]] == a[w[1]] && b[w[0]] == b[w[1]])
        ans = true;
    }
    if (ans)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 5;
char a[N], b[N];
int k, n, w[2];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> k; k--;) {
    cin >> n >> a >> b;
    int cnt = 0;
    for (int i = 0; i < n; ++i)
      if (a[i] != b[i]) {
        w[cnt] = i;
        cnt++;
      }
    bool ans = (cnt == 0);
    if (cnt == 2) {
      if (a[w[0]] == b[w[1]] && a[w[1]] == b[w[0]])
        ans = true;
      if (a[w[0]] == a[w[1]] && b[w[0]] == b[w[1]])
        ans = true;
    }
    if (ans)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 5;
char a[N], b[N];
int k, n;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> k; k--;) {
    cin >> n >> a >> b;
    int cnt = 0;
    for (int i = 0; i < n; ++i)
      if (a[i] != b[i])
        cnt++;
    if (cnt == 0 || cnt == 2)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

const int N = 1e4 + 5;
char s[N], t[N];
int n;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  for (cin >> k; k--;) {
    cin >> n >> s + 1 >> t + 1;
    vector<ii> w;
    for (int i = 1; i <= n; ++i)
      if (s[i] != t[i])
        w.push_back(ii(i, i));
    if (w.size() == 0) cout << "Yes\n";
    else if (w.size() != 2) cout << "No\n";
    else {
      char a1 = s[w[0].first], b1 = t[w[0].second], a2 = s[w[1].first], b2 = t[w[1].second];
      if ((a1 == a2) && (b1 == b2)) cout << "Yes\n";
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 5;
char a[N], b[N];
int k, n, w[2];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> k; k--;) {
    cin >> n >> a >> b;
    int cnt = 0;
    for (int i = 0; i < n; ++i)
      if (a[i] != b[i]) {
        w[cnt] = i;
        cnt++;
      }
    bool ans = (cnt == 0);
    if (cnt == 2) {
      if (a[w[0]] == a[w[1]] && b[w[0]] == b[w[1]])
        ans = true;
    }
    if (ans)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 5;
char a[N], b[N];
int k, n, w[2], ra[256], rb[256];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> k; k--;) {
    memset(ra, 0, sizeof ra);
    memset(rb, 0, sizeof rb);
    cin >> n >> a >> b;
    int cnt = 0;
    bool eq = false;
    for (int i = 0; i < n; ++i) {
      if (a[i] != b[i]) {
        w[cnt] = i;
        cnt++;
      }
      ra[a[i]] = 1;
      rb[b[i]] = 1;
    }
    for (int i = 0; i < 256; ++i)
      if (ra[i] && rb[i])
        eq = true;
    bool ans = (cnt == 0 && eq);
    if (cnt == 2) {
      if (a[w[0]] == a[w[1]] && b[w[0]] == b[w[1]])
        ans = true;
    }
    if (ans)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 5;
char a[N], b[N];
int k, n, w[N], ra[256], rb[256];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (cin >> k; k--;) {
    memset(ra, 0, sizeof ra);
    memset(rb, 0, sizeof rb);
    cin >> n >> a >> b;
    int cnt = 0;
    bool eq = false;
    for (int i = 0; i < n; ++i) {
      if (a[i] != b[i] && cnt) {
        w[cnt] = i;
        cnt++;
      }
      ra[a[i]] = 1;
      rb[b[i]] = 1;
    }
    for (int i = 0; i < 256; ++i)
      if (ra[i] && rb[i])
        eq = true;
    bool ans = (cnt == 0 && eq);
    if (cnt == 2) {
      if (a[w[0]] == a[w[1]] && b[w[0]] == b[w[1]])
        ans = true;
    }
    if (ans)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,t,sum,f,g,h;
	cin>>t;
	while(t--)
	{
		sum=0,f=0,g=0,h=0;
		cin>>n;
		string s,s1;
		cin>>s>>s1;
		if (s1==s)
		{
			cout<<"Yes\n";
			continue;
		}
		std::map<char, int> map,map1;
		for (int i = 0; i < s.size(); ++i)
		{
			map[s[i]]++;
			map1[s1[i]]++;
		}
		for (auto i = map.begin(); i != map.end(); ++i)
		{
			//
			if (i->second-map1[i->first]==2)
				f+=1;
			else if (i->second>0&&i->second-map1[i->first]==-2&&h==0&&f<=1)
				h=1;
			else if (i->second>0&&i->second!=map1[i->first])
			{
				f=0;
				break;
			}
		}
		h=0;
		for (auto i = map1.begin(); i != map1.end(); ++i)
		{
			if (i->second>0&&i->second-map[i->first]==2)
				g+=1;
			else if (i->second>0&&i->second-map[i->first]==-2&&h==0&&g<=1)
				h=1;
			else if (i->second>0&&i->second!=map[i->first])
			{
				g=0;
				break;
			}
		}
		//cout<<sum<<endl;
		if (f==1&&g==1)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,c=0;
	cin>>t;
	while(t--)
	{
		c=0;
		cin>>n;
		char a,b;
		string s1,s;
		cin>>s>>s1;
		for (int i = 0; i < n; ++i)
		{
			if (s[i]!=s1[i])
			{
				if (c==1)
				{
					if (s[i]!=a||s1[i]!=b)
					{
						c=3;
					}
				}
				a=s[i];
				b=s1[i];
				c++;
			}
		}
		if (c==2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,t,sum,f,g;
	cin>>t;
	while(t--)
	{
		sum=0,f=0,g=0;
		cin>>n;
		string s,s1;
		cin>>s>>s1;
		std::map<char, int> map,map1;
		for (int i = 0; i < s.size(); ++i)
		{
			map[s[i]]++;
			map1[s1[i]]++;
		}
		for (auto i = map.begin(); i != map.end(); ++i)
		{
			//
			if (abs(i->second-map1[i->first])==2)
				f+=1;
		}

		for (auto i = map1.begin(); i != map1.end(); ++i)
		{
			if (i->second>0&&abs(i->second-map[i->first])==2)
				g+=1;
		}
		//cout<<sum<<endl;
		if (f==1&&g==1)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,t,sum,f,g;
	cin>>t;
	while(t--)
	{
		sum=0,f=0,g=0;
		cin>>n;
		string s,s1;
		cin>>s>>s1;
		std::map<char, int> map,map1;
		for (int i = 0; i < s.size(); ++i)
		{
			map[s[i]]++;
			map1[s1[i]]++;
		}
		for (auto i = map.begin(); i != map.end(); ++i)
		{
			//
			if ((i->second-map1[i->first])==2)
				f+=1;
		}

		for (auto i = map1.begin(); i != map1.end(); ++i)
		{
			if (i->second>0&&(i->second-map[i->first])==2)
				g+=1;
		}
		//cout<<sum<<endl;
		if (f==1&&g==1)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,t,sum;
	cin>>t;
	while(t--)
	{
		sum=0;
		cin>>n;
		string s,s1;
		cin>>s>>s1;
		std::map<char, int> map,map1;
		for (int i = 0; i < s.size(); ++i)
		{
			map[s[i]]++;
			map1[s1[i]]++;
		}
		for (auto i = map.begin(); i != map.end(); ++i)
		{
			//
			if (abs(i->second-map1[i->first])==2)
				sum++;
		}
		for (auto i = map1.begin(); i != map1.end(); ++i)
		{
			if (i->second>0&&abs(i->second-map[i->first])==2)
				sum++	;
		}
		//cout<<sum<<endl;
		if (sum==2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,t,sum,f,g;
	cin>>t;
	while(t--)
	{
		sum=0,f=0,g=0;
		cin>>n;
		string s,s1;
		cin>>s>>s1;
		std::map<char, int> map,map1;
		for (int i = 0; i < s.size(); ++i)
		{
			map[s[i]]++;
			map1[s1[i]]++;
		}
		for (auto i = map.begin(); i != map.end(); ++i)
		{
			//
			if (abs(i->second-map1[i->first])==2)
				f=1;
		}

		for (auto i = map1.begin(); i != map1.end(); ++i)
		{
			if (i->second>0&&abs(i->second-map[i->first])==2)
				g=1;
		}
		//cout<<sum<<endl;
		if (f==1&&g==1)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,t,sum,f,g,h;
	cin>>t;
	while(t--)
	{
		sum=0,f=0,g=0,h=0;
		cin>>n;
		string s,s1;
		cin>>s>>s1;
		if (s1==s2)
		{
			cout<<"Yes\n";
			continue;
		}
		std::map<char, int> map,map1;
		for (int i = 0; i < s.size(); ++i)
		{
			map[s[i]]++;
			map1[s1[i]]++;
		}
		for (auto i = map.begin(); i != map.end(); ++i)
		{
			//
			if (i->second-map1[i->first]==2)
				f+=1;
			else if (i->second>0&&i->second-map1[i->first]==-2&&h==0&&f<=1)
				h=1;
			else if (i->second>0&&i->second!=map1[i->first])
			{
				f=0;
				break;
			}
		}
		h=0;
		for (auto i = map1.begin(); i != map1.end(); ++i)
		{
			if (i->second>0&&i->second-map[i->first]==2)
				g+=1;
			else if (i->second>0&&i->second-map[i->first]==-2&&h==0&&g<=1)
				h=1;
			else if (i->second>0&&i->second!=map[i->first])
			{
				g=0;
				break;
			}
		}
		//cout<<sum<<endl;
		if (f==1&&g==1)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;

void solve(){
   ll n,i;
   cin>>n;
   st s,t;
   cin>>s>>t;
   st temp1,temp2;
   f0(i,n){
    if(s[i]!=t[i]){
      temp1+=s[i];
      temp2+=t[i];
    }
   }
   if(temp1.length()==2 && temp2.length()==2){
    if((temp1[0]==temp1[1] )&& (temp2[0]==temp2[1]))
      pn("YES");
      else
      pn("NO");
   }else
   pn("NO");
}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;

void solve(){
   ll n,i,c=0;
   cin>>n;
   st s,t;
   cin>>s>>t;
   if(s==t){
               pn("YES");
               return ;
   }
   int a[26]={0},b[26]={0};
   f0(i,n){
    a[s[i]-'a']++;
    b[t[i]-'a']++;
   }
   f0(i,26){
               if(a[i]-b[i]!=0){
                          if(abs(a[i]-b[i])%2==0) c++;
                          else{
      pn("NO");
      return ;
    }
               }

   }// cout<<c<<endl;
   if(c==2) pn("YES");
   else pn("NO");

}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;

void solve(){
   ll n,i,c=0;
   cin>>n;
   st s,t;
   cin>>s>>t;
   if(s==t){
               pn("YES";
)
   }
   int a[26]={0},b[26]={0};
   f0(i,n){
    a[s[i]-'a']++;
    b[t[i]-'a']++;
   }
   f0(i,26){
               if((a[i]-b[i])!=0){
                          if((a[i]==2&&b[i]==0) || (a[i]==0 && b[i]==2)) c++;
                          else{
      pn("NO");
      return ;
    }
               }

   }// cout<<c<<endl;
   if(c==2) pn("YES");
   else pn("NO");

}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;
ll n;
st s,t;
bool check(ll pos){
   for(int i=0;i<n;i++){
       swap(s[pos],t[i]);
       //cout<<s<<" "<<t<<endl;
     //s[pos]=t[i],t[pos]=s[i];
     if(s==t) return true;
     else  swap(s[pos],t[i]);
   }
   return false;
}
void solve(){
   ll i,j;
   cin>>n;
   cin>>s>>t;
   f0(i,n){
    if(s[i]!=t[i]){
        //cout<<i<<endl;
       bool res=check(i);
          if(res){
            pn("YES");
            return ;
          }

      }

   }
   pn("NO");

}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;

void solve(){
   ll n,i;
   cin>>n;
   st s,t;
   cin>>s>>t;
   st temp1,temp2;
   f0(i,n){
    if(s[i]!=t[i]){
      temp1+=s[i];
      temp2+=t[i];
    }
   }
   if(temp1.length()==2 && temp2.length()==2){
    if((temp1[0]==temp1[1] )&& (temp2[0]==temp2[1]))
      pn("YES");
   }else
   pn("NO");
}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;

void solve(){
   ll n,i,c=0;
   cin>>n;
   st s,t;
   cin>>s>>t;
   if(s==t){
               pn("YES");

   }
   int a[26]={0},b[26]={0};
   f0(i,n){
    a[s[i]-'a']++;
    b[t[i]-'a']++;
   }
   f0(i,26){
               if((a[i]-b[i])!=0){
                          if((a[i]==2&&b[i]==0) || (a[i]==0 && b[i]==2)) c++;
                          else{
      pn("NO");
      return ;
    }
               }

   }// cout<<c<<endl;
   if(c==2) pn("YES");
   else pn("NO");

}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename Arg1>
//print with endl
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }
 //print with space
template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

int sum(int n){
    int v=0;
    while(n!=0){
        v+=(n%10);
        n/=10;
    }
    return v;
}
#define fast  ios::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
#define st string
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define f0(i,a) for(i=0;i<a;i++)
#define f1(i,a) for(i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define lb lower_bound
#define ub upper_bound
#define pl pair<ll,ll>
#define vpl vector<pl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;
const unsigned int M = 1000000007;

void solve(){
   ll n,i,c=0;
   cin>>n;
   st s,t;
   cin>>s>>t;
   int a[26]={0},b[26]={0};
   f0(i,n){
    a[s[i]-'a']++;
    b[t[i]-'a']++;
   }
   f0(i,26){
               if(a[i]-b[i]!=0){
                          if(abs(a[i]-b[i])%2==0) c++;
                          else{
      pn("NO");
      return ;
    }
               }

   }// cout<<c<<endl;
   if(c==2) pn("YES");
   else pn("NO");

}
int main(){
  fast;
  ll t;
  cin>>t;
   while(t--){
    solve();
   }
}


#include<bits/stdc++.h>
using namespace std;
int f[30];
int n,Q;
char a[10005],b[10005];
int main(){
    scanf("%d",&Q);
    while (Q--){
        scanf("%d",&n);
        for (int i=0;i<=n;i++)scanf("%c",&a[i]);
        for (int i=0;i<=n;i++)scanf("%c",&b[i]);
        memset(f,0,sizeof(f));
        int bo,bo1;
        bo1=bo=0;
        for (int i=1;i<=n;i++){
            f[a[i]-96]++;f[b[i]-96]++;
            if (a[i]!=b[i])bo++;
        }
        for (int i=1;i<=26;i++)
            if (f[i]%2==1)bo1++;
        if (bo1!=0)printf("NO\n");
        else{
            if (bo<=2)printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int f[30];
int n,Q;
char a[10005],b[10005];
int main(){
    scanf("%d",&Q);
    while (Q--){
        scanf("%d",&n);
        for (int i=0;i<=n;i++)scanf("%c",&a[i]);
        for (int i=0;i<=n;i++)scanf("%c",&b[i]);
        memset(f,0,sizeof(f));
        int bo,bo1;
        bo1=bo=0;
        for (int i=1;i<=n;i++){
            f[a[i]-96]++;f[b[i]-96]++;
            if (a[i]!=b[i])bo++;
        }
        for (int i=1;i<=26;i++)
            if (f[i]%2==1)bo1++;
        if (bo==2||bo==0)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int f[30];
int n,Q;
char a[10005],b[10005];
int main(){
    scanf("%d",&Q);
    while (Q--){
        scanf("%d",&n);
        for (int i=0;i<=n;i++)scanf("%c",&a[i]);
        for (int i=0;i<=n;i++)scanf("%c",&b[i]);
        memset(f,0,sizeof(f));
        int bo,bo1;
        bo1=bo=0;
        for (int i=1;i<=n;i++){
            f[a[i]-96]++;f[b[i]-96]++;
            if (a[i]!=b[i])bo++;
        }
        for (int i=1;i<=26;i++)
            if (f[i]%2==1)bo1++;
        if (bo1!=0)printf("No\n");
        else{
            if (bo==2||bo==0)printf("Yes\n");
            else printf("No\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int f[30];
int n,Q;
char a[10005],b[10005];
int main(){
    scanf("%d",&Q);
    while (Q--){
        scanf("%d",&n);
        scanf("%s",a+1);scanf("%s",b+1);
        memset(f,0,sizeof(f));
        int bo,bo1;
        bo1=bo=0;
        for (int i=1;i<=n;i++){
            f[a[i]-96]++;f[b[i]-96]++;
            if (a[i]!=b[i])bo++;
        }
        for (int i=1;i<=26;i++)
            if (f[i]%2==1)bo1++;
        if (bo==2||bo==0)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int f[30];
int n,Q;
char a[10005],b[10005];
int main(){
    scanf("%d",&Q);
    while (Q--){
        scanf("%d",&n);
        for (int i=0;i<=n;i++)scanf("%c",&a[i]);
        for (int i=0;i<=n;i++)scanf("%c",&b[i]);
        memset(f,0,sizeof(f));
        int bo,bo1;
        bo1=bo=0;
        for (int i=1;i<=n;i++){
            f[a[i]-96]++;f[b[i]-96]++;
            if (a[i]!=b[i])bo++;
        }
        for (int i=1;i<=26;i++)
            if (f[i]%2==1)bo1++;
        if (bo1!=0)printf("No\n");
        else{
            if (bo<=2)printf("Yes\n");
            else printf("No\n");
        }
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

void tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0;
    cin>>n;
    string s, t;
    cin>>s>>t;

    int arr[30]={};
    fol(i,0,n)
    {
        u=s[i]-'a';
        arr[u]++;
    }
    fol(i,0,n)
    {
        u=t[i]-'a';
        arr[u]++;
    }
    fol(i,0,30) if(arr[i]%2) { cout<<"No"<<endl; return; }
    vll ans;
    fol(i,0,n)
    {
        if(s[i]==t[i]) continue;
        fol(j,i+1,n)
        {
            if(s[j]==s[i])
            {
                ans.pb({j+1,i+1});
                swap(s[j],t[i]);
                break;
            }
        }
        if(s[i]!=t[i])
        {
            ans.pb({i+1,i+1});
            swap(s[i],t[i]);
            fol(j,i+1,n)
            {
                if(t[j]==t[i])
                {
                    ans.pb({i+1,j+1});
                    swap(s[i],t[j]);
                    break;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    cout<<sz(ans)<<endl;
    forr(x,ans) cout<<x.ff<<" "<<x.ss<<endl;
}

int main()
{
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cout << fixed << setprecision(10);
    int t=1;
    cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

int n;
string s, t;
bool work() {
	int p1,p2,cnt=0;
	for (int i=1;i<=n;i++) if (s[i]!=t[i]) {
		cnt++;
		if (cnt==3) return false;
		if (cnt==1) p1=i;
		else p2=i;
	}
	if (cnt==1) p2=p1;
	swap(s[p1],t[p2]);
	for (int i=1;i<=n;i++) if (s[i]!=t[i]) return false;
	return true;
}

void tejas_919(int kkkk)
{
    cin>>n;
    cin>>s>>t;
    if(work()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cout << fixed << setprecision(10);
    int t=1;
    cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

void tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0;
    cin>>n;
    string s, t;
    cin>>s>>t;
    int arr[30]={};
    fol(i,0,n)
    {
        u=s[i]-'a';
        arr[u]++;
    }
    fol(i,0,n)
    {
        u=t[i]-'a';
        arr[u]++;
    }
    fol(i,0,30) if(arr[i]%2) { cout<<"NO"<<endl; return; }
    vll ans;
    fol(i,0,n)
    {
        if(s[i]==t[i]) continue;
        fol(j,i+1,n)
        {
            if(s[j]==s[i])
            {
                ans.pb({j+1,i+1});
                swap(s[j],t[i]);
                break;
            }
        }
        if(s[i]!=t[i])
        {
            ans.pb({i+1,i+1});
            swap(s[i],t[i]);
            fol(j,i+1,n)
            {
                if(t[j]==t[i])
                {
                    ans.pb({i+1,j+1});
                    swap(s[i],t[j]);
                    break;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
}

int main()
{
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cout << fixed << setprecision(10);
    int t=1;
    cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

void tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0;
    cin>>n;
    string s, t;
    cin>>s>>t;
    int arr[30]={};
    fol(i,0,n)
    {
        u=s[i]-'a';
        arr[u]++;
    }
    fol(i,0,n)
    {
        u=t[i]-'a';
        arr[u]++;
    }
    fol(i,0,30) if(arr[i]%2) { cout<<"No"<<endl; return; }
    vll ans;
    fol(i,0,n)
    {
        if(s[i]==t[i]) continue;
        fol(j,i+1,n)
        {
            if(s[j]==s[i])
            {
                ans.pb({j+1,i+1});
                swap(s[j],t[i]);
                break;
            }
        }
        if(s[i]!=t[i])
        {
            ans.pb({i+1,i+1});
            swap(s[i],t[i]);
            fol(j,i+1,n)
            {
                if(t[j]==t[i])
                {
                    ans.pb({i+1,j+1});
                    swap(s[i],t[j]);
                    break;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    cout<<sz(ans)<<endl;
    forr(x,ans) cout<<x.ff<<" "<<x.ss<<endl;
}

int main()
{
    #ifndef tejasp
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #endif
    cout << fixed << setprecision(10);
    int t=1;
    cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

int n;
string s, t;
bool work() {
	int p1,p2,cnt=0;
	for (int i=0;i<n;i++) if (s[i]!=t[i]) {
		cnt++;
		if (cnt==3) return false;
		if (cnt==1) p1=i;
		else p2=i;
	}
	if (cnt==1) p2=p1;
	swap(s[p1],t[p2]);
	for (int i=0;i<n;i++) if (s[i]!=t[i]) return false;
	return true;
}

void tejas_919(int kkkk)
{
    cin>>n;
    cin>>s>>t;
    if(work()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cout << fixed << setprecision(10);
    int t=1;
    cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

void tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0;
    cin>>n;
    string s, t;
    cin>>s>>t;
    int arr[30]={};
    fol(i,0,n)
    {
        u=s[i]-'a';
        arr[u]++;
    }
    fol(i,0,n)
    {
        u=t[i]-'a';
        arr[u]++;
    }
    fol(i,0,30) if(arr[i]%2) { cout<<"No"<<endl; return; }
    vll ans;
    fol(i,0,n)
    {
        if(s[i]==t[i]) continue;
        fol(j,i+1,n)
        {
            if(s[j]==s[i])
            {
                ans.pb({j+1,i+1});
                swap(s[j],t[i]);
                break;
            }
        }
        if(s[i]!=t[i])
        {
            ans.pb({i+1,i+1});
            swap(s[i],t[i]);
            fol(j,i+1,n)
            {
                if(t[j]==t[i])
                {
                    ans.pb({i+1,j+1});
                    swap(s[i],t[j]);
                    break;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
}

int main()
{
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cout << fixed << setprecision(10);
    int t=1;
    cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


#include <iostream>
#include <algorithm>
using namespace std;

int k,t;
char n1[10005];
char n2[10005];
int swapindex[2];

bool same(char x[],char y[],int n)
{
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
		 return false;
		}
	}
	return true;
}

int ham(char x[],char y[],int n)
{
	int temp = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
			temp++;
		}
	}
	return temp;
}

int main() {

	cin >> k;
	for (int i = 0 ; i < k;i++)
	{
		cin >> t;
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n1[l];

		}
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n2[l];

		}
		if (ham(n1,n2,t) == 2)
		{
			int temp = 0;
			for (int i = 0 ; i < t ; i++) {

				if (n1[i] != n2[i])
				{
					swapindex[temp] = i;
					temp++;
				}
			}
			swap(n1[swapindex[0]],n2[swapindex[1]]);
			if (same(n1,n2,t))
			{
				cout << "Yes" << endl;
			}
		}
		else
		{
				cout << "No" << endl;
		}

	}

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int k,t;
char n1[10005];
char n2[10005];
int swapindex[2];

bool same(char x[],char y[],int n)
{
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
		 return false;
		}
	}
	return true;
}

int ham(char x[],char y[],int n)
{
	int temp = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
			temp++;
		}
	}
	return temp;
}

int main() {

	cin >> k;
	for (int i = 0 ; i < k;i++)
	{
		cin >> t;
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n1[l];

		}
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n2[l];

		}
		if (ham(n1,n2,t) == 1 || ham(n1,n2,t) > 2)
		{
			cout << "No" << endl;
		}
		else
		{
			int temp = 0;
			for (int i = 0 ; i < t ; i++) {

				if (n1[i] != n2[i])
				{
					swapindex[temp] = i;
					temp++;
				}
			}
			swap(n1[swapindex[0]],n2[swapindex[1]]);
			if (same(n1,n2,t))
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}

		}

	}

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int k,t;
char n1[10005];
char n2[10005];
bool check [29][2];

int same()
{
	int temp = 0;
	for (int i = 0 ; i < 29;i++)
	{
		if (check[i][0] == true && check[i][1] == true)
		{
			temp++;
		}
	}
	return temp;
}

int ham(char x[],char y[],int n)
{
	int temp = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
			temp++;
		}
	}
	return temp;
}

int main() {

	cin >> k;
	for (int i = 0 ; i < k;i++)
	{
		cin >> t;
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n1[l];
			check[(int)n1[l] - 'a'][0] = true;
		}
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n2[l];
			check[(int)n1[l] - 'a'][1] = true;
		}
		if ((t > 2) && ham(n1,n2,t) == 2 && (same() == t - 1))
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}

			for (int i = 0 ; i < 29;i++)
	{
		check[i][0] = check[i][1] = false;
	}

	}

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int k,t;
char n1[10005];
char n2[10005];
bool check [29][2];

int same()
{
	int temp = 0;
	for (int i = 0 ; i < 29;i++)
	{
		if (check[i][0] == true && check[i][1] == true)
		{
			temp++;
		}
	}
	return temp;
}

int ham(char x[],char y[],int n)
{
	int temp = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
			temp++;
		}
	}
	return temp;
}

int main() {

	cin >> k;
	for (int i = 0 ; i < k;i++)
	{
		cin >> t;
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n1[l];
			check[(int)n1[l] - 'a'][0] = true;
		}
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n2[l];
			check[(int)n1[l] - 'a'][1] = true;
		}
		if (ham(n1,n2,t) == 2 && same())
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}

			for (int i = 0 ; i < 29;i++)
	{
		check[i][0] = check[i][1] = false;
	}

	}

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int k,t;
char n1[10005];
char n2[10005];
int swapindex[2];

bool same(char x[],char y[],int n)
{
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
		 return false;
		}
	}
	return true;
}

int ham(char x[],char y[],int n)
{
	int temp = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
			temp++;
		}
	}
	return temp;
}

int main() {

	cin >> k;
	for (int i = 0 ; i < k;i++)
	{

		cin >> t;
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n1[l];

		}
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n2[l];

		}
		if (ham(n1,n2,t) == 2)
		{
			int temp = 0;
			for (int i = 0 ; i < t ; i++) {

				if (n1[i] != n2[i])
				{
					swapindex[temp] = i;
					temp++;
				}
			}
			swap(n1[swapindex[0]],n2[swapindex[1]]);
			if (same(n1,n2,t))
			{
				cout << "Yes" << endl;
			}
			else
		{
			cout << "No" << endl;
		}
		}
		else
		{
				cout << "No" << endl;
		}

	}

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int k,t;
char n1[10005];
char n2[10005];

int ham(char x[],char y[],int n)
{
	int temp = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (x[i] != y[i])
		{
			temp++;
		}
	}
	return temp;
}

int main() {

	cin >> k;
	for (int i = 0 ; i < k;i++)
	{
		cin >> t;
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n1[l];
		}
		for (int l = 0 ; l < t ; l++)
		{
			cin >> n2[l];
		}
		if (ham(n1,n2,t) == 2)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}

	}

	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    string s,p;
    while(t--)
    {
        int n;
        cin>>n;
        char e,w;
        cin>>e;
    cin>>s;
    cin>>w;
    cin>>p;
        char a[2],b[2];
        int j=0,k=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]!=p[i])
            {
                a[j]=s[i];
                b[j]=p[i];
                j++;
            }
            if(j>2)
            break;
        }
        if(j!=2)
        cout<<"No\n";
        else
        {
            if(a[0]==a[1] && b[0]==b[1])
            cout<<"Yes\n";
            else
            cout<<"No\n";
        }
    }
}


    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin>>t;

        for(int y=1;y<=t;y++)
        {
            int n;
            cin>>n;
            string s,p;
            cin>>s>>p;
            char a[10000],b[10000];
            int j=0,k=0;
            for(int i=0;i<n;i++)
            {
                if(s[i]!=p[i])
                {
                a[j]=s[i];
                b[j]=p[i];
                j++;

                }
            }
            if(j!=2)
            cout<<"No\n";
            else
            {
                if(a[0]==a[1] && b[0]==b[1])
                cout<<"Yes\n";
                else
                cout<<"No\n";
            }
        }
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin>>t;

        for(int y=1;y<=t;y++)
        {
            int n;
            cin>>n;
            string s,p;
            cin>>s>>p;
            char a[10000],b[10000];
            int j=0,k=0;
            for(int i=0;i<n;i++)
            {
                if(s[i]!=p[i])
                {
                a[j]=s[i];
                b[j]=p[i];
                j++;

                }
                if(j>2)break;
            }
            if(j!=2)
            cout<<"No\n";
            else
            {
                if(a[0]==a[1] && b[0]==b[1])
                cout<<"Yes\n";
                else
                cout<<"No\n";
            }
        }
    }


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s,p;
        char a[2],b[2];
        int e=0;
        cin>>s>>p;
        int i,j=0,k;
        for(i=0;i<n;i++)
        {
            if(s[i]!=p[i])
            {
                a[j]=s[i];
                b[j]=p[i];
                j++;
                e++;
            }
            if(e>2)
            {
                break;
            }
        }
        if(e==0)
        cout<<"Yes\n";
        else
        if(e>2 || e<2)
        cout<<"No\n";
        else
        {
        if(a[0]==a[1] && b[0]==b[1])
        cout<<"Yes\n";
        else
        cout<<"No\n";
        }

    }
}


    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin>>t;

        for(int y=1;y<=t;y++)
        {
            int n;
            cin>>n;
            string s,p;
            cin>>s>>p;
            char a[100],b[100];
            int j=0,k=0;
            for(int i=0;i<n;i++)
            {
                if(s[i]!=p[i])
                {
                a[j]=s[i];
                b[j]=p[i];
                j++;

                }
            }
            if(j!=2)
            cout<<"No\n";
            else
            {
                if(a[0]==a[1] && b[0]==b[1])
                cout<<"Yes\n";
                else
                cout<<"No\n";
            }
        }
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin>>t;

        for(int y=1;y<=t;y++)
        {
            int n;
            cin>>n;
            string s,p;
            cin>>s>>p;
            vector<char>a,b;
            int j=0,k=0;
            for(int i=0;i<n;i++)
            {
                if(s[i]!=p[i])
                {j++;
                    a.push_back(s[i]);
                    b.push_back(p[i]);

                }
            }
            if(j!=2)
            cout<<"No\n";
            else
            {
                if(a[0]==a[1] && b[0]==b[1])
                cout<<"Yes\n";
                else
                cout<<"No\n";
            }
        }
    }


        #include<bits/stdc++.h>
        using namespace std;

        int main(){
            int t;
            cin>>t;
            while(t--){
                int n;
                cin>>n;
                string a,b;
                cin>>a>>b;
                for(int i=0;i<n;i++)
                    for(int j=0;j<n;j++)
                    {
                        swap(a[i],b[j]);
                        if(a==b)
                        {
                            cout<<"Yes"<<endl;
                            break;
                        }
                    }
                    cout<<"No"<<endl;
            }
        }


    #include<iostream>
    #include<string>
    using namespace std;

    int main()
    {
    	int q; cin>>q;
    	while(q-->0)
    	{
    		int n; cin>>n;
    		string s,t; cin>>s>>t;
    		int d[n], i=0;
    		for(int c=0;c<n;c++)
    			if(s[c]!=t[c])
    				d[i++]=c;

    		if(i==2 && s[d[0]]==s[d[1]] && t[d[0]]==t[d[1]])
    			cout<<"Yes"<<endl;
    		else cout<<"No"<<endl;
    	}

    	return 0;
    }


            #include<bits/stdc++.h>
            using namespace std;

            int main(){
                int t;
                cin>>t;
                while(t--){
                    int n,flag=0;
                    cin>>n;
                    string a,b;
                    cin>>a>>b;
                    for(int i=0;i<n;i++)
                       if(a[i]!=b[i])
                        flag++;

                        if(flag==2)
                        cout<<"Yes"<<endl;
                        else
                        cout<<"No"<<endl;

                }
            }


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,flag=0;
        cin>>n;
        string a,b;
        cin>>a>>b;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            {
                swap(a[i],b[j]);
                if(a==b)
                {
                    cout<<"Yes"<<endl;
                    flag=1;
                    break;
                }
                if(flag==1)
                break;
            }
            cout<<"No"<<endl;
    }
}


    #include<bits/stdc++.h>
    using namespace std;

    int main(){
        int t;
        cin>>t;
        while(t--){
            int n;
            cin>>n;
            string a,b;
            cin>>a>>b;
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                {
                    swap(a[i],b[j]);
                    if(strcmp(*a,*b)==0)
                    {
                        cout<<"Yes"<<endl;
                        break;
                    }
                }
                cout<<"No"<<endl;
        }
    }


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        string a,b;
        cin>>a>>b;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            {
                swap(a[i],b[j]);
                if(strcmp(a,b)==0)
                {
                    cout<<"Yes"<<endl;
                    break;
                }
            }
            cout<<"No"<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0,f=0,x=0;int j;
		cin>>n;
		char s1[10000],s2[10000];
		scanf("%s",s1);
		scanf("%s",s2);
		strcat(s1,s2);
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
				if(c<2) j=i;
				if(s1[i] == s1[j] && s2[i] == s2[j]){
					x = 1;
				}
			}
		}
		sort(s1,s1+2*n);
		// printf("%s\n", s1);
		for(int i=0;i<2*n-1;i+=2){
			if(s1[i] != s1[i+1]){
				f=1;break;
			}
		}
		if(c==0) cout<<"YES"<<endl;
		else{
			if(f==0 && c==2 && x==1) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t;
    cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	string a,b;
    	cin>>a>>b;
    	if(a==b){
    		cout<<"YES"<<endl;
    		return 0;
    	}
    	else{
    		int j;int c=0;
    		for(int i=0;i<n;i++){

    			if(a[i] != b[i]){
    				c++;
    				if(c>1){
    					if(a[i] == a[j]){
    						swap(a[i],b[j]);
    						break;
    					}
    				}
    				j=i;
    			}
    		}
    		if(a == b) cout<<"YES"<<endl;
    		else cout<<"NO"<<endl;
    	}

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0,f=0,x=0;int j;
		cin>>n;
		string s1;string s2;
		cin>>s1;
		cin>>s2;
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
				if(c == 1) j=i;
				else if (c == 2) x=i;
			}
		}

		if(c == 0) cout<<"YES"<<endl;
		else if(c == 2){
			char p=s1[j];
			s1[j] = s2[x];
			s2[x] = p;
			if(s1 == s2) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else cout<<"NO"<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0,f=0,x=0;int j;
		cin>>n;
		char s1[10000],s2[10000];
		scanf("%s",s1);
		scanf("%s",s2);
		strcat(s1,s2);
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
				if(c<2) j=i;
				if(s1[i] == s1[j] && s2[i] == s2[j]){
					x =1;
				}
			}
		}
		sort(s1,s1+2*n);
		// printf("%s\n", s1);
		for(int i=0;i<2*n-1;i+=2){
			if(s1[i] != s1[i+1]){
				f=1;break;
			}
		}
		if(f==0 && c<=2 && x == 1) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0;
		cin>>n;
		string s1,s2;
		cin>>s1>>s2;
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
			}
		}
		if(c<=2) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0,f=0;
		cin>>n;
		char s1[10000],s2[10000];
		scanf("%s",s1);
		scanf("%s",s2);
		strcat(s1,s2);
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
			}
		}
		sort(s1,s1+2*n);
		// printf("%s\n", s1);
		for(int i=0;i<2*n-1;i+=2){
			if(s1[i] != s1[i+1]){
				f=1;break;
			}
		}
		if(f==0 && c<=2) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0;
		cin>>n;
		string s1,s2;
		cin>>s1>>s2;
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
			}
		}
		if(c==2) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		int n;int c=0,f=0,x=0;int j;
		cin>>n;
		string s1;string s2;
		cin>>s1;
		cin>>s2;
		for(int i=0;i<n;i++){
			if(s1[i] != s2[i]){
				c++;
				if(c == 1) j=i;
				else if (c == 2) x=i;
			}
		}

		if(c == 0) cout<<"YES"<<endl;
		else if(c == 2){
			char p=s1[j];
			s1[j] = s2[x];
			s2[x] = p;
			cout<<endl<<s1<<" "<<s2<<" "<<x<<endl;
			if(s1 == s2) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else cout<<"NO"<<endl;

	}
	return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

map<char, int> v;
set<char> va,vb;

bool compare(int n, string stra, string strb) {
	int c=0;
	for(int i=0; i<n; i++) {
		if(stra[i] != strb[i]) c++;
		if(c>2) return false;
	}
	return true;
}

int main() {
	int t,n;
	string stra,strb;
	cin>>t;
	while(t--) {
		cin>>n>>stra>>strb;
		if(stra == strb) {
			cout<<"No"<<endl;
			continue;
		}
		for(char &c : stra) {
			v[c]++;
			va.insert(c);
		}
		for(char &c : strb) {
			v[c]++;
			vb.insert(c);
		}
		bool done = false;
		for(auto &i : v) {
			if(i.second%2 == 1) {
				done = true;
				break;
			}
		}
		if(done || !compare(n,stra,strb)) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
		v.clear();
		va.clear();
		vb.clear();
	}
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

int t,n;
string stra,strb;

int main() {
	cin>>t;
	while(t--) {
		int i=0,pi=-1,pj=-1;
		cin>>n>>stra>>strb;
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pi = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = -1;
				break;
			}
		}
		if(pj==-1) {
			cout<<"No"<<endl;
			continue;
		}
		if(stra[pi] == stra[pj] && strb[pi] == strb[pj]) cout<<"Yes"<<endl;
		else if(stra[pi] == strb[pj] && strb[pi] == stra[pj]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

int t,n;
string stra,strb;

int main() {
	cin>>t;
	while(t--) {
		int i=0,pi=-1,pj=-1;
		cin>>n>>stra>>strb;
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pi = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = -1;
				break;
			}
		}
		if(pj==-1) {
			cout<<"No"<<endl;
			continue;
		}
		swap(stra[pi], strb[pj]);
		if(stra == strb) {
			cout<<"Yes"<<endl;
			continue;
		}
		swap(stra[pi], stra[pj]);
		if(stra == strb) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

int t,n;
string stra,strb;

int main() {
	cin>>t;
	while(t--) {
		int i=0,pi=-1,pj=-1;
		cin>>n>>stra>>strb;
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pi = i++;
				break;
			}
		}
		if(pi==-1) {
			cout<<"No"<<endl;
			continue;
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = -1;
				break;
			}
		}
		if(pj==-1) {
			cout<<"No"<<endl;
			continue;
		}
		swap(stra[pi], stra[pj]);
		if(stra == strb) {
			cout<<"Yes"<<endl;
			continue;
		}
		swap(stra[pi], stra[pj]);
		swap(stra[pi], strb[pj]);
		if(stra == strb) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

map<char, int> v;
set<char> va,vb;

bool compare(int n, string stra, string strb) {
	int c=0;
	for(int i=0; i<n; i++) {
		if(stra[i] != strb[i]) {
			for(int j=i+1; j<n; j++) {
				if(strb[j] == strb[i]){
					swap(stra[i],strb[j]);
					break;
				}
			}
			break;
		}
	}
	if(stra == strb) return true;
	return false;
}

int main() {
	int t,n;
	string stra,strb;
	cin>>t;
	while(t--) {
		cin>>n>>stra>>strb;
		if(stra == strb) {
			cout<<"No"<<endl;
			continue;
		}
		for(char &c : stra) {
			v[c]++;
			va.insert(c);
		}
		for(char &c : strb) {
			v[c]++;
			vb.insert(c);
		}
		bool done = false;
		for(auto &i : v) {
			if(i.second%2 == 1) {
				done = true;
				break;
			}
		}
		if(done || !compare(n,stra,strb)) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
		v.clear();
		va.clear();
		vb.clear();
	}
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

int t,n;
string stra,strb;

int main() {
	cin>>t;
	while(t--) {
		int c=0;
		cin>>n>>stra>>strb;
		for(int i=0; i<n; i++) {
			if(stra[i] != strb[i]) c++;
		}
		if(c==2) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

map<char, int> v;
set<char> va,vb;

bool compare(int n, string stra, string strb) {
	int c=0;
	for(int i=0; i<n; i++) {
		if(stra[i] != strb[i]) {
			for(int j=i+1; j<n; j++) {
				if(strb[j] == strb[i]){
					swap(stra[i],strb[j]);
					break;
				}
			}
			if(stra[i] != strb[i]) {
				for(int j=i+1; j<n; j++) {
					if(stra[j] == strb[i]){
						swap(stra[i],stra[j]);
						break;
					}
				}
			}
			break;
		}
	}
	if(stra == strb) return true;
	return false;
}

int main() {
	int t,n;
	string stra,strb;
	cin>>t;
	while(t--) {
		cin>>n>>stra>>strb;
		if(stra == strb) {
			cout<<"No"<<endl;
			continue;
		}
		for(char &c : stra) {
			v[c]++;
			va.insert(c);
		}
		for(char &c : strb) {
			v[c]++;
			vb.insert(c);
		}
		bool done = false;
		for(auto &i : v) {
			if(i.second%2 == 1) {
				done = true;
				break;
			}
		}
		if(done || !compare(n,stra,strb)) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
		v.clear();
		va.clear();
		vb.clear();
	}
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

vi v(24),va(24),vb(24);

bool compare(int n, string stra, string strb) {
	int c=0;
	for(int i=0; i<n; i++) {
		if(stra[i] != strb[i]) c++;
		if(c>2) return false;
	}
	return true;
}

int main() {
	int t,n;
	string stra,strb;
	cin>>t;
	while(t--) {
		cin>>n>>stra>>strb;
		for(char &c : stra) {
			v[(int) (c - 'a')]++;
			va[(int) (c - 'a')]++;
		}
		for(char &c : strb) {
			v[(int) (c - 'a')]++;
			vb[(int) (c - 'a')]++;
		}
		bool done = false;
		for(int &i : v) {
			if(i%2 == 1) {
				done = true;
				break;
			}
		}
		if(done || !compare(n,stra,strb)) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
		for(int i=0; i<26; i++) {
			v[i] = 0;
			va[i] = 0;
			vb[i] = 0;
		}
	}
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

int t,n;
string stra,strb;

int main() {
	cin>>t;
	while(t--) {
		int i=0,pi=-1,pj=-1;
		cin>>n>>stra>>strb;
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pi = i++;
				break;
			}
		}
		if(pi==-1) {
			cout<<"No"<<endl;
			continue;
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = -1;
				break;
			}
		}
		if(pj==-1) {
			cout<<"No"<<endl;
			continue;
		}
		if(stra[pi] != stra[pj]) {
			swap(stra[pj],strb[pi]);
			if(stra[pi] != stra[pj]) {
				swap(stra[pj],strb[pj]);
				if(stra[pi] != stra[pj]) {
					cout<<"No"<<endl;
					continue;
				}
			}
		}
		if(strb[pi] != strb[pj]) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vvi vector< vector<int> >
#define pii pair<int,int>
#define dvec vector< vector< pair<int,int> > >
#define INF 0x3f3f3f3f
#define ok printf("OK\n")
#define bb binary_search
#define all(A) A.begin(),A.end()
using namespace std;

int t,n;
string stra,strb;

int main() {
	cin>>t;
	while(t--) {
		int i=0,pi=-1,pj=-1;
		cin>>n>>stra>>strb;
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pi = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = i++;
				break;
			}
		}
		for(; i<n; i++) {
			if(stra[i] != strb[i]) {
				pj = -1;
				break;
			}
		}
		if(pj==-1) {
			cout<<"No"<<endl;
			continue;
		}
		swap(stra[pi], strb[pj]);
		if(stra == strb) {
			cout<<"Yes"<<endl;
			continue;
		}
		swap(stra[pi], strb[pj]);
		swap(strb[pi], stra[pj]);
		if(stra == strb) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin>>t;
  rep(i,t){
    int n;
    cin>>n;
    string s,t;
    char a='?',b='?';
    cin>>s>>t;
    rep(j,n){
      if(s[j]!=t[j]){
	if(a=='?'){
	  a=s[j];b=t[j];
	}
	else{
	  if(a==s[j] && b==t[j]){
	    cout<<"Yes"<<endl;break;
	  }else{cout<<"No"<<endl;break;}
	}
      }
      if(j==n-1){cout<<"No"<<endl;break;}
    }

  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

signed main(){
  cin.tie(0);
  //ios::sync_with_stdio(false);
  int m;
  cin>>m;
  rep(i,m){
    int n;
    cin>>n;
    string s,t;
    char a='?',b='?';
    cin>>s>>t;
    bool flag=false;
    rep(j,n){
      if(s[j]!=t[j]){
	if(flag){cout<<"No"<<endl;break;}
	if(a=='?'){
	  a=s[j];b=t[j];
	}
	else{
	  if((a==s[j] && b==t[j])){
	    flag=true;
	  }else{cout<<"No"<<endl;break;}
	}
      }
      if(s==t){cout<<"Yes"<<endl;break;}
      if(j==n-1 && !flag){cout<<"No"<<endl;break;}
      else if(j==n-1){cout<<"Yes"<<endl;break;}
    }

  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

signed main(){
  cin.tie(0);
  //ios::sync_with_stdio(false);
  int t;
  cin>>t;
  rep(i,t){
    int n;
    cin>>n;
    string s,t;
    char a='?',b='?';
    cin>>s>>t;
    rep(j,n){
      if(s[j]!=t[j]){
	if(a=='?'){
	  a=s[j];b=t[j];
	}
	else{
	  if((a==s[j] && b==t[j])){
	    cout<<"Yes"<<endl;break;
	  }else{cout<<"No"<<endl;break;}
	}
      }
      if(s==t){cout<<"Yes"<<endl;break;}
      if(j==n-1 && s!=t){cout<<"No"<<endl;break;}
    }

  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

signed main(){
  cin.tie(0);
  //ios::sync_with_stdio(false);
  int m;
  cin>>m;
  rep(i,m){
    int n;
    cin>>n;
    string s,t;
    char a='?',b='?';
    cin>>s>>t;
    rep(j,n){
      if(s[j]!=t[j]){
	if(a=='?'){
	  a=s[j];b=t[j];
	}
	else{
	  if((a==s[j] && b==t[j])){
	    cout<<"Yes"<<endl;break;
	  }else{cout<<"No"<<endl;break;}
	}
      }
      if(s==t){cout<<"Yes"<<endl;break;}
      if(j==n-1 && s!=t){cout<<"No"<<endl;break;}
    }

  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin>>t;
  rep(i,t){
    int n;
    cin>>n;
    string s,t;
    char a='?',b='?';
    cin>>s>>t;
    rep(j,n){
      if(s[j]!=t[j]){
	if(a=='?'){
	  a=s[j];b=t[j];
	}
	else{
	  if(a==s[j] && b==t[j]){
	    cout<<"Yes"<<endl;break;
	  }else{cout<<"No"<<endl;break;}
	}
      }
      if(s==t){cout<<"Yes"<<endl;break;}
      if(j==n-1 && s!=t){cout<<"No"<<endl;break;}
    }

  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin>>t;
  rep(i,t){
    int n;
    cin>>n;
    string s,t;
    char a='?',b='?';
    cin>>s>>t;
    rep(j,n){
      if(s[j]!=t[j]){
	if(a=='?'){
	  a=s[j];b=t[j];
	}
	else{
	  if((a==t[j] && b==s[j]) || (a==s[j] && b==t[j])){
	    cout<<"Yes"<<endl;break;
	  }else{cout<<"No"<<endl;break;}
	}
      }
      if(s==t){cout<<"Yes"<<endl;break;}
      if(j==n-1 && s!=t){cout<<"No"<<endl;break;}
    }

  }

  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;

    for(int i = 0 ;i<n;i++){
      for(int j = 0 ;j<n;j++){
          t1 = s1; t2 = s2;
          char temp = t1[i];
          t1[i] = t2[j];
          t2[j] = temp;
          // cout<<t1<<" "<<t2<<'\n';
          if(t1 == t2){
            cout<<"Yes"<<'\n';
            flag = 1;
            break;
          }
      }
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  cin.tie(NULL); cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0, chk[10001] = {0, }, count = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;
    for(int i = 0 ;i<n;i++){
      if(s1[i] == s2[i]){
        chk[i] = 1;
        count++;
      }
    }
    if(n - count > 2) cout<<"No"<<'\n';
    else{
      for(int i = 0 ;i<n;i++){
        if(chk[i] == 1) continue;
        for(int j = 0 ;j<n;j++){
            t1 = s1; t2 = s2;
            if(t1[i] == t2[j]) continue;
            char temp = t1[i];
            t1[i] = t2[j];
            t2[j] = temp;
            // cout<<t1<<" "<<t2<<'\n';
            if(!t1.compare(t2)){
              cout<<"Yes"<<'\n';
              flag = 1;
              break;
            }
        }
        if(flag == 1) break;
      }
      if(flag == 0) cout<<"No"<<'\n';
    }
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  cin.tie(NULL); cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0, chk[10001] = {0, };
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;
    for(int i = 0 ;i<n;i++){
      if(s1[i] == s2[i]) chk[i] = 1;
    }
    for(int i = 0 ;i<n;i++){
      if(chk[i] == 1) continue;
      for(int j = 0 ;j<n;j++){
          t1 = s1; t2 = s2;
          if(t1[i] == t2[j]) continue;
          char temp = t1[i];
          t1[i] = t2[j];
          t2[j] = temp;
          // cout<<t1<<" "<<t2<<'\n';
          if(!t1.compare(t2)){
            cout<<"Yes"<<'\n';
            flag = 1;
            break;
          }
      }
      if(flag == 1) break;
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;

    for(int i = 0 ;i<n;i++){
      for(int j = 0 ;j<n;j++){
          t1 = s1; t2 = s2;
          char temp = t1[i];
          t1[i] = t2[j];
          t2[j] = temp;
          // cout<<t1<<" "<<t2<<'\n';
          if(t1 == t2){
            cout<<"Yes"<<'\n';
            flag = 1;
            break;
          }
      }
      if(flag == 1) break;
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  cin.tie(NULL); cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;

    for(int i = 0 ;i<n;i++){
      for(int j = 0 ;j<n;j++){
          t1 = s1; t2 = s2;
          if(t1[i] == t2[j]) continue;
          char temp = t1[i];
          t1[i] = t2[j];
          t2[j] = temp;
          // cout<<t1<<" "<<t2<<'\n';
          if(!t1.compare(t2)){
            cout<<"Yes"<<'\n';
            flag = 1;
            break;
          }
      }
      if(flag == 1) break;
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;

    for(int i = 0 ;i<n;i++){
      for(int j = 0 ;j<n;j++){
          char temp = t1[i];
          t1 = s1; t2 = s2;
          t1[i] = t2[j];
          t2[j] = temp;
          if(t1 == t2){
            cout<<"Yes"<<'\n';
            flag = 1;
          }
      }
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;

    for(int i = 0 ;i<n;i++){
      for(int j = 0 ;j<n;j++){
          char temp = t1[i];
          t1 = s1; t2 = s2;
          t1[i] = t2[j];
          t2[j] = temp;
          // cout<<t1<<" "<<t2<<'\n';
          if(t1 == t2){
            cout<<"Yes"<<'\n';
            flag = 1;
            break;
          }
      }
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(void){
  int k;
  cin>>k;
  for(int i = 0 ;i<k;i++){
    int n, flag = 0;
    string s1, s2, t1, t2;
    cin>>n;
    cin>>s1>>s2;

    for(int i = 0 ;i<n;i++){
      for(int j = 0 ;j<n;j++){
          t1 = s1; t2 = s2;
          if(t1[i] == t2[j]) continue;
          char temp = t1[i];
          t1[i] = t2[j];
          t2[j] = temp;
          // cout<<t1<<" "<<t2<<'\n';
          if(t1 == t2){
            cout<<"Yes"<<'\n';
            flag = 1;
            break;
          }
      }
      if(flag == 1) break;
    }
    if(flag == 0) cout<<"No"<<'\n';
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool y[10101];

int main()
{
    int K;
    scanf("%d", &K);
    for(int t = 0; t < K; t++){
        int N;
        char A[10101], B[10101];
        scanf("%d", &N);
        scanf("%s", A);
        scanf("%s", B);
        int F = N;
        for(int i = 0; i < N; i++){
            if(A[i] == B[i]){
                y[i] = true;
                F--;
            }
        }
        if(F > 2 || F == 1){
            printf("No\n");
            continue;
        }
        char a, b;
        bool flag = false;
        for(int i = 0; i < N; i++){
            if(!y[i] && !flag){
                flag = true;
                a = A[i];
                b = B[i];
                continue;
            }
            if(!y[i] && flag){
                if(a != A[i] || b != B[i]){
                    printf("No\n");
                    goto e;
                }
                printf("Yes\n");
                break;
            }
        }
        e:;
        for(int i = 0; i < N; i++) y[i] = false;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool y[10101];
char A[10101], B[10101];
int main()
{
    int K;
    scanf("%d", &K);
    for(int t = 0; t < K; t++){
        int N;

        scanf("%d", &N);
        for(int i = 0; i < N; i++) y[i] = false;
        scanf("%s", A);
        printf("%s\n", A);
        scanf("%s", B);
        printf("%s\n", B);
        int F = N;
        for(int i = 0; i < N; i++){
            if(A[i] == B[i]){
                y[i] = true;
                F--;
            }
        }
        if(F > 2 || F == 1){
            printf("No\n");
            continue;
        }
        char a, b;
        bool flag = false;
        for(int i = 0; i < N; i++){
            if(!y[i] && !flag){
                flag = true;
                a = A[i];
                b = B[i];
                continue;
            }
            if(!y[i] && flag){
                if(a != A[i] || b != B[i]){
                    printf("No\n");
                    goto e;
                }
                printf("Yes\n");
                break;
            }
        }
        e:;
        for(int i = 0; i < N; i++) y[i] = false;
    }
    return 0;
}