#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long google_itr = 1;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long popcount(long long num) {
  num = num - ((num >> 1) & 0x55555555);
  num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
  return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
vector<pair<long long, long long>> factor_arr;
void myfactor(long long num) {
  long long count = 0;
  while (!(num % 2)) {
    num >>= 1;
    count++;
  }
  if (count) factor_arr.push_back({2, count});
  for (auto i = 3; i <= sqrt(num); i += 2) {
    count = 0;
    while (num % i == 0) {
      count++;
      num /= i;
    }
    if (count) factor_arr.push_back({i, count});
  }
  if (num > 2) factor_arr.push_back({num, 1});
}
void virus() {
  long long len;
  cin >> len;
  string fir, sec;
  cin >> fir >> sec;
  map<char, long long> cnt_fir, cnt_sec;
  for (auto i : fir) cnt_fir[i]++;
  for (auto i : sec) cnt_sec[i]++;
  if (fir == sec)
    cout << "Yes\n";
  else {
    long long mis = 0;
    vector<long long> misi;
    for (auto i = 0; i < len; i++) {
      if (fir[i] != sec[i]) mis++, misi.push_back(i);
    }
    if (mis != 2)
      cout << "No\n";
    else {
      if ((fir[misi[0]] == fir[misi[1]]) and (sec[misi[1]] == sec[misi[0]]))
        cout << "Yes\n";
      else
        cout << "No\n";
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    auto start = high_resolution_clock::now();
    virus();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
  }
  return 0;
}
