import java.io.*; 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()); PrintWriter pw = new PrintWriter(System.out); for (int z = 0; z < t; z++) { long n = Long.parseLong(br.readLine()); if (n == 2) { pw.println("P"); continue; } long goal = 0; for (int i = 2; i < n; i++) { if (n % i != 0) { goal = i; break; } } long g = gcd(goal, n); if (g == 1) { pw.println("K"); } else { pw.println("P"); } } pw.flush(); br.close(); } static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } }