#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    bool is = false;
    bool allequal = true;
    for (long long i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        allequal = false;
        for (long long j = i + 1; j < n; j++) {
          if (s[j] != t[j]) {
            if (s[i] == s[j] && t[i] == t[j]) {
              is = true;
              swap(s[i], t[j]);
            }
            break;
          }
        }
        break;
      }
    }
    for (long long i = 0; i < n; i++)
      if (s[i] != t[i]) is = false;
    if (is || allequal)
      cout << "Yes";
    else
      cout << "No";
    cout << endl;
  }
}
