#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, n;
  cin >> K;
  string s, t;
  for (int k = 0; k < K; k++) {
    cin >> n;
    cin >> s >> t;
    int c = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) c++;
    }
    if (c != 2) {
      cout << "No" << endl;
      continue;
    }
    char sp = '.', tp = '.';
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        if (sp == '.') {
          sp = s[i];
          tp = t[i];
        } else {
          if (s[i] == sp && t[i] == tp) {
            cout << "Yes" << endl;
          } else {
            cout << "No" << endl;
          }
        }
      }
    }
  }
  return 0;
}
