#include <stdio.h> #include <string.h> # define MaxSize 10010 char line_0[MaxSize]; char line_1[MaxSize]; int main() { int k; int n; scanf("%d", &k); while(k--) { int Count=0; memset(line_0, 0, sizeof(char)*MaxSize); memset(line_1, 0, sizeof(char)*MaxSize); scanf("%d", &n); getchar(); scanf("%s", line_0); scanf("%s", line_1); int i; int flag_0=0, flag_1=0; for(i=0; i<n; ++i) { if(line_0[i]!=line_1[i]) { ++Count; if(Count==1) flag_0=i; else flag_1=i; } if(Count>2) break; } if(Count==2) { if((line_0[flag_0]==line_0[flag_1])&&(line_1[flag_0]==line_1[flag_1])) printf("YES\n"); else printf("NO\n"); } else printf("NO\n"); } return 0; }