#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbXAgbWFrZV9wYWlyCnR5cGVkZWYgbG9uZyBsb25nIGxsOwptYXA8bGwsYm9vbD4gbTsKY29uc3QgbGwgTU9EPTFlMTYrNzsKaW50IG1haW4oKQp7CiAgICBpbnQgbjsgY2luPj5uOwogICAgZm9yKGludCBpPTA7aTxuO2krKykKICAgIHsKICAgICAgICBzdHJpbmcgczsgY2luPj5zOwogICAgICAgIGxsIGhhc2g9MDsKICAgICAgICBmb3IoaW50IGo9MDtqPHMuc2l6ZSgpO2orKykKICAgICAgICB7CiAgICAgICAgICAgIGhhc2g9aGFzaCo0KyhsbCkoc1tqXS0nYScrMSk7CiAgICAgICAgICAgIGhhc2g9aGFzaCVNT0Q7CiAgICAgICAgfQogICAgICAgIG1baGFzaF09dHJ1ZTsKICAgIH0KICAgIGludCBtOyBjaW4+Pm07CiAgICBmb3IoaW50IGk9MDtpPG07aSsrKQogICAgewogICAgICAgIGJvb2wgZmxhZz1mYWxzZTsKICAgICAgICBzdHJpbmcgczsgY2luPj5zOwogICAgICAgIGxsIGhhc2g9MDsKICAgICAgICBmb3IoaW50IGo9MDtqPHMuc2l6ZSgpO2orKykKICAgICAgICB7CiAgICAgICAgICAgIGhhc2g9aGFzaCo0KyhsbCkoc1tqXS0nYScrMSk7CiAgICAgICAgICAgIGhhc2g9aGFzaCVNT0Q7CiAgICAgICAgfQogICAgICAgIGxsIHo9MTsKICAgICAgICBmb3IoaW50IGo9cy5zaXplKCktMTtqPj0wO2otLSkKICAgICAgICB7CiAgICAgICAgICAgIGZvcihjaGFyIGM9J2EnO2M8PSdjJztjKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKGMhPXNbal0pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbGwgaGFzaDE9aGFzaDsKICAgICAgICAgICAgICAgICAgICBoYXNoMS09KGxsKSgoKHNbal0tJ2EnKzEpKnopJU1PRCk7CiAgICAgICAgICAgICAgICAgICAgaGFzaDErPShsbCkoKChjLSdhJysxKSp6KSVNT0QpOwogICAgICAgICAgICAgICAgICAgIGhhc2gxPShoYXNoMStNT0QpJU1PRDsKCiAgICAgICAgICAgICAgICAgICAgaWYobVtoYXNoMV0pCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBmbGFnPXRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZihmbGFnPT10cnVlKQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIHo9eio0OwogICAgICAgICAgICB6PXolTU9EOwogICAgICAgIH0KICAgICAgICBpZihmbGFnPT10cnVlKQogICAgICAgICAgICBjb3V0PDwiWUVTIjsKICAgICAgICBlbHNlCiAgICAgICAgICAgIGNvdXQ8PCJOTyI7CiAgICAgICAgY291dDw8ZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9