eolymp
bolt
Try our new interface for solving problems
Problems

Game on a Tree

Game on a Tree

Alice and Bob are playing a game on an undirected Tree. Alice plays first. In first move, Alice can mark any vertex of the tree. After first move, they will play alternatively and each player will choose a vertex which is adjacent to the LAST marked vertex and mark it. Note that a player cannot mark a vertex which was already marked in a previous move. If a player can not choose any vertex, he or she loses. Given that both players play optimally, can you find out who will win, even before the game begins. \InputFile First line contains \textbf{T}, the number of test cases. Then description of each test case follows. First line contains a number \textbf{N}, the number of vertices in a tree. The next \textbf{N}-\textbf{1} lines contains two space separated integers \textbf{a} \textbf{b} represents an undirected edge from \textbf{a} to \textbf{b}. (\textbf{1} ≤ \textbf{a}, \textbf{b} ≤ \textbf{N}). It is known that \textbf{T} ≤ \textbf{25}, \textbf{N} ≤ \textbf{50000}. \OutputFile Output \textbf{T} lines, each containing the answer for one test case. Output "\textbf{Alice}" if Alice wins the game, or "\textbf{Bob}" otherwise. \[quotes for clarity only\].
Time limit 1 second
Memory limit 256 MiB
Input example #1
2
2
1 2
3
1 2
1 3
Output example #1
Bob
Alice

Example description: Large input/output data, be careful with your input/output routines.

Author Ajay Somani
Source Sevastopol - 2010