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