#include <bits/stdc++.h>
using namespace std;
int st[100005];
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second < b.second)
    return true;
  else if (a.second == b.second)
    return a.first < b.first;
  else
    return false;
}
bool sortbyboth(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first < b.first)
    return true;
  else if (a.first == b.first)
    return a.second < b.second;
  else
    return false;
}
unsigned long long powr(unsigned long long x1, unsigned long long n1) {
  if (x1 == 0) {
    return 0;
  }
  unsigned long long result = 1;
  while (n1 > 0) {
    if (n1 & 1) {
      result = (result * x1);
    }
    n1 = n1 >> 1;
    x1 = (x1 * x1);
  }
  return result;
}
int fact(int n) { return (n == 1 || n == 0) ? 1 : n * fact(n - 1); }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int a[26] = {0}, b[26] = {0};
    for (int i = 0; i < n; i++) {
      a[s[i] - 97]++;
      b[t[i] - 97]++;
    }
    int temp = 0;
    for (int i = 0; i < 26; i++) {
      if ((a[i] + b[i]) % 2 == 1) {
        cout << "No" << endl;
        temp = 1;
        break;
      }
    }
    if (temp == 0) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) {
          cnt++;
        }
      }
      if (cnt == 2) {
        int cnt1 = 0;
        for (int i = 0; i < 26; i++) {
          if (a[i] != b[i]) cnt1++;
        }
        if (cnt1 == 0) {
          cout << "No" << endl;
        } else {
          cout << "Yes" << endl;
        }
      } else if (cnt == 0) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
  return 0;
}
