## https://yukicoder.me/problems/no/2000 MAX_INT = 10 ** 18 def main(): S = input() D = [] for _ in range(26): D.append(list(map(int, input().split()))) # 組み上げ beta_dist_list = [[MAX_INT ] * 26 for _ in range(len(S))] beta_dist = [MAX_INT] * 26 for i in reversed(range(len(S))): for j in range(26): beta_dist_list[i][j] = beta_dist[j] s = S[i] s_ind = ord(s) - ord("a") beta_dist[s_ind] = i answers = [["Y" for _ in range(26)] for _ in range(26)] for i in range(len(S)): s = S[i] s_ind = ord(s) - ord("a") for t_ind in range(26): if beta_dist_list[i][t_ind] - i < D[s_ind][t_ind]: answers[s_ind][t_ind] = "N" for i in range(26): print(" ".join(answers[i])) if __name__ == "__main__": main()