#arc162c. [arc162_c]Mex Game on Tree
[arc162_c]Mex Game on Tree
Problem Statement
You are given a rooted tree with vertices numbered to . Vertex is the root, and the parent of vertex is .
Some vertices of the rooted tree have non-negative integers from to written on them. This information is given by the sequence . If , vertex has the integer written on it; if , vertex does not have an integer written on it.
Alice and Bob play a game. Alice goes first, and they take turns performing the following operation until all vertices have an integer written on them.
- Choose one vertex without an integer written on it and write a non-negative integer between and on it.
After the operations, for each vertex , let be the smallest non-negative integer not written on any vertex (including ) in the subtree rooted at vertex .
If there is a vertex such that , Alice wins. Otherwise, Bob wins. Determine the winner when both players play optimally.
There are test cases. Answer each of them.
Constraints
- All input values are integers.
- The sum of over all test cases in a single input is at most .
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
Output
Print lines. The -th line should contain Alice
if Alice wins, and Bob
if Bob wins when both players play optimally in the -th test case.
Sample Input 1
2
4 2
1 1 2
-1 -1 3 1
6 4
1 2 2 1 3
-1 -1 -1 -1 -1 -1
Sample Output 1
Alice
Bob
In the first test case, if Alice writes on vertex , then regardless of Bob's operation. Therefore, Alice can win.
In the second test case, Bob can ensure that there will be no vertex with by choosing the right integer to write.