#include <bits/stdc++.h>
using namespace std;
inline void filehandling() {}
vector<long long> vector_in(long long n) {
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  return v;
}
void vector_out(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
long long vector_sum(vector<long long> v) {
  long long sum;
  for (long long i = 0; i < v.size(); i++) sum += v[i];
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  filehandling();
  long long Test = 1;
  cin >> Test;
  while (Test--) {
    long long n;
    cin >> n;
    string string1, string2;
    cin >> string1 >> string2;
    vector<bool> v(n);
    for (long long i = 0; i < n; i++)
      if (string1[i] == string2[i]) v[i] = true;
    long long XX = 0;
    for (long long i = 0; i < n; i++) XX += !v[i];
    if (!XX)
      cout << "Yes" << endl;
    else if (XX != 2)
      cout << "No" << endl;
    else {
      vector<long long> seq;
      for (long long i = 0; i < n; i++)
        if (!v[i]) seq.push_back(i);
      swap(string1[seq[0]], string2[seq[1]]);
      if (string1 == string2)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
}
