#include using namespace std; int main(){ string S; cin >> S; int N = S.size(); vector> D(26, vector(26)); for (int i = 0; i < 26; i++){ for (int j = 0; j < 26; j++){ cin >> D[i][j]; } } vector> id(26); for (int i = 0; i < N; i++){ id[S[i] - 'a'].push_back(i); } for (int i = 0; i < 26; i++){ for (int j = 0; j < 26; j++){ int cnt = id[i].size(); bool ok = true; for (int k = 0; k < cnt; k++){ auto itr = upper_bound(id[j].begin(), id[j].end(), id[i][k]); if (itr != id[j].end()){ if (*itr - id[i][k] < D[i][j]){ ok = false; } } } if (ok){ cout << 'Y'; } else { cout << 'N'; } if (j < 25){ cout << ' '; } } cout << endl; } }