#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n;
  scanf("%d", &k);
  for (int ik = 0; ik < k; ik++) {
    scanf("%d", &n);
    char a[10000], b[10000], c;
    scanf("%c", &c);
    for (int i = 0; i < n; i++) {
      scanf("%c", a + i);
    }
    scanf("%c", &c);
    for (int i = 0; i < n; i++) {
      scanf("%c", b + i);
    }
    int diff = 0;
    char first, second;
    bool bad = false;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (diff == 0) {
          first = a[i];
          second = b[i];
        } else {
          if (first != a[i] || second != b[i]) {
            bad = true;
          }
        }
        diff++;
      }
    }
    if (diff == 2 && !bad) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
