题目收集
题目列表题单
返回列表

Big Tree Reversing Game

CodeforcesP0032· 3000ms· 1024 MB· ZJU Summer 2026 Contest 3原题链接
博弈论

创建于 2026/07/16 · 更新于 2026/07/16

题目描述

You are given a tree with nnn vertices. Each edge has an initial direction. There is a token initially placed on vertex 111.

There is also a set TTT of terminal vertices.

Two players, Alice and Bob, play alternately. Alice moves first.

In one turn, the current player performs the following two operations:

  1. choose an edge incident to the vertex containing the token and reverse its direction;
  2. choose a directed path starting from the current vertex of the token, such that the endpoint of this path is a vertex whose incident edges are all directed towards it, and then move the token to the endpoint of this path.

If, after both operations of a player's turn are completed, the token is on a vertex in TTT, the game ends.

Alice wants the game to end. Bob wants the game to never end.

Assuming both players play optimally, determine whether Alice can force the game to end from the initial position.

It is guaranteed that every edge incident to vertex 111 is initially directed towards vertex 111 and 1∉T1 \notin T1∈/T.

输入格式

The input contains multiple test cases.

The first line contains an integer ttt (1≤t≤1061 \le t \le 10^61≤t≤106), the number of test cases.

For each test case, the first line contains an integer nnn (2≤n≤1062 \le n \le 10^62≤n≤106).

The second line contains an integer kkk (1≤k≤n−11 \le k \le n-11≤k≤n−1), the number of terminal vertices.

The third line contains kkk distinct integers a1,a2,…,aka_1,a_2,\ldots,a_ka1​,a2​,…,ak​ (2≤ai≤n2 \le a_i \le n2≤ai​≤n). These vertices form the terminal set T={a1,a2,…,ak}T=\{a_1,a_2,\ldots,a_k\}T={a1​,a2​,…,ak​}.

Each of the next n−1n-1n−1 lines contains two integers u,vu,vu,v (1≤u,v≤n1 \le u,v \le n1≤u,v≤n, u≠vu \ne vu=v), describing an edge initially directed from uuu to vvv.

The sum of nnn over all test cases does not exceed 10610^6106.

输出格式

For each test case, print one line.

If Alice can force the game to end from the initial position, print Alice. Otherwise, print Bob.

样例输入 #1

4
2
1
2
2 1
3
1
3
2 1
3 2
3
1
2
2 1
2 3
4
1
4
2 1
3 2
3 4

样例输出 #1

Alice
Bob
Alice
Bob