#include <bits/stdc++.h>
using namespace std;
int main() {
  int tt;
  cin >> tt;
  for (int h = 0; h < tt; h++) {
    int n, k = 0;
    int a[10000];
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) a[k] = i, k++;
    }
    if (k == 0)
      cout << "Yes\n";
    else if (k == 2) {
      if (s[a[0]] == s[a[1]] and t[a[0]] == t[a[1]])
        cout << "Yes\n";
      else
        cout << "No\n";
    } else
      cout << "No\n";
  }
}
