Bot Game
Practice
4 (4 votes)
Easy
Problem
91% Success 1229 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Mavis and Shivam are playing with their Bot. They randomly placed the Bot in a grid of size, (n, m).

Mavis always plays first move, and then Shivam plays his move in alternating turns. Mavis can control movement of bot, on his turn, and can move the Bot one step in any of the four directions if there is no wall between the positions.

i.e if Bot is at (i, j) then he can move it to any of the four positions, (i, j-1) or (i, j+1) or (i-1, j) or (i+1, j) if there is no wall between them. If Bot is present at the border of the grid, then it can be moved out of the grid (only if there is no wall) and Mavis wins the game.

After Mavis' turn, Shivam selects a border between two positions and block the movement of Bot through that wall. Shivam wins the game if he can successfully block the Bot in the grid.

enter image description here

Consider the above example of an instant, where B represent the Bot at (2, 3) and the Bold line represents the blocking wall between (2, 3) and (2, 4). Thus, Bot can move to (1, 3) or to (2, 2) or to (3, 3), but not to (2, 4) because of the wall.

Both the friends are best in their moves and play optimally, throughout the game. Now, you are given the size of the grid, (n, m) and the initial position of the Bot, (x, y), determine the winner of the game.

Input:

The first line contains an integer, g, denoting the number of games played between them. Each game is described in a line.
The first and the only line of each test case contain four space-separated integers: n, m, x and y, as described in the statement.

Output:

For each test case print the name of the winner in a single line.

Constraints:

1 ≤ g ≤ 1000
1 ≤ n,m ≤ 106
1 ≤ xn
1 ≤ ym

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
18 votes
Tags:
Ad-HocBasic ProgrammingOpenApprovedEasyMathamatics
Points:20
2 votes
Tags:
ImplementationEasySimple-math
Points:20
11 votes
Tags:
Basic ProgrammingOpenApprovedEasyHash functionMathamatics