#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  while (k--) {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string s_old, t_old;
    s_old = s;
    t_old = t;
    multiset<char> s_s;
    multiset<char> s_t;
    for (int i = 0; i < n; i++) {
      s_s.insert(s[i]);
      s_t.insert(t[i]);
    }
    bool checked = false;
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i] && checked == false) {
        bool found = false;
        for (int j = i + 1; j < n; j++) {
          if (t[j] == t[i] && (s[j] != t[j] || s[j] == s[i])) {
            t[j] = s[i];
            found = true;
            break;
          }
        }
        if (!found) {
          flag = false;
          break;
        }
        checked = true;
      } else if (s[i] != t[i]) {
        flag = false;
      }
    }
    if (flag == false) {
      s = s_old;
      t = t_old;
      for (int i = 0; i < n; i++) {
        if (s[i] != t[i] && checked == false) {
          bool found = false;
          for (int j = i + 1; j < n; j++) {
            if (s[j] == s[i] && (t[j] != s[j] || t[j] == t[i])) {
              s[j] = t[i];
              found = true;
              break;
            }
          }
          if (!found) {
            flag = false;
            break;
          }
          checked = true;
        } else if (s[i] != t[i]) {
          flag = false;
        }
      }
    }
    if (flag)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
