func main() const n: int :: 5000000 var primes: []int :: #[n]int do primes[0] :: 2 var primesNum: int :: 1 for i(3, n, 2) for j(0, primesNum - 1) var prime: int :: primes[j] if(prime ^ 2 > i) break j end if if(i % prime = 0) skip i end if end for do primes[primesNum] :: i do primesNum :+ 1 end for var primeDict: dict :: #dict for i(0, primesNum - 1) do primeDict.add(primes[i], true) end for var t: int :: cui@inputInt() for(1, t) do cui@inputInt() var p: int :: cui@inputInt() var ans: int :: primeDict.get(p, &) ?(1, -1) do cui@print("\{ans}\n") end for end func