#include <bits/stdc++.h>
using namespace std;
int q;
int n;
string s, t;
int main() {
  cin >> q;
  while (q--) {
    cin >> n >> s >> t;
    map<pair<char, char>, int> M;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        sum++;
        if (M[{s[i], t[i]}]) {
          int x = M[{s[i], t[i]}] - 1;
          swap(s[x], t[i]);
        }
        M[{s[i], t[i]}] = i + 1;
        if (sum == 2) break;
      }
    }
    int ok = 1;
    for (int i = 0; i < n; i++)
      if (s[i] != t[i]) ok = 0;
    if (ok == 1)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
