#include <bits/stdc++.h>
using namespace std;
bool comp(int n, const string &str1, const string &str2) {
  string tm1 = "", tm2 = "";
  for (int i = 0; i < n; i++) {
    if (str1[i] != str2[i]) {
      tm1 += (str1[i]);
      tm2 += (str2[i]);
    }
  }
  n = tm1.length();
  if (n > 2) return false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      swap(tm1[i], tm2[j]);
      if (tm1 == tm2) return true;
      swap(tm1[i], tm2[j]);
    }
  }
  return false;
}
int main() {
  int k, n;
  string str1, str2;
  cin >> k;
  while (k--) {
    cin >> n;
    cin >> str1 >> str2;
    if (comp(n, str1, str2))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
