#include using namespace std; using ll = long long; int main(){ string s; cin >> s; vector tb(26, 1 << 30); vector> A(26, vector(26, 1 << 30)); for(int i = s.size() - 1; i >= 0; i--){ for(int j = 0; j < 26; j++){ A[s[i] - 'a'][j] = min(A[s[i] - 'a'][j], tb[j] - i); } tb[s[i] - 'a'] = i; } for(int i = 0, v; i < 26; i++){ for(int j = 0; j < 26; j++){ cin >> v; if(j) cout << " "; cout << (v <= A[i][j] ? 'Y' : 'N'); } cout << '\n'; } }