t = int(input()) x = [int(input()) for i in range(t)] for i in x: if i % 9 == 0: print("Y") else: print("N")