var tot,i,j,n,x:longint;c:char;ss:string;s:array[1..100005]of string;ff:boolean;
function judge(y:longint):boolean;
var k:longint;fff:boolean;
begin
fff:=true;
if length(ss)<>length(s[y])
then exit(false);
for k:=1 to length(ss) do
if (ss[k]<>s[y][k])and(ss[k]<>'*')and(s[y][k]<>'*')
then exit(false);
exit(fff);
end;
begin
assign(input,'asm_talk.in');
assign(output,'asm_talk.out');
reset(input);
rewrite(output);
readln(n);
tot:=0;
for i:=1 to n do
begin
read(x);
read(c);
if x=1 then
begin inc(tot);readln(s[tot]);end;
if x=2 then
begin
ff:=false;
readln(ss);
for j:=1 to tot do
if judge(j)
then ff:=true;
if ff
then writeln('YES')
else writeln('NO');end;
end;
close(input);
close(output);
end.