#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  string s, t;
  cin >> s >> t;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) a.push_back(i);
  }
  if (a.size() > 2) {
    printf("no\n");
    return;
  }
  for (int i = 0; i < (int)a.size(); i++) {
    for (int j = 0; j < (int)a.size(); j++) {
      string temp_s = s;
      string temp_t = t;
      swap(temp_s[a[i]], temp_t[a[j]]);
      if (temp_s == temp_t) {
        printf("yes\n");
        return;
      }
    }
  }
  printf("no\n");
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
