use std::cmp::*; use std::io::Read; fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin=stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } fn get() -> T { get_word().parse().ok().unwrap() } fn gcd(x: usize, y: usize) -> usize { if x < y { gcd(y, x) } else if y == 0 { x } else { gcd(y, x % y) } } // https://yukicoder.me/problems/no/2725 (3) // 実験の結果、n = 2, 6, 18, 30, 42, 54, ... で後手必勝、それ以外で先手必勝であることがわかる。 // これは n = 2, 6 + 12i とみなすことができる。 // 6+12i が後手必勝なのは、先手は初手で奇数に行くしかなく、後手は 4 に行けば勝てるためである。 // 他の場合で先手必勝なのもほとんど明らか。(12|N なら初手 5、2|N and not(3|N) なら初手 3 など) fn main() { let t: i32 = get(); for _ in 0..t { let n: i64 = get(); println!("{}", if n == 2 || n % 12 == 6 { "P" } else { "K" }); } }