#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string str[1001]={""},s;
int main()
{
freopen("asm_talk.in","r",stdin);
freopen("asm_talk.out","w",stdout);
int m,tot=1,w,O,OO;
scanf("%d",&m);
for (int i=1;i<=m;i++)
{
scanf("%d",&w);
if (w==1) getline(cin,str[tot++]);
if (w==2)
{
s="";
getline(cin,s);
OO=0;
for (int j=1;j<=tot-1;j++)
{
if (str[j].length()==s.length())
{
O=0;
for(int k=1;k<str[j].size();k++)
{
if (s[k]=='*'||s[k]==str[j][k]){}
else {O=1;break;}
}
if (O==0)
OO=1;
}
if (OO==1) {cout<<"YES"<<endl;break;}
}
if (OO==0) cout<<"NO"<<endl;
}
}
}