#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    if (a == b) {
      cout << "YES" << endl;
      return 0;
    } else {
      int j;
      int c = 0;
      for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
          c++;
          if (c > 1) {
            if (a[i] == a[j]) {
              swap(a[i], b[j]);
              break;
            }
          }
          j = i;
        }
      }
      if (a == b)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
