#include <bits/stdc++.h>
using namespace std;
bool comp(long long a, long long b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<int> l(256, 0);
    for (int i = 0; i < n; i++) {
      l[s[i]]++;
      l[t[i]]++;
    }
    bool band = true;
    for (int i = 'a'; i <= 'z'; i++) {
      if (l[i] % 2) band = false;
    }
    if (band) {
      int j = -1;
      band = false;
      for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) {
          if (j != -1) {
            swap(s[j], t[i]);
            if (s == t) {
              band = true;
              break;
            }
            swap(s[j], t[i]);
            swap(s[i], t[j]);
            if (s == t) {
              band = true;
              break;
            }
          } else {
            j = i;
          }
        }
      }
      if (band)
        cout << "YES\n";
      else
        cout << "NO\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
