#include <bits/stdc++.h>
using namespace std;
int fastread() {
  int fh = 1, x = 0;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') {
    fh = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return fh * x;
}
char a[10010];
int main() {
  int T = fastread();
  char p, fl1, ll1, fl2, ll2;
  for (; T; --T) {
    int n = fastread(), tmp = 0;
    for (int i = 1; i <= n; i++) a[i] = getchar();
    p = getchar();
    for (int i = 1; i <= n; i++) {
      p = getchar();
      if (p != a[i]) {
        tmp++;
        fl1 = ll1;
        ll1 = a[i];
        fl2 = ll2;
        ll2 = p;
      }
    }
    if (tmp == 2 && fl1 == ll1 && fl2 == ll2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
