#P17092. [ICPC 2017 Qingdao R] Battle in Two Pairs of Heroes

[ICPC 2017 Qingdao R] Battle in Two Pairs of Heroes

Problem Description

In the game of Warcraft, Alice has two heroes A1 and A2, and Bob has two heroes B1 and B2. The health points of A1 and A2 (resp. B1 and B2) are a1a_1 and a2a_2 (resp. b1b_1 and b2b_2) respectively. The heroes with positive health points are surviving, and the heroes with zero or negative health points are dead. The goal of the game is to kill both of the opponent’s heroes.

Alice and Bob take turns to move. In Alice’s turn, if A1 (resp. A2) is surviving, then A1 (resp. A2) can decrease B1’s health points by a11a_{11} (resp. a21a_{21}), or decrease B2’s health points by a12a_{12} (resp. a22a_{22}). If both A1 and A2 are surviving, then there are 4 possible actions in Alice’s turn:

  • Decrease B1’s health points by a11+a21a_{11} + a_{21};
  • Decrease B2’s health points by a12+a22a_{12} + a_{22};
  • Decrease B1’s health points by a11a_{11} and decrease B2’s health points by a22a_{22};
  • Decrease B1’s health points by a21a_{21} and decrease B2’s health points by a12a_{12}.

Similarly, in Bob’s turn, if B1 (resp. B2) is surviving, then B1 (resp. B2) can decrease A1’s health points by b11b_{11} (resp. b21b_{21}), or decrease A2’s health points by b12b_{12} (resp. b22b_{22}). If both B1 and B2 are surviving, then there are 4 possible actions in Bob’s turn:

  • Decrease A1’s health points by b11+b21b_{11} + b_{21};
  • Decrease A2’s health points by b12+b22b_{12} + b_{22};
  • Decrease A1’s health points by b11b_{11} and decrease A2’s health points by b22b_{22};
  • Decrease A1’s health points by b21b_{21} and decrease A2’s health points by b12b_{12}.

Both player play optimally. Your task is to find out the winner of the game.

Input Format

The first line is the number of test cases up to 40. For each test case, there is a line containing 12 integers a1a_1, a2a_2, b1b_1, b2b_2, a11a_{11}, a12a_{12}, a21a_{21}, a22a_{22}, b11b_{11}, b12b_{12}, b21b_{21} and b22b_{22}. All the integers are positive and less than 100.

Output Format

For each test case, if Alice has a winning strategy even if Bob moves first, then output “Alice wins”; if Bob has a winning strategy even if Alice moves first, then output “Bob wins”; if the player who moves first has a winning strategy, then output “It depends”.

3
3 3 3 8 1 2 2 1 2 1 1 2
4 10 10 4 1 2 2 1 2 1 1 2
5 12 12 5 2 1 1 2 1 2 2 1
It depends
Alice wins
Bob wins