#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+5;
string s[N];
ll n,q,op,x,y;
map<ll,char>a,b;
signed main(){
cin>>n>>q;
for(int i=1;i<=n;i++)
cin>>s[i];
for(int i=1;i<=q;i++)
{
cin>>op>>x>>y;
a.clear();
b.clear();
if(op==1)s[y]+=s[x],s[x]="";
else {
bool flag=true;
for(int j=0;j<s[x].size();j++)
a[s[x][j]]=1;
for(int j=0;j<s[y].size();j++)
if(a[s[y][j]]==0){flag=false;break;}
for(int j=0;j<s[y].size();j++)
b[s[y][j]]=1;
for(int j=0;j<s[x].size();j++)
if(b[s[x][j]]==0){flag=false;break;}
if(flag&&s[x].size()==s[y].size())cout<<"Yes\n";
else cout<<"No\n";
}
}
return 0;
}