#include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main() { string S; cin>>S; vector D(26,vector(26)); rep(i,26){ rep(j,26){ cin>>D[i][j]; } } vector ans(26,string(26,'Y')); vector maxi(26,-Inf); rep(i,S.size()){ rep(j,26){ if(i - maxi[j] < D[j][S[i]-'a'])ans[j][S[i]-'a'] = 'N'; } maxi[S[i]-'a'] = i; } rep(i,26){ rep(j,26){ if(j!=0)cout<<' '; cout<