n=int(input())
l=[]
for i in range(n):
l.append(input())
print(l)
d={}
for i in l:
d[i]=True
print(d)
t=int(input())
for i in range(t):
s=input()
check=""
ans=[]
for j in s:
check=check+j
if(check in d):
ans.append(check)
check=""
for j in ans:
print(j,end=" ")
print()
To embed this program on your website, copy the following code and paste it into your website's HTML: