Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Queen's Dance

By Kryptonyte · Limits 1s, 512 MB

Alice and Bob love to play certain games where they can show their intellect. Recently they become curious about the game of chess. After playing the game for a while, they found that queen is one of the most important pieces. The move of a queen is a combination of a rook and a bishop’s move. A rook can only move horizontally and vertically, a bishop can move diagonally. From their new experience of chess games, they think queen is the strongest piece. But being intellectual, they will never consider queen as the strongest piece without any test.

Chess is usually played in an 8*8 board. But for testing purposes, they consider an infinite board where (0,0) is the origin and a queen can only move towards the origin from it’s position. So if the current position of the queen is (x,y) and a new valid position is (x’,y’) then x’≤ x and y’ ≤ y must be true. Also, x’ and y’ must be non-negative and a player must change the position of the chess piece after a turn.

Alice and Bob will start moving the chess piece. The winner is the one who moves the queen to the position (0,0).

Now, Alice will give the first move. Both of them will play optimally. You have to determine the winner of the game.


Input starts with an integer T (≤ 100), denoting the number of test cases. For each of the test case, there will be two integers X(0 ≤ X ≤ 106) and Y(0 ≤ Y ≤ 106).


For each of the test case, print Alice if Alice wins. Otherwise Print Bob.


0 0



66% Solution Ratio

ghazanfarEarliest, Jan '17

Bishal_GFastest, 0.0s

Bishal_GLightest, 131 kB

SUMbit_011Shortest, 438B


Login to submit

Related Contests

The Tough Winter Spar 2016 Ended at 2017-01-30 12:00:00 +0000 UTC