#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    long long w = 0;
    char s1, t1, s2, t2;
    int q = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        w++;
      }
      if (w == 1 && q == 0) {
        s1 = s[i], t1 = t[i];
        q++;
      }
      if (w == 2 && q == 1) {
        s2 = s[i], t2 = t[i];
        q++;
      }
    }
    if (w != 2) {
      cout << "NO" << endl;
    } else {
      if (t1 == t2 && s1 == s2)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
