Showing errror on testcase 2

#include<bits/stdc++.h>

using namespace std;

int main() {

int t;

cin>>t;

while(t–){

string s1,s2,s3;

int m,n;

cin>>n >>m;

cin>>s1;

cin>>s2;

int w=0;

int xrr[26]={0};

int yrr[26]={0};

char arr[26];

int brr[26]={0};

int k=0,l=0;

for(int i=0;i<26;i++){

arr[i] = 97+i;

}

for(int i=0;i<(n);i++){

char ch;

ch=s1[i];

if(arr[ch-97]==ch){

    xrr[ch-97]++;

}

}

for(int i=0;i<26;i++){

if(xrr[i] != 0){

    k++;

   

}

}

for(int i=0;i<(m);i++){

char ch;

ch=s2[i];

if(arr[ch-97]==ch){

    yrr[ch-97]++;

}

}

for(int i=0;i<26;i++){

if(yrr[i] != 0){

    l++;

   

}

}

int key4=0;

if(n>m){

for(int i=0;i<26;i++){

if(xrr[i] >= yrr[i] && xrr[i] !=0 && yrr[i] !=0){

    w++;

}

}

if(w != min(k,l)){

cout<<"NO"<<endl;

key4=1;

}

}

if(n<=m){

for(int i=0;i<26;i++){

if(xrr[i] <= yrr[i] && xrr[i] !=0 && yrr[i] !=0){

    w++;

}

}

if(w != min(k,l)){

cout<<"NO"<<endl;

key4 =1;

}

}

if(key4 ==0){

s3=s1+s2;

for(int i=0;i<(m+n);i++){

char ch;

ch=s3[i];

if(arr[ch-97]==ch){

    brr[ch-97]++;

}

}

int uniq=0,counter=0;

for(int i=0;i<26;i++){

if(brr[i] != 0){

    uniq++;

   

}

}

for(int i=0;i<26;i++){

if(brr[i]%2 == 1){

    counter++;

}

}

if((m+n)%2 == 0){

if(counter>0){

    cout<<"no"<<endl;

}

else{

    if(uniq <= (m+n)/2){

        cout<<"yes"<<endl;

    }

    else{

        cout<<"no"<<endl;

    }

}

}

if((m+n)%2 == 1){

if(counter>1){

    cout<<"no"<<endl;

}

else{

    if(uniq <= ((m+n)/2)+1){

        cout<<"yes"<<endl;

    }

    else{

        cout<<"no"<<endl;

    }

}

}

}

}

return 0;

}