#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  for (int m; n--;) {
    std::vector<int> cur;
    std::string s1, s2;
    std::cin >> m >> s1 >> s2;
    for (int i = 0; i < m; ++i)
      if (s1[i] != s2[i]) {
        cur.push_back(i);
      }
    if (cur.size() != 2) {
      std::cout << "No\n";
      continue;
    }
    std::swap(s1[cur[1]], s2[cur[0]]);
    s1 == s2 ? std::cout << "Yes\n" : std::cout << "No\n";
  }
}
