#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    vector<int> a;
    for (int i = 0; i < N; i++) {
      if (s1[i] != s2[i]) {
        a.push_back(i);
      }
    }
    if (a.empty()) {
      cout << "Yes\n";
    } else {
      if (a.size() == 1) {
        cout << "No\n";
        continue;
      }
      swap(s1[a[0]], s2[a[1]]);
      if (s1 == s2) {
        cout << "Yes\n";
      } else {
        cout << "No\n";
      }
    }
  }
  return 0;
}
