local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs local function getprimes(x) local primes = {} local allnums = {} for i = 1, x do allnums[i] = true end for i = 2, x do if allnums[i] then table.insert(primes, i) local lim = mfl(x / i) for j = 2, lim do allnums[j * i] = false end end end return primes end local function getdivisorparts(x, primes) local zzz = 1 local prime_num = #primes local lim = mce(msq(x)) local primepos = 1 local dv = primes[primepos] while primepos <= prime_num and dv <= lim do if x % dv == 0 then local cnt = 1 x = mfl(x / dv) while x % dv == 0 do x = mfl(x / dv) cnt = cnt + 1 end zzz = zzz * (cnt + 1) lim = mce(msq(x)) end if primepos == prime_num then break end primepos = primepos + 1 dv = primes[primepos] end if x ~= 1 then zzz = zzz * 2 end return zzz end local primes = getprimes(1000) local q = io.read("*n") for iq = 1, q do local n = io.read("*n") local z = getdivisorparts(n, primes) print(z % 2 == 0 and "K" or "P") end