require 'prime' N = gets.to_i # 0=Lose, 1=Win dp = Array.new(N+1){ nil } dp[0], dp[1] = -1, -1 # whileの条件式で邪魔だから値入れとく dp[2] = 0 dp[3] = 0 primes = Prime.each(N).to_a result = 1 while dp.include? nil froms = [] dp.each_with_index do | d, i | froms << i if d == (result ^ 1) end primes.each do | p | froms.each do | f | next if f+p > N dp[f+p] = result unless dp[f+p] end end result = result ^ 1 # bit反転 end case dp[-1] when 0 puts 'Lose' when 1 puts 'Win' else puts 'Illega' end