#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { string s; cin >> s; constexpr int ws = 26; vector a(ws, vector(ws)); rep(i, ws) rep(j, ws) cin >> a[i][j]; vector dist(ws, vector(ws, 1e9)); vector lastseen(ws, -1); rep(i, s.size()) { rep(j, ws) { if (lastseen[j] != -1) dist[j][s[i] - 'a'] = min(dist[j][s[i] - 'a'], i - lastseen[j]); } lastseen[s[i] - 'a'] = i; } rep(i, ws) { rep(j, ws) cout << (dist[i][j] >= a[i][j] ? 'Y' : 'N') << " "; cout << endl; } return 0; }