main = interact $ unlines . map (show . goldbach . read) . init . lines
 
goldbach x
 | odd x = 0
 | otherwise = length [() | a <- primes x, b <- primes x, a+b == x, a<=b]

primes n = take n (2 : f [3] [3,5..])
 where f (x:xs) ys = let (ps,qs) = span (< x^2) ys in ps ++ f (xs++ps) [z | z<-qs, mod z x /= 0]