SIGMA = 26 def main(): S = input() D = [list(map(int, input().split())) for _ in range(SIGMA)] ans = [[True for _ in range(SIGMA)] for _ in range(SIGMA)] prev = [-(10 ** 9) for _ in range(SIGMA)] for j, s in enumerate(S): b = ord(s) - ord("a") for a, i in enumerate(prev): ans[a][b] &= j - i >= D[a][b] prev[b] = j for a in ans: print(*["NY"[a::2] for a in a]) if __name__ == "__main__": main()