#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
p:
  while (t--) {
    int n, i, c = 0;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<char> str;
    for (i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        str.push_back(s[i]);
        str.push_back(t[i]);
        c++;
      }
      if (c > 2) {
        cout << "No"
             << "\n";
        goto p;
      }
    }
    if (str[0] == str[2] && str[1] == str[3]) {
      cout << "Yes"
           << "\n";
    } else
      cout << "No"
           << "\n";
  }
  return 0;
}
