#include <bits/stdc++.h>
using namespace std;
int trie[600005][4], k, g;
char s[600005], temp[600005];
bool ans;
void insert(){
int index, node;
node = 0;
for(int i=0 ; s[i] ; i++){
index = s[i] - 'a';
if(trie[node][index] == -1){
trie[node][index] = k++;
}
node = trie[node][index];
}
trie[node][3] = 1;
}
void search(int i, int x, int node, int len){
int index;
g++;
index = s[i] - 'a';
if(i == len){
if(trie[node][3] == 1 && x==1)
ans = true;
return;
}
if(ans)
return;
if(x == 1){
if(trie[node][index] != -1)
search(i+1, 1, trie[node][index], len);
} else if(x == 0) {
if(trie[node][index] != -1)
search(i+1, 0, trie[node][index], len);
if(ans)
return;
for(int j=0 ; j<3 ; j++){
if(index != j){
if(trie[node][j] != -1)
search(i+1, 1, trie[node][j], len);
}
if(ans)
return;
}
}
}
int main(){
int n, m, l, index, flag;
cin>>n>>m;
k = 1;
for(int i=0 ; i<600005 ; i++){
for(int j=0 ; j<3 ; j++){
trie[i][j] = -1;
}
}
getchar();
for(int i=0 ; i<n ; i++){
scanf("%[^\n]s", s);
getchar();
insert();
}
for(int i=0 ; i<m ; i++){
scanf("%[^\n]s", s);
getchar();
l = strlen(s);
ans = false;
search(0, 0, 0, l);
if(ans){
printf("YES\n");
} else {
printf("NO\n");
}
}
cout<<g<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IHRyaWVbNjAwMDA1XVs0XSwgaywgZzsKY2hhciBzWzYwMDAwNV0sIHRlbXBbNjAwMDA1XTsKYm9vbCBhbnM7Cgp2b2lkIGluc2VydCgpewogICAgaW50IGluZGV4LCBub2RlOwogICAgbm9kZSA9IDA7CiAgICBmb3IoaW50IGk9MCA7IHNbaV0gOyBpKyspewogICAgICAgIGluZGV4ID0gc1tpXSAtICdhJzsKICAgICAgICBpZih0cmllW25vZGVdW2luZGV4XSA9PSAtMSl7CiAgICAgICAgICAgIHRyaWVbbm9kZV1baW5kZXhdID0gaysrOwogICAgICAgIH0gCiAgICAgICAgbm9kZSA9IHRyaWVbbm9kZV1baW5kZXhdOwogICAgfQoKICAgIHRyaWVbbm9kZV1bM10gPSAxOwp9Cgp2b2lkICBzZWFyY2goaW50IGksIGludCB4LCBpbnQgbm9kZSwgaW50IGxlbil7CiAgICBpbnQgaW5kZXg7CiAgICBnKys7CiAgICBpbmRleCA9IHNbaV0gLSAnYSc7CiAgICBpZihpID09IGxlbil7CiAgICAgICAgaWYodHJpZVtub2RlXVszXSA9PSAxICYmIHg9PTEpCiAgICAgICAgICAgIGFucyA9IHRydWU7CiAgICAgICAgcmV0dXJuOwogICAgfSAKCiAgICBpZihhbnMpCiAgICAgICAgcmV0dXJuOwoKICAgIGlmKHggPT0gMSl7CiAgICAJaWYodHJpZVtub2RlXVtpbmRleF0gIT0gLTEpCiAgICAgICAJCXNlYXJjaChpKzEsIDEsIHRyaWVbbm9kZV1baW5kZXhdLCBsZW4pOwogICAgfSBlbHNlIGlmKHggPT0gMCkgewogICAgCWlmKHRyaWVbbm9kZV1baW5kZXhdICE9IC0xKQogICAgCQlzZWFyY2goaSsxLCAwLCB0cmllW25vZGVdW2luZGV4XSwgbGVuKTsKICAgIAlpZihhbnMpCiAgICAJCXJldHVybjsKICAgICAgICBmb3IoaW50IGo9MCA7IGo8MyA7IGorKyl7CiAgICAgICAgICAgIGlmKGluZGV4ICE9IGopewogICAgICAgICAgICAJaWYodHJpZVtub2RlXVtqXSAhPSAtMSkKICAgICAgICAgICAgICAgCSBzZWFyY2goaSsxLCAxLCB0cmllW25vZGVdW2pdLCBsZW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmKGFucykKICAgICAgICAgICAgCXJldHVybjsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKCl7CiAgICBpbnQgbiwgbSwgbCwgaW5kZXgsIGZsYWc7CiAgICBjaW4+Pm4+Pm07CgogICAgayA9IDE7CiAgICBmb3IoaW50IGk9MCA7IGk8NjAwMDA1IDsgaSsrKXsKICAgICAgICBmb3IoaW50IGo9MCA7IGo8MyA7IGorKyl7CiAgICAgICAgICAgIHRyaWVbaV1bal0gPSAtMTsKICAgICAgICB9CiAgICB9CgogICAgZ2V0Y2hhcigpOwogICAgZm9yKGludCBpPTAgOyBpPG4gOyBpKyspewogICAgICAgIHNjYW5mKCIlW15cbl1zIiwgcyk7CiAgICAgICAgZ2V0Y2hhcigpOwogICAgICAgIGluc2VydCgpOwogICAgfQoKICAgIGZvcihpbnQgaT0wIDsgaTxtIDsgaSsrKXsKICAgICAgICBzY2FuZigiJVteXG5dcyIsIHMpOwogICAgICAgIGdldGNoYXIoKTsKICAgICAgICBsID0gc3RybGVuKHMpOwogICAgICAgIGFucyA9IGZhbHNlOwoKICAgICAgICBzZWFyY2goMCwgMCwgMCwgbCk7CgogICAgICAgIGlmKGFucyl7CiAgICAgICAgICAgIHByaW50ZigiWUVTXG4iKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwcmludGYoIk5PXG4iKTsKICAgICAgICB9CiAgICB9CgoJY291dDw8Zzw8ZW5kbDsKICAgIHJldHVybiAwOwp9
OSA5CmNhY2NiY2FjYWJjY2JhCmFhY2JjYmNhYWJhY2JjYmNiYQpiYWJjY2FhYWNjY2FjYmIKY2FhYWJjYWFjYmFiYWJiYWJiYgphYmJhY2NhY2FiYWNhYWFhCmJjY2JjY2FiYWJjYWFjYgpjYWFjYmNhYWNiYWJhYmJhYmJiCmJjYWNhYmFiYmJjYWFjYQpjY2JiY2JhYmFiYmNjYWFiCmJiY2JjY2FiYWJjYWFjYgphYWNjY2JhYmJhY2JhYmFjYWNhCmJiY2JjY2NiYWJjYWFjYgphY2JhY2FjYmNhY2MKY2FhYWJjYWFhYmFjYWJiYWJiYgphYmJiYWJhYWFiYQphYWNjY2JjYWFiYWNiY2JjYmEKYWJiYWNjYWNhYmJjYWFhYQphYWNjYmJjYWJiYWNiY2JjYmE=
9 9
caccbcacabccba
aacbcbcaabacbcbcba
babccaaacccacbb
caaabcaacbababbabbb
abbaccacabacaaaa
bccbccababcaacb
caacbcaacbababbabbb
bcacababbbcaaca
ccbbcbababbccaab
bbcbccababcaacb
aacccbabbacbabacaca
bbcbcccbabcaacb
acbacacbcacc
caaabcaaabacabbabbb
abbbabaaaba
aacccbcaabacbcbcba
abbaccacabbcaaaa
aaccbbcabbacbcbcba