#include <bits/stdc++.h>
using namespace std;
void slv() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << "Yes\n";
    return;
  }
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      v.push_back(i);
    }
  }
  if (v.size() == 2) swap(s[v[0]], t[v[1]]);
  if (s != t)
    cout << "No\n";
  else
    cout << "Yes\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    slv();
  }
  return 0;
}
