import Data.Bool import Data.List import Data.IntMap ((!)) import qualified Data.IntMap as M primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x] where isPrime n = null [i | i <- takeWhile (\x -> x^2 <= n) primes, rem n i == 0] main = readLn >>= putStrLn . bool "Lose" "Win" . pgame pgame n = (foldl' grundy (M.fromList [(2,0),(3,0)]) [4..n]) ! n /= 0 where grundy im i = M.insert i (minimum ([0..11] \\ (map (im!) (takeWhile (>=2) (map (i-) primes))))) im