#include <set>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;
set<ll> h[10];
ll x=2452343;
ll mod=1e9+7;
ll rhash(std::string& v){
ll h=0;
for(auto& c : v)h*=x,h+=c,h%=mod;
return h;
}
void cnthash(std::string& v,int l){
if(v.size()<l)return;
ll hh=0;
ll p=1;
for(int i=0;i<l;++i)p*=x,p%=mod;
for(int i=0;i<l;++i)hh*=x,hh+=v[i],hh%=mod;
h[l-1].emplace(hh);
for(int i=l;i<v.size();++i){
hh*=x;
hh-=v[i-l]*p;
hh+=v[i];
hh%=mod;
hh+=(hh>>63)&mod;
h[l-1].emplace(hh);
}
}
int main(){
string v;
cin>>v;
for(int i=1;i<=10;++i)cnthash(v,i);
int m;
cin>>m;
for(int i=0;i<m;++i){
cin>>v;
cout<<(h[v.size()-1].count(rhash(v))?"YES":"NO")<<'\n';
}
return 0;
}