#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int> p;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) p.push_back(i);
  }
  if (p.size() == 2 && s[p[0]] == s[p[1]] && t[p[0]] == t[p[1]])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) solve();
  return 0;
}
