#include <bits/stdc++.h>
const long long M = 1e9 + 7;
const double pi = 3.14159265358979323846;
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    long long i1 = -1, i2 = -1, cnt = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        cnt++;
        if (i1 == -1)
          i1 = i;
        else
          i2 = i;
      }
    }
    if (cnt == 2) {
      swap(a[i1], b[i2]);
      long long f = 0;
      for (long long i = 0; i < n; i++) {
        if (a[i] != b[i]) {
          f = 1;
          break;
        }
      }
      if (f)
        cout << ("NO") << "\n";
      else
        cout << ("YES") << "\n";
    } else
      cout << ("NO") << "\n";
  }
  return 0;
}
