#include <bits/stdc++.h>
using namespace std;
const int A = 15;
int a, b, k, n, x[A];
string s, g;
int main() {
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> n >> s >> g;
    for (int j = 0; j < n; j++) {
      if (s[j] != g[j] && a == 0) {
        a = j + 1;
      } else if (s[j] != g[j] && b == 0) {
        b = j + 1;
        if (s[a - 1] != s[b - 1] || g[a - 1] != g[b - 1]) {
          x[i] = 1;
        }
      } else if (s[j] != g[j]) {
        x[i] = 1;
        break;
      }
    }
    if (a > 0 && b == 0) {
      x[i] = 1;
    }
    a = 0;
    b = 0;
  }
  for (int i = 0; i < k; i++) {
    if (x[i] == 1) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}
