#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
map<ll,bool> m;
const ll MOD=1e16+7;
int main()
{
    int n; cin>>n;
    for(int i=0;i<n;i++)
    {
        string s; cin>>s;
        ll hash=0;
        for(int j=0;j<s.size();j++)
        {
            hash=hash*4+(ll)(s[j]-'a'+1);
            hash=hash%MOD;
        }
        m[hash]=true;
    }
    int m; cin>>m;
    for(int i=0;i<m;i++)
    {
        bool flag=false;
        string s; cin>>s;
        ll hash=0;
        for(int j=0;j<s.size();j++)
        {
            hash=hash*4+(ll)(s[j]-'a'+1);
            hash=hash%MOD;
        }
        ll z=1;
        for(int j=s.size()-1;j>=0;j--)
        {
            for(char c='a';c<='c';c++)
            {
                if(c!=s[j])
                {
                    ll hash1=hash;
                    hash1-=(ll)(((s[j]-'a'+1)*z)%MOD);
                    hash1+=(ll)(((c-'a'+1)*z)%MOD);
                    hash1=(hash1+MOD)%MOD;

                    if(m[hash1])
                    {
                        flag=true;
                        break;
                    }
                }
            }
            if(flag==true)
                break;
            z=z*4;
            z=z%MOD;
        }
        if(flag==true)
            cout<<"YES";
        else
            cout<<"NO";
        cout<<endl;
    }
    return 0;
}