#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int count = 0;
    int a[2];
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        count++;
        if (count > 2) break;
        a[k] = i;
        k++;
      }
    }
    if (count != 2)
      cout << "No" << endl;
    else {
      if (s[a[0]] == s[a[1]] && t[a[0]] == t[a[1]]) {
        cout << "Yes" << endl;
      } else
        cout << "No" << endl;
    }
  }
  return 0;
}
