using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new bool[t]; for (var u = 0; u < t; ++u) { var n = long.Parse(ReadLine()); for (var i = 2; i < 60 && i < n; ++i) { if (GCD(n, i) == 1) { ans[u] = true; break; } if (n % i != 0) { break; } } } WriteLine(string.Join("\n", ans.Select(f => f ? "K" : "P"))); } static long GCD(long a, long b) { if (a < b) return GCD(b, a); if (a % b == 0) return b; return GCD(b, a % b); } }