import sys # Set input function to read lines from stdin for potentially faster I/O input = sys.stdin.readline def solve(): """ Solves the problem for T test cases. Reads T, then for each test case reads an integer angle x (in degrees), determines if tan(x degrees) is rational, and collects the results. Finally, prints all results, each on a new line. """ # Read the total number of test cases. T = int(input()) # A list to store the 'Y' or 'N' result string for each test case. results = [] # Iterate T times, processing one test case per iteration. for _ in range(T): # Read the angle x (an integer representing degrees). # The problem statement guarantees 0 <= x < 90. x = int(input()) # Mathematical background: # It can be shown that for an integer angle x (in degrees), # tan(x degrees) is rational if and only if x is a multiple of 45 degrees, # excluding angles where tan is undefined (like 90 degrees, 270 degrees, etc.). # The relevant theorem involves roots of unity in the field of Gaussian rationals Q(i). # If tan(x degrees) is rational, then exp(i * x * pi / 90) must be one of {1, -1, i, -i}. # Analyzing these cases for x in the range [0, 90): # 1. exp(i * x * pi / 90) = 1 => x = 0. tan(0 deg) = 0 (rational). # 2. exp(i * x * pi / 90) = -1 => x = 90 (not in range). # 3. exp(i * x * pi / 90) = i => x = 45. tan(45 deg) = 1 (rational). # 4. exp(i * x * pi / 90) = -i => x = 135 (not in range). # Therefore, within the specified range 0 <= x < 90, tan(x degrees) is rational # if and only if x is 0 or 45. if x == 0 or x == 45: # If x is 0 or 45, tan(x degrees) is rational. results.append('Y') else: # For all other integer values of x in the range [0, 90), tan(x degrees) is irrational. results.append('N') # Print the collected results. # Using "\n".join(results) efficiently prints each result on a separate line. print("\n".join(results)) # The standard Python entry point check. # Ensures that solve() is called only when the script is executed directly. if __name__ == '__main__': solve()