#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> S; vector> A(26, vector(26)); rep(y,26) rep(x,26) cin >> A[y][x]; vector> pos(26); rep(i,sz(S)){ pos[S[i]-'a'].pb(i); } string ny = "NY"; rep(a,26){ rep(b,26){ int flag = 1; rep(i,sz(pos[a])){ int p = pos[a][i]; auto x = upper_bound(all(pos[b]),p); if(x!=pos[b].end()&&p+A[a][b]>*x) flag=0; } if(b) cout << ' '; cout << ny[flag]; } cout << '\n'; } return 0; }