CF2002B.Removals Game

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Removals Game

Alice got a permutation a1,a2,,ana_1, a_2, \ldots, a_n of [1,2,,n][1,2,\ldots,n], and Bob got another permutation b1,b2,,bnb_1, b_2, \ldots, b_n of [1,2,,n][1,2,\ldots,n]. They are going to play a game with these arrays.

In each turn, the following events happen in order:

  • Alice chooses either the first or the last element of her array and removes it from the array;
  • Bob chooses either the first or the last element of his array and removes it from the array.

The game continues for n1n-1 turns, after which both arrays will have exactly one remaining element: xx in the array aa and yy in the array bb.

If x=yx=y, Bob wins; otherwise, Alice wins. Find which player will win if both players play optimally.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041\le t\le10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n31051\le n\le 3\cdot 10^5).

The next line contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ain1\le a_i\le n, all aia_i are distinct) — the permutation of Alice.

The next line contains nn integers b1,b2,,bnb_1,b_2,\ldots,b_n (1bin1\le b_i\le n, all bib_i are distinct) — the permutation of Bob.

It is guaranteed that the sum of all nn does not exceed 31053\cdot 10^5.

Output

For each test case, print a single line with the name of the winner, assuming both players play optimally. If Alice wins, print Alice; otherwise, print Bob.

Note

In the first test case, Bob can win the game by deleting the same element as Alice did.

In the second test case, Alice can delete 33 in the first turn, and then in the second turn, delete the element that is different from the one Bob deleted in the first turn to win the game.

Samples

2
2
1 2
1 2
3
1 2 3
2 3 1
Bob
Alice

在线编程 IDE

建议全屏模式获得最佳体验