#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  for (int q = 0, q_len = (k); q < q_len; ++q) {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<char> a;
    for (int i = 0, i_len = (n); i < i_len; ++i) {
      if (s[i] != t[i]) {
        a.push_back(s[i]);
        a.push_back(t[i]);
      }
    }
    if (a.size() == 4 && a[0] == a[2] && a[1] == a[3]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
