#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    long long n;
    cin >> n;
    string a, b;
    cin >> a;
    cin >> b;
    long long ans = 0;
    long long p = 0, k, cn = 0;
    long long p1;
    for (long long j = 0; j < n; j++) {
      if (cn < 2) {
        if (p == 0) {
          if ((a[j] - b[j]) != 0) {
            p1 = a[j];
            k = b[j];
            p = 1;
            cn++;
          }
        } else {
          if ((a[j] - b[j]) != 0) {
            cn++;
            if (p1 == a[j] && k == b[j])
              ans = 1;
            else
              break;
          }
        }
      } else {
        if (a[j] - b[j] != 0) {
          ans = 0;
          break;
        }
      }
    }
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
