#include <bits/stdc++.h>
using namespace std;
string s1, s2;
vector<int> v;
int main() {
  int k, n;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    cin >> n;
    cin >> s1 >> s2;
    for (int j = 0; j < n; ++j) {
      if (s1[j] != s2[j]) v.push_back(j);
    }
    if (v.size() == 2) {
      swap(s1[v[0]], s2[v[1]]);
      swap(s1[v[0]], s2[v[1]]);
      swap(s1[v[1]], s2[v[0]]);
      if (s1 == s2)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else if (v.size() == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    v.clear();
  }
  return 0;
}
