#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, c = 0, t;
  cin >> t;
  while (t--) {
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    int k = -1;
    for (j = 0; j < s1.length(); j++) {
      if (s1[j] != s2[j]) {
        if (k < 0) {
          k = j;
        } else {
          swap(s1[j], s2[k]);
          break;
        }
      }
    }
    if (s1 == s2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
