#include <bits/stdc++.h>
void test(std::istream& stream);
int main() {
  std::istream& stream = std::cin;
  int tests{};
  stream >> tests;
  for (int i = 0; i < tests; ++i) {
    test(stream);
  }
}
void test(std::istream& stream) {
  int length{};
  stream >> length;
  std::string lhs;
  std::string rhs;
  stream >> lhs >> rhs;
  std::vector<int> diffs;
  diffs.reserve(2);
  for (int i = 0; i < lhs.size(); ++i) {
    if (lhs[i] != rhs[i]) {
      diffs.push_back(i);
    }
    if (diffs.size() >= 3) {
      break;
    }
  }
  if (diffs.size() == 2 &&
      ((lhs[diffs[0]] == lhs[diffs[1]] && rhs[diffs[0]] == rhs[diffs[1]]))) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}
