Practice on Toph

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


By curly_braces · Limits 1s, 512 MB

Alice and Bob are playing GoG. GoG is a two-player board game. It consists of a grid with nn rows and mm columns. Players take alternate moves. In each move, a player can move in four directions(Up, Down, Left, and Right). If a player goes out of the grid or goes to a cell that has already been visited by any player (Alice or Bob), then the player dies. The last person alive wins.

Alice starts at the top-left cell and Bob starts at the bottom-right cell. Can you determine the winner, considering both players play optimally and Alice goes first?


The first line of the input will contain a single integer T(1T100)T (1 \leq T \leq 100), the number of test cases.

The next TT lines each will contain the two integers nn and m(1n,m105;2n×m105)m (1 \leq n, m \leq 10^5; 2 \leq n \times m \leq 10^5), the dimensions of the grid for that testcase.


For each testcase, print the name of the winner in a new line.


1 3
2 2



99% Solution Ratio

Siddik_53rdEarliest, 6M ago

habijabiFastest, 0.0s

habijabiLightest, 0 B

silenced.VOICEShortest, 114B


Login to submit


We claim that if there are even number of cells then Bob wins, and if there are odd number of cells ...

Toph uses cookies. By continuing you agree to our Cookie Policy.