QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#4549. Alice and Bob are playing games again

統計

Alice and Bob are playing a game again.

There are $n$ nodes and $m$ edges ($0 \le m \le n-1$), forming a forest of rooted trees. The root of each tree is the node with the smallest index in its connected component.

Alice and Bob take turns (Alice goes first). In each turn, a player chooses a node $x$ that has not been deleted yet and deletes $x$ along with all of its ancestors. The player who cannot make a move loses.

Note that the structure of the trees is fixed from the beginning; deleting a node does not change the parent-child relationships of the remaining nodes.

For example, in a chain $1-3-2$ where $1$ is the root, if node $1$ is deleted, node $3$ remains the parent of node $2$.

Assuming both Alice and Bob play optimally, determine whether Alice has a winning strategy.

Input

The first line contains a positive integer $T$, representing the number of test cases. The following lines contain $T$ test cases.

For each test case:

The first line contains two integers $n$ and $m$, representing the number of nodes and edges respectively (nodes are numbered starting from $1$).

The next $m$ lines each contain two positive integers $a$ and $b$, representing an edge between node $a$ and node $b$. The input data contains no multiple edges.

Output

Output $T$ lines. Each line should state the winner, assuming Alice goes first and both players play optimally.

Examples

Input 1

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

Output 1

Alice
Alice
Bob
Alice

Note 1

There are 4 test cases in total.

In the first test case, the input is a chain, and Alice can delete all nodes in one turn.

In the second test case, Alice can win by deleting node $1$ on her first turn.

Constraints

For $10\%$ of the data, $m=0$.

For $20\%$ of the data, $1 \le n \le 20$.

For $40\%$ of the data, $1 \le n \le 10^2$.

For $60\%$ of the data, $1 \le n \le 10^3$.

For $100\%$ of the data, $1 \le T \le 10$, $1 \le n \le 10^5$, $\sum{n} \le 2 \times 10^5$, $0 \le m \le n-1$. The input data is guaranteed not to contain cycles, and the size of each tree is $\le 5 \times 10^4$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.