//trie tree的储存方式:将字母储存在边上,边的节点连接与它相连的字母
//trie[now].next[x]=tot:now是上个节点编号,x是字母,tot是下个节点编号
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 300010
struct node{
int next[27];
int w;
}tire[N];
int n,m,cnt=0;
char s[10];
void build(){
int now=0,len=strlen(s);
for(int i=0;i<len;i++){
int x=s[i]-'a'+1;
if(!tire[now].next[x])//现在插入的字母在之前同一节点处未出现过
tire[now].next[x]=++cnt;//字母插入一个新的位置,否则不做处理
now=tire[now].next[x];//为下个字母的插入做准备
}
//tire[now].w=1;//标记以当前字母结束的点--为整个单词的查询做准备(本题没有意义)
}
int query(){
int now=0,p=0,len=strlen(s);
while(p<len){
if(!tire[now].next[s[p]-'a'+1])//以now为头结点的x字母不存在,返回0
return 0;
now=tire[now].next[s[p++]-'a'+1];//为查询下个字母做准备
}
return 1;//查前缀 返回
// return tire[now].w;//查完整单词 返回
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%s",s),build();
scanf("%d",&m);
for(int i=1;i<=m;i++)
scanf("%s",s),printf("%s\n",query()?"YES":"NO");
return 0;
}