#include using namespace std; string s; int d[26][26], p[200001][26]; bool f[26][26]; int main() { cin >> s; for (int i = 0; i < 26; i++) { for (int j = 0; j < 26; j++) { cin >> d[i][j]; } } fill(p[0], p[0] + 26, -3e5); for (int i = 0; i < s.size(); i++) { int u = s[i] - 'a'; for (int j = 0; j < 26; j++) { if(j == u) p[i + 1][u] = i; else p[i + 1][j] = p[i][j]; if (p[i][j] + d[j][u] > i) f[j][u] = 1; } } for (int i = 0; i < 26; i++) { for (int j = 0; j < 26; j++) { if (!f[i][j]) cout << "Y"; else cout << "N"; if (j < 25) cout << " "; } cout << endl; } }