#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long maxn = 1e13;
long long min(long long a, long long b) { return a < b ? a : b; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str, str1;
    cin >> str >> str1;
    vector<char> vec;
    for (int i = 0; i < n; i++) {
      if (str[i] != str1[i]) {
        vec.push_back(str[i]);
        vec.push_back(str1[i]);
      }
    }
    if (vec.size() == 0 || vec.size() == 4) {
      if (vec.size() == 4) {
        if (vec[0] == vec[2] && vec[1] == vec[3]) {
          cout << "YES" << endl;
        } else {
          cout << "NO"
               << "\n";
        }
      } else {
        cout << "YES"
             << "\n";
      }
    } else {
      cout << "NO"
           << "\n";
    }
  }
}
