#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
ll T,n,q,p,o;
char c;
signed main(){
cin>>T;
while(T--){
cin>>n>>q;
cin>>s>>t;
if(s==t)cout<<"Yes\n";
else cout<<"No\n";
for(int i=1;i<=q;i++)
{
cin>>o>>p>>c;
if(o==0)s[p]=c;
else t[p]=c;
if(s==t)cout<<"Yes\n";
else cout<<"No\n";
}
}
return 0;
}
开了O2都过不去