#include <bits/stdc++.h>
using namespace std;
bool isPrime(unsigned long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (unsigned long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int pow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  string a, b;
  cin >> a;
  cin >> b;
  string aa = a, bb = b;
  int c = 0, x = 0, y = 0;
  for (int i = 0; i < int(n); i++) {
    if (a[i] == b[i]) continue;
    if (!c) {
      x = i;
      c++;
      continue;
    }
    if (c == 1) {
      y = i;
      c++;
      continue;
    }
    c++;
  }
  swap(a[x], b[y]);
  if (!a.compare(b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
