#include <bits/stdc++.h>
using namespace std;
void hike() {
  int64_t n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int64_t> f;
  for (int64_t i = 0; i < n; ++i) {
    if (s[i] != t[i]) {
      f.push_back(i);
    }
  }
  if (f.size() != 2) {
    cout << "No\n";
    return;
  }
  char x1 = s[f[0]], y1 = t[f[0]];
  char x2 = s[f[1]], y2 = t[f[1]];
  s[f[0]] = y2;
  t[f[1]] = x1;
  if (s == t) {
    cout << "Yes\n";
    return;
  }
  s[f[0]] = x1;
  t[f[1]] = y2;
  s[f[1]] = y1;
  t[f[0]] = x2;
  if (s == t) {
    cout << "Yes\n";
    return;
  }
  cout << "No\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int64_t t = 1;
  cin >> t;
  while (t--) hike();
  return 0;
}
