#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
char a[N], b[N];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    scanf("%s%s", a, b);
    int t = 0;
    int t1 = 0, t2 = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        t++;
        if (t == 1)
          t1 = i;
        else if (t == 2)
          t2 = i;
      }
      if (t == 3) break;
    }
    if (t != 2)
      printf("No\n");
    else {
      if (t == 0 || (a[t1] == a[t2] && b[t1] == b[t2]))
        printf("Yes\n");
      else
        printf("No\n");
    }
  }
  return 0;
}
