#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 100000000;
const double eps = 1e-8;
long long n, m, k;
string s1, s2;
int a[maxn];
int flag[maxn];
long long x[maxn], tot;
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> s1 >> s2;
    int tot = 0;
    string ss1 = "", ss2 = "";
    for (int i = 0; i < n; i++) {
      if (s1[i] != s2[i]) {
        tot++;
        ss1 += s1[i];
        ss2 += s2[i];
      }
    }
    if (tot == 2) {
      if (ss1[0] == ss1[1] && ss2[0] == ss2[1]) {
        cout << "Yes\n";
      } else
        cout << "No\n";
    } else if (tot == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
