#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #include using namespace atcoder; using mint = modint998244353; #define rep(i, n) for (int i = 0; i < n; i++) #define endl '\n' #define ALL(a) (a).begin(), (a).end() int d[26][26]; bool a[26][26]; int t[26]; int main() { string s; cin >> s; rep(i, 26) rep(j, 26) cin >> d[i][j], a[i][j] = true; rep(i, 26) t[i] = -1e9; const int n = s.length(); rep(j, n) { const int c = s[j] - 'a'; rep(i, 26) a[i][c] &= t[i] + d[i][c] <= j; t[c] = j; } rep(i, 26) { rep(j, 25) cout << (a[i][j] ? 'Y' : 'N') << " "; cout << (a[i][25] ? 'Y' : 'N') << endl; } return 0; }