CodechefJun 12, 2025

It is My Serve

Hazrat Ali

Codechef

Alice and Bob are playing a game of table tennis where irrespective of the point scored, every player makes 22 consecutive serves before the service changes. Alice makes the first serve of the match. Therefore the first 22 serves will be made by Alice, then the next 22 serves will be made by Bob and so on.

Let's consider the following example match for more clarity:

  • Alice makes the 1st1st serve.
  • Let us assume, Bob wins this point. (Score is 00 for Alice and 11 for Bob)
  • Alice makes the 2nd2nd serve.
  • Let us assume, Alice wins this point. (Score is 11 for Alice and 11 for Bob)
  • Bob makes the 3rd3rd serve.
  • Let us assume, Alice wins this point. (Score is 22 for Alice and 11 for Bob)
  • Bob makes the 4th4th serve.
  • Let us assume, Alice wins this point. (Score is 33 for Alice and 11 for Bob)
  • Alice makes the 5th5th serve.
  • And the game continues 

After the score reaches PP and QQ for Alice and Bob respectively, both the players forgot whose serve it is. Help them determine whose service it is.

Input Format

  • The first line contains a single integer TT — the number of test cases. Then the test cases follow.
  • The first line of each test case contains two integers PP and QQ — the score of Alice and Bob respectively.

Output Format

For each test case, determine which player's (Alice or Bob) serve it is.

You may print each character of Alice and Bob in uppercase or lowercase (for example, BobBOBboB will be considered identical).

Constraints

  • 1≤T≤200
  • 0≤P,Q≤10

Sample 1:

Input
4
0 0
0 2
2 2
4 7

Output
Alice
Bob
Alice
Bob


Solution

def table_tennis(a, b):
    temp = a + b
    turn = (temp // 2) % 2
    return "Alice" if turn == 0 else "Bob"

def main():
    t = int(input())
    for _ in range(t):
        a, b = map(int, input().split())
        print(table_tennis(a, b))

# call the function
main()





 

Comments