require 'prime' inputs = STDIN.readlines.map(&:chomp) N = inputs[0].to_i class Calc def initialize @primes = Prime.instance.each(N).to_a @memos = Array.new(N) end def dp(n, turn) if n == 0 || n == 1 winner_is_me = true elsif !@memos[n].nil? winner_is_me = @memos[n] else ps = @primes.take_while { |p| p < n }.reverse winner_is_me = ps.any? { |p| dp(n - p, !turn) == turn } end @memos[n] = winner_is_me !(turn ^ winner_is_me) end end puts Calc.new.dp(N, true) ? 'Win' : 'Lose'