Snakes and Ladders

No attempts yetTime limit1sMemory limit128 MB

Problem

Simulate the board game Snakes and Ladders. The board has squares numbered from $1$ to $100$, and the piece starts on square $1$.

On each turn you roll a pair of dice and move the piece forward by the sum of the two dice. After the move, the following rules apply based on the square the piece lands on:

  • If the piece lands on the bottom of a ladder, it climbs up to the square at the top of the ladder.
  • If the piece lands on the head (top) of a snake, it slides down to the square at the tail (bottom) of the snake.

This board has $3$ ladders ($9 \to 34$, $40 \to 64$, $67 \to 86$) and $3$ snakes ($54 \to 19$, $90 \to 48$, $99 \to 77$). No ladder top or snake tail is itself the start of another ladder or snake, so moves never chain.

If advancing by the dice sum would move the piece past square $100$, the piece is not moved at all. The player wins when the piece lands exactly on the last square, $100$.

Input

The input consists of several lines, each containing one integer.

  • An integer between $2$ and $12$ inclusive is the sum of the two dice rolled this turn.
  • $0$ means the player quits the game.

The input ends when $0$ is given or when the piece reaches square $100$.

Output

For each turn, print the number of the square the piece ends up on, one per line, in the following format:

You are now on square N

Here $N$ is the number of the square where the piece is located after any ladder or snake is applied; if the piece could not advance and stayed in place, it is the current square number. When the piece reaches square $100$, print that line and then print You Win! and terminate the program. If the input is $0$, print You Quit! and terminate.