//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_M = 100100;
const int MAX_N = 1100;
const int MAX_WORD = 1100;
const int MAX_AHO = 800100;
const int MAX_LETTERS = 63;
const int REDUCTION = 1;
char M[MAX_M];
int N;
bool isPresent[MAX_N];
vector<int> repeats[MAX_N];
int lett(char c)
{
if('a' <= c && c <= 'z') return 1+c-'a';
else if('A' <= c && c <= 'Z') return 1+26+c-'A';
else return 1+52+c-'0';
}
struct node
{
int val;
int terminal;
int parent;
int children[MAX_LETTERS];
int fail;
node()
{
val = 0;
terminal = 0;
parent = 0;
memset(children, 0, sizeof(children));
fail = 0;
}
};
node aho[MAX_AHO/REDUCTION]; int sz;
char curWord[MAX_WORD]; int cwIdx;
void add_word()
{
int wLen = strlen(curWord);
int idx = 1, pos = 0;
while(true)
{
if(pos == wLen)
{
if(aho[idx].terminal == 0) aho[idx].terminal = cwIdx++;
else repeats[aho[idx].terminal].push_back(cwIdx++);
break;
}else if(aho[idx].children[lett(curWord[pos])] != 0) idx = aho[idx].children[lett(curWord[pos])];
else
{
aho[idx].children[lett(curWord[pos])] = sz;
aho[sz].val = lett(curWord[pos]);
aho[sz].parent = idx;
idx = sz++;
}
++pos;
}
}
int fail(int idx, int val)
{
while(true)
{
if(aho[idx].children[val] != 0) return aho[idx].children[val];
else if(idx == 1) return 1;
idx = aho[idx].fail;
}
}
void build_fails()
{
queue<int> q;
q.push(1);
while(!q.empty())
{
int u = q.front();
q.pop();
for(int i = 0; i < MAX_LETTERS; i++)
if(aho[u].children[i] != 0)
{
if(u == 1) aho[aho[u].children[i]].fail = 1;
else aho[aho[u].children[i]].fail = fail(aho[u].fail, i);
q.push(aho[u].children[i]);
}
}
}
int main (int argc, const char * argv[])
{
scanf("%s", M);
scanf("%d", &N);
int mLen = strlen(M);
for(int r = 1; r <= REDUCTION; r++)
{
memset(isPresent, 0, sizeof(isPresent));
for(int i = 0; i < MAX_N; i++)
repeats[i].clear();
memset(aho, 0, sizeof(aho));
sz = 2;
cwIdx = 1;
for(int i = N*(r-1)/REDUCTION; i < N*r/REDUCTION; i++)
{
scanf("%s", curWord);
add_word();
}
build_fails();
for(int i = 0, idx = 1; i < mLen; i++)
{
idx = fail(idx, lett(M[i]));
int curIdx = idx;
while(aho[curIdx].terminal != 0)
{
isPresent[aho[curIdx].terminal] = true;
aho[curIdx].terminal = 0;
curIdx = aho[curIdx].fail;
}
}
for(int i = 1; i <= (N*r/REDUCTION)-N*(r-1)/REDUCTION; i++)
for(int j = 0; j < sz(repeats[i]); j++)
isPresent[repeats[i][j]] = true;
for(int i = 1; i <= (N*r/REDUCTION)-N*(r-1)/REDUCTION; i++)
if(isPresent[i]) cout << "Y\n";
else cout << "N\n";
}
return 0;
}