import sys input = sys.stdin.readline query = [int(input()) for _ in [0] * int(input())] m = max(query) is_prime = [True] * (m + 1) is_prime[0] = is_prime[1] = False for i in range(2, m): if not(is_prime[i]): continue for j in range(i << 1, m + 1, i): is_prime[j] = False prime_cnt = [0] * (m + 1) half_prime_cnt = [0] * (m + 1) ans = [''] * (m + 1) for n in range(2, m + 1): prime_cnt[n] = prime_cnt[n - 1] + is_prime[n] half_prime_cnt[n] += half_prime_cnt[n - 1] if(is_prime[n]): ans[n] = 'P' k = n << 1 if(k <= m): half_prime_cnt[k] += 1 continue if((prime_cnt[n] - half_prime_cnt[n]) & 1): ans[n] = 'K' else: ans[n] = 'P' for k in query: print(ans[k])