import java.io.*; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); int m = 3000000; Eratosthenes era = new Eratosthenes(m); int[] a = new int[m + 1]; for (int i = 2; i < a.length; i++) { if (era.isSosuu(i)) { a[i]++; } a[i] += a[i - 1]; } PrintWriter pw = new PrintWriter(System.out); for (int z = 0; z < t; z++) { int n = Integer.parseInt(br.readLine()); if (era.isSosuu(n)) { pw.println("P"); } else { int num = n - 2 - (a[n] - a[n / 2]); if (num % 2 == 1) { pw.println("K"); } else { pw.println("P"); } } } pw.flush(); br.close(); } static class Eratosthenes { int[] div; public Eratosthenes(int n) { div = new int[n + 1]; if (n < 2) return; div[0] = -1; div[1] = -1; int end = (int) Math.sqrt(n) + 1; for (int i = 2; i <= end; i++) { if (div[i] == 0) { div[i] = i; for (int j = i * i; j <= n; j+=i) { if (div[j] == 0) div[j] = i; } } } for (int i = end + 1; i <= n; i++) { if (div[i] == 0) div[i] = i; } } public Map bunkai(int x) { Map soinsu = new HashMap<>(); while (x > 1) { Integer d = div[x]; soinsu.put(d, soinsu.getOrDefault(d, 0) + 1); x /= d; } return soinsu; } public boolean isSosuu(int x) { return div[x] == x; } } }