#include <bits/stdc++.h>
using namespace std;
int q, n;
string s1, s2;
vector<int> diff;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> q;
  while (q--) {
    diff.clear();
    cin >> n >> s1 >> s2;
    for (int i = 0; i < n; ++i)
      if (s1[i] != s2[i]) diff.push_back(i);
    if (diff.size() != 2) {
      cout << "No\n";
      continue;
    }
    if (s1[diff[0]] == s1[diff[1]] && s2[diff[0]] == s2[diff[1]])
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
