QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 64 MB Total points: 100 Hackable ✓

#6789. Yet Another Game of Stones

Statistics

Alice and Bob are playing yet another game of stones. The rules of this game are as follow:

  • The game starts with $n$ piles of stones indexed from $1$ to $n$. The $i$-th pile contains $a_i$ stones and a special constraint indicated as $b_i$.

  • The players make their moves alternatively. The allowable moves for the two players are different.

  • An allowable move of Bob is considered as removal of some positive number of stones from a pile.

  • An allowable move of Alice is also considered as removal of some positive number of stones from a pile, but is limited by the constraint $b_i$ of that pile.

    • If $b_i = 0$, there are no constraints.

    • If $b_i = 1$, Alice can only remove some odd number of stones from that pile.

    • If $b_i = 2$, Alice can only remove some even number of stones from that pile.

    Please note that there are no constraints on Bob.

  • The player who is unable to make an allowable move loses.

Alice is always the first to make a move. Do you know who will win the game if they both play optimally?

Input

There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first line contains an integer $n$ ($1 \le n \le 10^5$), indicating the number of piles.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$), indicating the number of stones in each pile.

The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($0 \le b_i \le 2$), indicating the special constraint of each pile.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$.

We kindly remind you that this problem contains large I/O file, so it’s recommended to use a faster I/O method. For example, you can use scanf/printf instead of cin/cout in C++.

Output

For each test case, output “Alice” (without the quotes) if Alice will win the game. Otherwise, output “Bob” (without the quotes).

Examples

Input 1

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

Output 1

Alice
Bob
Bob

Note

For the first test case, Alice can remove 3 stones from the first pile, and then she will win the game.

For the second test case, as Alice can only remove some even number of stones, she is unable to remove all the stones in the first move. So Bob can remove all the remaining stones in his move and win the game.

For the third test case, Alice is unable to remove any number of stones at the beginning of the game, so Bob wins.

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.