#include <bits/stdc++.h>
using namespace std;
long long n, u, num1, num2;
string s, t;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  while (n--) {
    cin >> u >> s >> t;
    for (long long i = 0; i < u; ++i) {
      if (s[i] != t[i]) {
        num1 = i;
        break;
      }
    }
    for (long long i = u - 1; i >= 0; --i) {
      if (s[i] != t[i]) {
        num2 = i;
        break;
      }
    }
    swap(s[num1], t[num2]);
    if (s == t) {
      cout << "Yes\n";
      continue;
    }
    swap(s[num1], t[num2]);
    swap(s[num2], t[num1]);
    if (s == t) {
      cout << "Yes\n";
      continue;
    }
    cout << "No\n";
  }
}
