#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  string a, b;
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> a >> b;
    long long c = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        c++;
      }
    }
    if (c == 2) {
      vector<long long> q1;
      for (long long i = 0; i < n; i++) {
        if (a[i] != b[i]) {
          q1.push_back(i);
        }
      }
      if (a[q1[0]] == a[q1[1]] && b[q1[0]] == b[q1[1]])
        cout << "Yes\n";
      else
        cout << "No\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}
