#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s, s1;
    cin >> s;
    cin >> s1;
    int ar[26], ar1[26];
    for (int i = 0; i < 26; i++) ar[i] = ar1[i] = 0;
    for (int i = 0; i < n; i++) {
      if (s1[i] != s[i]) {
        ar1[s1[i] - 'a']++;
        ar[s[i] - 'a']++;
      }
    }
    bool flag = 0;
    int count = 0, count1 = 0;
    for (int i = 0; i < 26; i++) {
      if (ar[i]) {
        if (ar[i] % 2) {
          flag = 1;
          break;
        } else
          count++;
      }
      if (ar1[i]) {
        if (ar1[i] % 2) {
          flag = 1;
          break;
        } else
          count1++;
      }
    }
    if (flag || count > 1 || count1 > 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
