#include int min(int a, int b) { if (a < b) return a; else return b; } int main() { char s[200005]; scanf("%s", s); int i, j, k; int d[33][33]; for (i = 0; i < 26; i++) for (j = 0; j < 26; j++) scanf("%d", &d[i][j]); int n; for (n = 0; s[n] != '\0'; n++); int cnt[200005]; int ans[33][33]; for (i = 0; i < 33; i++) for (j = 0; j < 33; j++) ans[i][j] = 0; for (j = 0; j < 26; j++) { cnt[0] = 0; for (i = 0; i < n; i++) { cnt[i + 1] = cnt[i]; if (s[i] == 'a' + j) cnt[i + 1]++; } for (i = 0; i < n; i++) { k = s[i] - 'a'; if (cnt[min(n, i + d[k][j])] - cnt[i + 1] > 0) ans[k][j]++; } } for (i = 0; i < 26; i++) { for (j = 0; j < 25; j++) { if (ans[i][j] > 0) printf("N "); else printf("Y "); } if (ans[i][25] > 0) printf("N\n"); else printf("Y\n"); } return 0; }