#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    set<pair<char, char>> st;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s1[i] != s2[i]) {
        cnt++;
        st.insert(make_pair(s1[i], s2[i]));
      }
    }
    if (cnt == 2 && st.size() == 1)
      cout << "Yes";
    else
      cout << "No";
    cout << "\n";
  }
  return 0;
}
