Lowest Unique

Rules

The game consists of R rounds. Each round each of the N players picks a number between 1 and M, inclusive, to "bid" on. After each player picks their number, the game server will determine the winner and broadcast the move to all players. The lowest unique number wins, and the player that picked it is awarded 1 point.

If there was no unique number picked, the number that was picked the least, but at least once, wins. The point is divided equally among players that picked the winning number, resulting in fractional points. Since each round exactly one total point is awarded, at the end of the game, the total score awarded to players will be R.

On the picture above, N=6, M=10, and after this move, players 1, 4, and 5 picked 2, player 3 picked 7, and won, player 6 picked 9, and player 2 picked 10.

I/O Protocol

  1. The program must output ready on a single line at startup.
  2. The program will receive start N p M R, where N is the number of players, p is the index of the player that this program is playing as (1 <= p <= N), M is the maximum number availabe to pick on each move, and R is the number of rounds.
  3. At the beginning of each move, the program will receive a yourmove command: the single word yourmove on a line.
  4. The program must output a line containing the single number mp (1 <= mp <= M), within 1 second of receiving the yourmove command.
  5. At the end of each move, the program will receive a move W m1 m2 ... mN line, which means that a move with winning number W has finished, and the player's moves were m1,m2,...,mN.
  6. The program should exit when its standard input is closed.
Example communication sequence for player 3 (the actual contents of stdin and stdout are without "read", "write" or leading spaces or "|" symbols):
  1. write | 
    ready
  2. read  | 
    start 6 3 10 500
  3. read  | 
    yourmove
  4. write | 
    7
  5. read  | 
    move 7 2 10 7 2 2 9
  6. read  | 
    yourmove
  7. ...