Multiplication Game

Interview

Time limit1sMemory limit128 MB

Summary
Alice and Bob multiply a running product by 2 to 9 in turn; find who forces the product to reach n first with optimal play.
Level

Medium5 of 10

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

Problem

Alice and Bob play a multiplication game. An integer pp starts at 11, and beforehand a fixed integer nn with 1<n<42949672951 < n < 4294967295 is chosen.

On each turn, the player to move multiplies pp by one integer between 22 and 99 inclusive. Alice moves first, then Bob, and they keep alternating turns.

The player who first makes p≥np \ge n wins.

Assuming both players play optimally, write a program that determines the winner.

Input

The input consists of several test cases. Each test case is a single line containing the integer nn. Process every test case until the end of input.

Output

For each test case, print Alice wins. if Alice wins, or Bob wins. if Bob wins, one per line.

Examples3

  1. Example 1

    Input
    162
    17
    34012226
    
    Expected output
    Alice wins.
    Bob wins.
    Alice wins.
    
  2. Example 2

    Input
    2
    9
    10
    18
    19
    
    Expected output
    Alice wins.
    Alice wins.
    Bob wins.
    Bob wins.
    Alice wins.
    
  3. Example 3

    Input
    162
    163
    324
    325
    
    Expected output
    Alice wins.
    Bob wins.
    Bob wins.
    Alice wins.