#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int p[26] = {0}, q[26] = {0}, i, j = 0, n, flag = 0, m[10] = {0};
    cin >> n;
    string s, str;
    cin >> str >> s;
    for (i = 0; i < n; i++) {
      if (s[i] != str[i] && j < 10) m[j++] = i;
    }
    if (s[m[0]] == s[m[1]] && str[m[0]] == str[m[1]] && j == 2)
      cout << "Yes"
           << "\n";
    else if (j > 3)
      cout << "No"
           << "\n";
    else
      cout << "No"
           << "\n";
  }
}
