import java.util.*; import java.io.*; public class Main { public static void main(String[]args){ Scanner sc = new Scanner(System.in); PrintWriter ou = new PrintWriter(System.out); int t = Integer.parseInt(sc.next()); for(int i = 0 ; i < t ; i++){ int a = Integer.parseInt(sc.next()); if(a % 45 == 0) ou.println("Y"); else ou.println("N"); } ou.flush(); } }