#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie();
#define ll long long
using namespace std;
#define A 124123423
#define B 283412834
#define C 582428341
map<ll, bool> hm;
map<ll, bool> hm2;
int main() { _
string s;
cin >> s;
int n = s.length();
for(int l=0;l<10;l++) {
for(int i=0;i+l<n;i++) {
ll h = 0, h2 = 0;
for(int j=i;j<=i+l;j++) {
h += s[j];
h *= A;
h %= B;
h2 += s[j];
h2 *= C;
h2 %= B;
}
hm[h]=true;
hm[h2]=true;
}
}
int l; cin >> l;
for(int i=0;i<l;i++) {
string q;
cin >> q;
ll h = 0, h2=0;
for(auto c : q) {
h += c;
h *= A;
h %= B;
h2 += c;
h2 *= C;
h2 %= B;
}
cout<<(hm[h]&&hm[h2]?"YES":"NO")<<endl;
}
return 0;
}