Under construction

Still being built. Things may change

Number Game

Interview

Time limit2sMemory limit128 MB

Summary
Given a set of numbers including 1 and a limit K, find the first integer that cannot be formed using at most K chosen numbers, then decide the game winner by turn parity.
Level

Medium5 of 10

Topics
Dynamic programming, Math, Game theory
Solved
No attempts yet

Problem

Holsoon and Jjaksoon play a number-making game. A set of N positive integers is given, and on each turn the current player must make the next positive integer: first 1, then 2, then 3, and so on. A number is made by choosing numbers from the given set and adding them together. The total number of chosen numbers used for one target may not exceed K, and numbers from the set may be reused.

For instance, if the usable numbers are 1 and 3 and K is 5, every target from 1 through 13 can be made, but 14 cannot. Because the players alternate turns and the failed target is 14, Jjaksoon is the player who cannot move, so Holsoon wins at 14.

Given the usable numbers and K, determine who wins and at which target number the game ends. The usable numbers always include 1. Although adding one more 1 to the previous construction may seem enough, the limit K makes that impossible once the construction already uses K numbers.

Input

The first line contains N, the number of usable integers. The second line contains the N usable integers in increasing order. The third line contains K, the maximum number of chosen integers allowed for one target.

Output

Print one line in the form holsoon win at X or jjaksoon win at X, where X is the first target number that the player to move cannot make.

Constraints

  • 1 <= N <= 1,000
  • 1 <= K <= 50
  • Every usable integer is a distinct positive integer not greater than 1,000.
  • The usable integers always include 1.

Examples1

  1. Example 1

    Input
    2
    1 3
    5
    
    Expected output
    holsoon win at 14