from bisect import bisect_right S = input().strip() C = {chr(i):[] for i in range(97,123)} for i in range(len(S)): C[S[i]].append(i) D = [list(map(int,input().split())) for _ in range(26)] X = [["Y" for _ in range(26)] for _ in range(26)] for i in range(26): a = chr(97+i) if len(C[a])==0:continue for j in range(26): b = chr(97+j) if len(C[b])==0:continue flag = "Y" for k in range(len(C[a])): inda = C[a][k] ind = bisect_right(C[b],inda) if ind==len(C[b]): continue indb = C[b][ind] if inda+D[i][j]>indb: flag = "N" break X[i][j] = flag for i in range(26): print(*X[i])