#include #include #include #include #include #include #include #define rep(i,n) for(i=0; i=a; --i) #define in(a) cin >> a #define out(a,b) cout << a << b #define print_vec(v) for(auto it=v.begin();it!=v.end();++it)cout<<*it <<" ";cout< > D(26, vector (26)); in(s); rep(i,26){ rep(j,26){ in(D[i][j]); } } vector > c_cnt(26); rep(i,s.size()) c_cnt[s[i]-'a'].push_back(i); vector > X(26, vector (26, 'A')); rep(i,26){ rep(j,26){ rep(x,c_cnt[i].size()){ rep(y,c_cnt[j].size()){ if(c_cnt[i][c_cnt[i].size()-x-1]c_cnt[j][y]) {X[i][j]='N';} break; } } } } } rep(i,26){ rep(j,26){ if(X[i][j]=='A') X[i][j]='Y'; } } rep(i,26){ rep(j,26){ out(X[i][j],""); if(j<25) out(" ",""); } out("",endl); } return 0; }