#include <bits/stdc++.h>
using namespace std;
int k, t;
char n1[10005];
char n2[10005];
int swapindex[2];
bool same(char x[], char y[], int n) {
  for (int i = 0; i < n; i++) {
    if (x[i] != y[i]) {
      return false;
    }
  }
  return true;
}
int ham(char x[], char y[], int n) {
  int temp = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] != y[i]) {
      temp++;
    }
  }
  return temp;
}
int main() {
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> t;
    for (int l = 0; l < t; l++) {
      cin >> n1[l];
    }
    for (int l = 0; l < t; l++) {
      cin >> n2[l];
    }
    if (ham(n1, n2, t) == 2) {
      int temp = 0;
      for (int i = 0; i < t; i++) {
        if (n1[i] != n2[i]) {
          swapindex[temp] = i;
          temp++;
        }
      }
      swap(n1[swapindex[0]], n2[swapindex[1]]);
      if (same(n1, n2, t)) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
