#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long INF = 4e18;
const int ALPHA = 26;
void solve() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  vector<char> a, b;
  for (int i = 0; i < n; ++i) {
    if (s[i] != t[i]) {
      a.push_back(s[i]);
      b.push_back(t[i]);
    }
  }
  if (a.size() == 2 && b.size() == 2) {
    if (a[0] == a[1] && b[0] == b[1]) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}
int main() {
  int t;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
