var
s,s2,s3,sch:string;
begin
readln(s);
readln(s2);
readln(s3);
s:= s + ' ';
while pos(' ',s) > 0 do begin
sch:= copy(s,1,pos(' ',s)-1);
delete(s,1,pos(' ',s));
if (pos(sch,s2) > 0) and (pos(sch,s3) > 0) then
writeln(sch);
end;
end.