#include <bits/stdc++.h>
using namespace std;
char s[10001], t[10001];
int main() {
  int k;
  scanf("%d", &k);
  while (k--) {
    int n;
    scanf("%d%s%s", &n, s + 1, t + 1);
    vector<int> v;
    for (int i = 1; i <= n; i++) {
      if (s[i] != t[i]) v.push_back(i);
    }
    if (v.size() == 2) {
      if (s[v[0]] == s[v[1]] && t[v[0]] == t[v[1]])
        printf("Yes\n");
      else
        printf("No\n");
    } else
      printf("No\n");
  }
}
