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