require 'prime' # 素数列挙 prime_generator = Prime::EratosthenesGenerator.new @primes = [] begin ; @primes << prime_generator.next ; end while @primes[-1]<10000 # dfs(num,you?) you?は勝つか? @memo={} def dfs(n,turn=true) return turn if n <= 1 return @memo[[n,turn]] if @memo.key?([n,turn]) res = !turn; @primes.each{|k| break if n-k<0 a=dfs(n-k,!turn) res=((res^a)&turn)|(res&a) } return @memo[[n,turn]]=res end puts dfs(gets.to_i) ? "Win" : "Lose"