#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
map<ll, bool> hm;
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;
for(int j=i;j<=i+l;j++) {
h += s[j];
h *= A;
h %= B;
}
hm[h]=true;
}
}
int l; cin >> l;
for(int i=0;i<l;i++) {
string q;
cin >> q;
ll h = 0;
for(auto c : q) {
h += c;
h *= A;
h %= B;
}
cout<<(hm[h]?"YES":"NO")<<endl;
}
return 0;
}