#P10029. 「Cfz Round 3」Battle

    ID: 11179 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>模拟数学洛谷原创O2优化洛谷月赛

「Cfz Round 3」Battle

Problem Description

Alice and Bob are playing a game with the following rules:

  • Alice initially has an integer nn, and Bob initially has an integer mm.
  • Starting from Alice, the two players take turns operating on the integer owned by the other player. Let the integer currently owned by the other player be hh. Change hh by subtracting hmodph \bmod p from it, where mod\bmod denotes the modulo operation, and pp is a given constant.
  • The first player who makes the other player's integer become 00 wins. If no one wins after each of them has made 1010996110^{10^{9961}} moves, the game is considered a draw.

You need to determine who will win, or report that the game will end in a draw.

Input Format

This problem has multiple test cases.

The first line contains an integer TT, representing the number of test cases.

Then follow the test cases. For each test case, three integers n,m,pn, m, p are given.

Output Format

For each test case, output one string per line as the answer:

  • If Alice will win, output Alice.
  • If Bob will win, output Bob.
  • If the game will be a draw, output Lasting Battle.
3
1 2 10
9 11 11
55 15 14
Alice
Bob
Lasting Battle

Hint

"Sample Explanation #1"

For the 11st test case, in her first move, Alice changes Bob's integer from 22 to 2(2mod10)2-(2\bmod 10), which is 00, so Alice will win.

For the 22nd test case, in her first move, Alice changes Bob's integer from 1111 to 11(11mod11)11-(11\bmod 11), which is 1111. In Bob's first move, he changes Alice's integer from 99 to 9(9mod11)9-(9 \bmod 11), which is 00, so Bob will win.

For the 33rd test case, it can be proven that the game will be a draw.

"Constraints"

For all testdata, 1T50001 \leq T \leq 5000, 1n,m,p2×1091 \leq n, m, p \leq 2\times 10^9.

Only if you pass all test points of this problem can you get the score for this problem.

Translated by ChatGPT 5