#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
struct TreeNode {
    bool if_[26];
    
    TreeNode *word[26];
};
class TireTreeType {
    private:
        TreeNode *null,*root;
        
        inline void Insert_Tire(TreeNode *now,char str[])
        {
            int len=strlen(str);
            for(int i=0;i<len;i++)
            {
                if(!now->if_[str[i]-‘a‘])
                {
                    now->if_[str[i]-‘a‘]=true;
                    now->word[str[i]-‘a‘]=new TreeNode;
                    for(int j=0;j<26;j++) now->word[str[i]-‘a‘]->word[j]=null;
                }
                now=now->word[str[i]-‘a‘];
            }
        }
        
        inline bool Find_Tire(TreeNode *now,char str[])
        {
            int len=strlen(str);
            for(int i=0;i<len;i++)
            {
                if(now->if_[str[i]-‘a‘])
                {
                    now=now->word[str[i]-‘a‘];
                }
                else return false;
            }
            return true;
        }
        
    public:
        TireTreeType()
        {
            null=new TreeNode;
            for(int i=0;i<26;i++) null->word[i]=null;
            root=new TreeNode;
            for(int i=0;i<26;i++) root->word[i]=null;
        }
        
        void Insert(char str[])
        {
            Insert_Tire(root,str);
        }
        
        bool Find(char str[])
        {
            return Find_Tire(root,str);
        }
};
class TireTreeType tree;
int n,m;
char Cgets[10];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",Cgets);
        tree.Insert(Cgets);
    }
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%s",Cgets);
        if(tree.Find(Cgets)) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}