//tonynater - SPOJ 2013
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define sz(x) ((int) x.size())
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
const double pi = acos(-1);
const double tau = 2*pi;
const double epsilon = 1e-6;
const int MAX_N = 1100;
const int MAX_AHO = 2000100;
string M;
int N;
bool isPresent[MAX_N];
vector<int> repeats[MAX_N];
struct node
{
int val;
int terminal;
int parent;
map<int, int> children;
int fail;
node()
{
val = -1;
terminal = -1;
parent = -1;
children.clear();
fail = -1;
}
};
node aho[MAX_AHO]; int sz = 1;
string curWord; int cwIdx;
void add_word()
{
int idx = 0, pos = 0;
while(true)
{
if(pos == sz(curWord))
{
if(aho[idx].terminal == -1) aho[idx].terminal = cwIdx++;
else repeats[aho[idx].terminal].push_back(cwIdx++);
break;
}else if(aho[idx].children.count(curWord[pos]) > 0) idx = aho[idx].children[curWord[pos]];
else
{
aho[idx].children[curWord[pos]] = sz;
aho[sz].val = curWord[pos];
aho[sz].parent = idx;
idx = sz++;
}
++pos;
}
}
int fail(int idx, int val)
{
while(true)
if(aho[idx].children.count(val) > 0) return aho[idx].children[val];
else if(idx == 0) return 0;
else idx = aho[idx].fail;
}
void build_fails()
{
queue<int> q;
q.push(0);
while(!q.empty())
{
int u = q.front();
q.pop();
for(map<int,int>::const_iterator it = aho[u].children.begin(); it != aho[u].children.end(); it++)
{
if(u == 0) aho[it->second].fail = 0;
else aho[it->second].fail = fail(aho[u].fail, it->first);
q.push(it->second);
}
}
}
int main (int argc, const char * argv[])
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> M >> N;
for(int i = 0; i < N; i++)
{
cin >> curWord;
add_word();
}
build_fails();
for(int i = 0, idx = 0; i < sz(M); i++)
{
idx = fail(idx, M[i]);
int curIdx = idx;
while(aho[curIdx].terminal != -1)
{
isPresent[aho[curIdx].terminal] = true;
aho[curIdx].terminal = -1;
curIdx = aho[curIdx].fail;
}
}
for(int i = 0; i < N; i++)
if(isPresent[i])
for(int j = 0; j < sz(repeats[i]); j++)
isPresent[repeats[i][j]] = true;
for(int i = 0; i < N; i++)
if(isPresent[i]) cout << "Y\n";
else cout << "N\n";
return 0;
}