#include <bits/stdc++.h>
using namespace std;
long long power(int x, unsigned int y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y >>= 1;
    x *= x;
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<pair<char, char> > v;
  int freq[26] = {0};
  for (int i = 0; i < n; i++) {
    freq[s[i] - 'a']++;
    freq[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (freq[i] % 2 != 0) {
      cout << "No\n";
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      v.push_back({s[i], t[i]});
    }
  }
  if (v.size() == 1 || v.size() > 2) {
    cout << "No\n";
    return;
  }
  if (v[0].first != v[1].first && v[0].second != v[1].second) {
    cout << "No\n";
    return;
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
