var n,i,j,a:longint;s:array[1..100000] of string; p,u,k:longint; t:string;
procedure have;
var i,p:longint;c:char;
begin
p:=pos('*',t);
if p=0 then begin
for i:=1 to u do
if t=s[i] then begin writeln('YES');exit;end;
writeln('NO');
exit;
end
else
begin
for i:=1 to u do
begin
if length(s)=length(t) then
for j:=1 to length(s[i]) do
begin
c:=s[i][j];
s[i][j]:='*';
if t=s[i] then begin writeln('YES');exit; end
else
s[i][j]:=c;
end;
end;
writeln('NO');
exit;
end;
end;
begin
assign(input,'asm_talk.in');
reset(input);
assign(output,'asm_talk.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
read(a);
case a of
1:begin u:=u+1; readln(s[u]);end;
2:begin readln(t);have;end;
end;
end;
close(input);
close(output);
end.