Alice and Bob play the following game:

They choose a permutation of the numbers $1$ to $n$.  
Alice plays first and they alternate.  
In a turn, they can remove any one remaining number from the permutation.  
The game ends when the remaining numbers form an increasing sequence of $1$ or more numbers. The person who played the turn that leaves an increasing sequence wins the game.  

Assuming both play optimally, who wins the game? Return Alice or Bob.   

Example 
$arr=[4,2,3,1]$   

This is the starting permutation to analyze, $n=4$.  First, Alice chooses $3$ or $2$. For the example, Alice chooses $3$ and leaves $arr'=[4,2,1]$.  Since this is a decreasing sequence, Bob can remove any number for optimum play.  He will lose regardless.  Alice then removes any number leaving an array of only one element.  Since Alice removed the last element to create an increasing sequence, Alice wins. 

Function Description  

Complete the permutationGame function in the editor below.  

permutationGame has the following parameter: 

- int arr[n]: the starting permutation  

Returns   

string:  either Alice or Bob  

Input Format

The first line contains the number of test cases $t$.  

Each of the next $t$ pairs of lines is in the following format: 

- The first line contains an integer $n$, the size of the array $arr$ 

- The second line contains $n$ space-separated integers, $arr[i]$ where $0\leq i<n$      

Constraints

$1\le t\le100$
$2\le n\le15$  
The permutation will not be an increasing sequence initially.

Sample Input
STDIN       Function
-----       --------
2           t = 2
3           arr[] size n = 3
1 3 2       arr = [1, 3, 2]
5           n = 5
5 3 2 1 4   arr = [5, 3, 2, 1, 4]

Sample Output
Alice
Bob

Explanation

For the first test, Alice can remove $3$ or $2$ to leave an increasing sequence and win the game.    

For the second test, if $4$ is removed then the only way to have an increasing sequence is to only have $1$ number left.  This takes a total of $4$ moves, and Bob wins. 

If Alice removes the $4$ on the first move, it will take $3$ more moves to create an increasing sequence. Bob wins. 
If Alice removes something else, Bob can remove $4$ on his next turn to create the same game state.  It is a decreasing sequence with $3$ numbers left.

Difficulty: MEDIUM
Tags: Game theory

Starter code:

Solutions:
def has_won(arr):
	prev = float('-inf')
	for el in arr:
		if el < prev:
			return False
		prev = el
	return True

def can_win(arr, cache):
	if arr in cache:
		return cache[arr]
	if has_won(arr):
		return False
	for i in range(len(arr)):
		new_arr = arr[:i] + arr[i + 1:]
		if not can_win(new_arr, cache):
			cache[arr] = True
			return True
	cache[arr] = False
	return False
for _ in range(int(input())):
	input()
	arr = tuple((int(s) for s in input().split()))
	if has_won(arr) or can_win(arr, {}):
		print('Alice')
	else:
		print('Bob')


def main():
	ncases = int(input())
	for _ in range(ncases):
		length = int(input())
		perm = [int(fld) for fld in input().split()]
		assert len(perm) == length
		firstwins = cachedfirstwins()
		print('Alice' if firstwins(perm) else 'Bob')

def cachedfirstwins():
	cache = {}

	def firstwins(perm):
		key = tuple(perm)
		ans = cache.get(key, None)
		if ans is not None:
			return ans
		if all((a < b for (a, b) in zip(perm[:-1], perm[1:]))):
			return False
		for i in range(len(perm)):
			if not firstwins(perm[:i] + perm[i + 1:]):
				cache[key] = True
				return True
		cache[key] = False
		return False
	return firstwins
main()


T = int(input())
table = {}

def ascending(numbers):
	for i in range(1, len(numbers)):
		if numbers[i] < numbers[i - 1]:
			return False
	return True

def winner(numbers):
	if len(numbers) == 1:
		return 'P'
	if ascending(numbers):
		table[tuple(numbers)] = 'P'
		return 'P'
	if tuple(numbers) in table:
		return table[tuple(numbers)]
	for i in range(len(numbers)):
		if winner(numbers[:i] + numbers[i + 1:]) == 'P':
			table[tuple(numbers)] = 'N'
			return 'N'
	table[tuple(numbers)] = 'P'
	return 'P'
for _ in range(T):
	table = {}
	n = int(input())
	numbers = [int(number) for number in input().split()]
	w = winner(numbers)
	print('Alice' if w == 'N' else 'Bob')


T = int(input())
for _ in range(T):
	N = int(input())
	ar = [int(i) for i in input().split()]
	cache = [-1 for _ in range(2 ** N)]
	cache[0] = 1

	def is_increasing(combo):
		prev = 0
		for i in range(N):
			if combo & 1 << i != 0:
				if ar[i] <= prev:
					return False
				prev = ar[i]
		return True

	def can_win(combo):
		if cache[combo] >= 0:
			return bool(cache[combo])
		for i in range(N):
			if combo & 1 << i != 0:
				subcombo = combo ^ 1 << i
				if is_increasing(subcombo) or not can_win(subcombo):
					cache[combo] = 1
					return True
		cache[combo] = 0
		return False
	print('Alice' if can_win(2 ** N - 1) else 'Bob')


import sys

def memoize(function):
	cache = dict()

	def memoized_function(*args):
		if args in cache:
			return cache[args]
		else:
			result = function(*args)
			cache[args] = result
			return result
	return memoized_function

@memoize
def is_increasing(xs):
	if not xs:
		return True
	x0 = xs[0]
	for x in xs:
		if x < x0:
			return False
		x0 = x
	return True

@memoize
def is_winning_position(xs):
	if is_increasing(xs):
		return False
	return not all([is_winning_position(xs[:i] + xs[i + 1:]) for (i, _x) in enumerate(xs)])
T = int(sys.stdin.readline())
for case in range(T):
	_N = int(sys.stdin.readline())
	xs = tuple([int(X) for X in sys.stdin.readline().split()])
	print('Alice' if is_winning_position(xs) else 'Bob')


import sys
status = {}

def init():
	global status
	status = {}

def isInOrder(nums):
	temp = list(map(int, nums))
	return temp == sorted(temp)

def getKey(nums):
	return ','.join(nums)

def canWin(nums):
	global status
	key = getKey(nums)
	if key in status:
		return status[key]
	win = False
	if not isInOrder(nums):
		for i in range(len(nums)):
			r = canWin(nums[:i] + nums[i + 1:])
			if not r:
				win = True
				break
	status[key] = win
	return win
k = sys.stdin.readline()
k = int(k)
while k > 0:
	k = k - 1
	n = sys.stdin.readline()
	n = int(n)
	nums = sys.stdin.readline().split()
	init()
	if canWin(nums):
		print('Alice')
	else:
		print('Bob')


import functools
test_cases = int(input())

def is_in_order(game):
	game_size = len(game)
	if game_size == 1:
		return True
	for i in range(game_size - 1):
		if int(game[i], 16) > int(game[i + 1], 16):
			return False
	return True

@functools.lru_cache(maxsize=None)
def get_winner_sing(game):
	game
	if is_in_order(game):
		return True
	else:
		return not get_winner([game[:x] + game[x + 1:] for x in range(len(game))])

def get_winner(game):
	if len(game) == 1:
		return get_winner_sing(game[0])
	else:
		for i in range(len(game)):
			if get_winner([game[i]]):
				return True
		return False

def convert_to_hex(num):
	num = int(num)
	if num == 15:
		return 'f'
	elif num == 14:
		return 'e'
	elif num == 13:
		return 'd'
	elif num == 12:
		return 'c'
	elif num == 11:
		return 'b'
	elif num == 10:
		return 'a'
	else:
		return str(num)
for i in range(test_cases):
	game_size = int(input())
	string = ''
	raw_game = input().split()
	for x in range(len(raw_game)):
		string += convert_to_hex(raw_game[x])
	game = [string]
	bob_winner = get_winner(game)
	if bob_winner:
		print('Bob')
	else:
		print('Alice')


seq_to_win_dict = dict()

def is_increasing(A):
	for i in range(0, len(A) - 1, 1):
		if A[i] > A[i + 1]:
			return False
	return True

def win(A):
	if is_increasing(A):
		return False
	if tuple(A) in seq_to_win_dict:
		return seq_to_win_dict[tuple(A)]
	for i in range(len(A)):
		A2 = A[0:i] + A[i + 1:len(A)]
		if not win(A2):
			seq_to_win_dict[tuple(A)] = True
			return True
	seq_to_win_dict[tuple(A)] = False
	return False
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	res = win(A)
	print('Alice' if res else 'Bob')


table = {}

def sol(a, depth):
	if (a, depth) not in table:
		res = 0
		if all((a[k] < a[k + 1] for k in range(len(a) - 1))):
			res = depth % 2
		elif depth % 2 == 0:
			res = 0
			for k in range(len(a)):
				res = sol(a[:k] + a[k + 1:], depth + 1)
				if res:
					break
		else:
			res = 1
			for k in range(len(a)):
				res = sol(a[:k] + a[k + 1:], depth + 1)
				if not res:
					break
		table[a, depth] = res
	return table[a, depth]
t = int(input())
for test in range(t):
	n = int(input())
	a = tuple(map(int, input().split()))
	table = {}
	print('Alice' if sol(a, 0) else 'Bob')


memory = {}

def memoized(func):

	def memo(seq):
		if seq not in memory:
			memory[seq] = func(seq)
		return memory[seq]
	return memo

def inSequence(seq):
	prev = -1
	for item in seq:
		if item < prev:
			return False
		prev = item
	return True

def skip(seq, n):
	for i in seq:
		if i != n:
			yield i

def moves(seq):
	for i in seq:
		yield tuple(skip(seq, i))

@memoized
def positionResult(seq):
	if len(seq) <= 1:
		return False
	if inSequence(seq):
		return False
	for move in moves(seq):
		if not positionResult(move):
			return True
	return False
T = int(input())
for Ti in range(T):
	N = int(input())
	A = tuple((int(i) for i in input().split()))
	if positionResult(A):
		print('Alice')
	else:
		print('Bob')


from itertools import combinations

def WhoWins(N, iTup):
	DPDict = {(i,): 0 for i in range(1, N + 1)}
	for cn in range(2, N + 1):
		for comb in combinations(iTup, cn):
			combState = 2
			for e in range(cn):
				subs = comb[:e] + comb[e + 1:]
				subsState = DPDict[subs]
				potState = subsState
				if subsState == 0:
					if e == 0:
						potState = 0 if comb[0] < comb[1] else 1
					elif e == cn - 1:
						potState = 0 if comb[cn - 1] > comb[cn - 2] else 1
					else:
						potState = 0 if comb[e - 1] < comb[e] < comb[e + 1] else 1
				elif subsState == 1:
					potState = 2
				else:
					potState = 1
				combState = potState if potState < combState else combState
			DPDict[comb] = combState
	print('Alice' if DPDict[iTup] <= 1 else 'Bob')
T = int(input())
for _ in range(T):
	N = int(input())
	iTup = tuple(map(int, input().split()))
	WhoWins(N, iTup)


from copy import deepcopy
from collections import defaultdict
T = int(input().strip())

def check_list(lst):
	global sort_memo
	list_is_sorted = True
	if len(lst) == 1:
		sort_memo[tuple(lst)] = True
		return True
	for i in range(1, len(lst)):
		if lst[i - 1] > lst[i]:
			sort_memo[tuple(lst)] = False
			return not list_is_sorted
	sort_memo[tuple(lst)] = True
	return list_is_sorted
memo = defaultdict(str)
sort_memo = defaultdict(bool)

def recursive_func(lst, turn='A', top_level=True):
	global memo
	global sort_memo
	if top_level:
		memo = defaultdict(str)
		sort_memo = defaultdict(bool)
	if tuple(lst) in memo:
		return memo[tuple(lst)]
	if tuple(lst) in sort_memo:
		check = sort_memo[tuple(lst)]
	else:
		check = check_list(lst)
	if check:
		if turn is 'B':
			result = 'A'
		else:
			result = 'B'
		memo[tuple(lst)] = result
		return 'A' if turn is 'B' else 'B'
	wins = 0
	for i in range(len(lst)):
		new_lst = deepcopy(lst)
		new_lst.pop(i)
		if turn == 'A':
			res = recursive_func(new_lst, turn='B', top_level=False)
		else:
			res = recursive_func(new_lst, turn='A', top_level=False)
		if res == turn:
			memo[tuple(lst)] = turn
			return turn
	if wins == 0:
		if turn is 'B':
			result = 'A'
		else:
			result = 'B'
		memo[tuple(lst)] = result
		return 'A' if turn is 'B' else 'B'
for _ in range(T):
	N = int(input().strip())
	perm = list(map(int, input().strip().split()))
	result = recursive_func(perm)
	if result == 'A':
		print('Alice')
	else:
		print('Bob')


def is_inc(_list):
	for i in range(1, len(_list)):
		if _list[i] < _list[i - 1]:
			return False
	return True

def exclude(_list, i):
	if i < len(_list) - 1:
		return _list[:i] + _list[i + 1:]
	return _list[:i]

def minimax(perm, games):
	h = hash(tuple(perm))
	if h in games:
		return True
	for i in range(len(perm)):
		new_perm = exclude(perm, i)
		if is_inc(new_perm):
			games[h] = True
			return True
		if not minimax(new_perm, games):
			games[h] = True
			return True
	return False
t = int(input())
games = {}
for i in range(t):
	n = int(input())
	perm = list(map(lambda x: int(x), input().split()))
	if minimax(perm, games):
		print('Alice')
	else:
		print('Bob')


def isSorted(a):
	prev = a[0]
	for n in a:
		if prev > n:
			return False
		prev = n
	return True

def memoize(f):
	m = {}

	def w(a):
		sa = repr(a)
		if sa in m:
			return m[sa]
		m[sa] = f(a)
		return m[sa]
	return w

@memoize
def win(a):
	if len(a) == 2:
		return a[0] > a[1]
	for item in a:
		newa = a[:]
		newa.remove(item)
		if isSorted(newa):
			return True
		if not win(newa):
			return True
	return False

def printWinner(a):
	if win(a):
		print('Alice')
	else:
		print('Bob')
numTestCases = int(input().strip())
for i in range(numTestCases):
	n = int(input().strip())
	a = [int(t) for t in input().strip().split(' ')]
	printWinner(a)


memo = {}

def is_end(numbers: list):
	if len(numbers) == 1:
		return True
	for i in range(1, len(numbers)):
		if numbers[i - 1] > numbers[i]:
			return False
	return True

def can_win(numbers: list):
	if is_end(numbers):
		return False
	tuple_numbers = tuple(numbers)
	if tuple_numbers in memo:
		return memo[tuple_numbers]
	for i in range(len(numbers)):
		temp = numbers.copy()
		temp.pop(i)
		if not can_win(temp):
			memo[tuple_numbers] = True
			return True
	memo[tuple_numbers] = False
	return False

def solve(numbers: list):
	if can_win(numbers):
		return 'Alice'
	else:
		return 'Bob'

def main():
	t = int(input())
	for _ in range(t):
		n = input()
		numbers = list(map(int, input().split()))
		print(solve(numbers))
main()


def next_steps(N, mask):
	p = 1
	for _ in range(N):
		if mask & p == p:
			yield (mask ^ p)
		p *= 2

def is_increasing(N, permutation, mask):
	m = bin(mask)[2:].zfill(N)
	indexes = [i for i in range(N) if m[i] != '0']
	for i in range(1, len(indexes)):
		if permutation[indexes[i]] < permutation[indexes[i - 1]]:
			return False
	return True

def is_loosing(N, permutation, mask, positions):
	if positions[mask] is not None:
		return positions[mask]
	if is_increasing(N, permutation, mask):
		positions[mask] = True
		return True
	else:
		temp = not any((is_loosing(N, permutation, new_mask, positions) for new_mask in next_steps(N, mask)))
		positions[mask] = temp
		return temp
T = int(input())
for _ in range(T):
	N = int(input())
	permutation = tuple((int(x) for x in input().split()))
	mask = 2 ** N - 1
	positions = [None] * (mask + 1)
	if is_loosing(N, permutation, mask, positions):
		print('Bob')
	else:
		print('Alice')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	w = [-1] * (1 << n)

	def f(state):
		if w[state] == -1:
			w[state] = 0
			inc = True
			prev = 0
			for i in range(n):
				if state & 1 << i == 0:
					if p[i] < prev:
						inc = False
						break
					prev = p[i]
			if inc:
				return 0
			for i in range(n):
				if state & 1 << i == 0:
					if f(state | 1 << i) == 0:
						w[state] = 1
						return 1
		return w[state]
	print(['Bob', 'Alice'][f(0)])


import itertools

def get_basis(n):
	if n == 1:
		return [{(1,): False}]
	else:
		b = get_basis(n - 1)
		last = b[-1]
		this_b = dict()
		first = True
		for p in itertools.permutations([i for i in range(1, n + 1)]):
			if first:
				this_b[p] = False
				first = False
				continue
			winning = False
			for i in range(n):
				n_list = p[:i] + p[i + 1:] if i < n - 1 else p[:i]
				n_list = [x - 1 if x > p[i] else x for x in n_list]
				n_tuple = tuple(n_list)
				if not last[n_tuple]:
					winning = True
					break
			this_b[p] = winning
		return b + [this_b]

def get_winning(arr, base, base_len):
	if len(arr) <= base_len:
		return base[len(arr) - 1][tuple(arr)]
	inc = True
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			inc = False
			break
	if inc:
		return False
	for i in range(len(arr)):
		n_list = arr[:i] + arr[i + 1:] if i < n - 1 else arr[:i]
		n_list = [x - 1 if x > arr[i] else x for x in n_list]
		if not get_winning(n_list, base, base_len):
			return True
	return False
base = get_basis(8)
base_len = 8
for _ in range(int(input().strip())):
	n = int(input().strip())
	t = tuple([int(x) for x in input().strip().split()])
	if n < base_len and base[n - 1][t] or get_winning(t, base, base_len):
		print('Alice')
	else:
		print('Bob')


dic = {}
for i in range(1, 16):
	dic[str(i)] = 0

def check_ans(nums):
	if len(nums) == 1:
		return 0
	if str(nums) in dic:
		return dic[str(nums)]
	if str(sorted(nums)) == str(nums):
		dic[str(sorted(nums))] = 0
		return 0
	for i in range(len(nums)):
		if check_ans(list(nums[:i] + nums[i + 1:])) == 0:
			dic[str(nums)] = 1
			return 1
	dic[str(nums)] = 0
	return 0
T = int(input())
for _ in range(T):
	N = int(input())
	nums = list(map(int, input().split()))
	if check_ans(nums) == 1:
		print('Alice')
	else:
		print('Bob')


T = int(input().strip())

def i_won(P, cache={}):
	if str(P) in cache:
		winner = cache[str(P)]
	else:
		winner = False
		j = P[0]
		lost_already = True
		for i in P:
			if i < j:
				lost_already = False
				break
			j = i
		if not lost_already:
			for i in range(len(P)):
				L = list(P)
				del L[i]
				Pi = tuple(L)
				winner_i = i_won(Pi)
				if not winner_i:
					winner = True
					break
		cache[str(P)] = winner
	return winner
for t in range(T):
	N = int(input().strip())
	P = tuple([int(x) for x in input().strip().split(' ')])
	if i_won(P):
		print('Alice')
	else:
		print('Bob')


def mex(s):
	i = 0
	while i in s:
		i += 1
	return i

def is_increasing(bit):
	b = bin(bit)[2:]
	seq = [l[i] for i in range(n) if i < len(b) and b[-(i + 1)] == '1']
	for i in range(len(seq) - 1):
		if seq[i + 1] < seq[i]:
			return False
	return True

def calc_gnum(bit):
	if dp[bit] != -1:
		return dp[bit]
	if is_increasing(bit):
		dp[bit] = 0
		return dp[bit]
	glist = []
	b = bin(bit)[2:][::-1]
	for i in range(len(b)):
		if b[i] == '1':
			glist.append(i)
	g = mex((calc_gnum(bit ^ 1 << i) for i in glist))
	dp[bit] = g
	return dp[bit]
t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	dp = [-1] * pow(2, n)
	ans = calc_gnum(pow(2, n) - 1)
	if ans == 0:
		print('Bob')
	else:
		print('Alice')


hist = {}

def game(p):
	n = len(p)
	if n == 1:
		return 0
	q = tuple(p)
	if q in hist:
		return hist[q]
	t = True
	for i in range(n - 1):
		if p[i] > p[i + 1]:
			t = False
			break
	if t:
		hist[q] = 0
		return 0
	rv = 0
	for i in range(n):
		sub = p[:i] + p[i + 1:]
		if game(sub) == 0:
			rv = 1
	hist[q] = rv
	return rv
num_probs = int(input())
for prob in range(num_probs):
	n = int(input())
	p = [int(x) for x in input().split()]
	if game(p) == 0:
		print('Bob')
	else:
		print('Alice')


import sys

def isincrease(A):
	for i in range(0, len(A)):
		if i != len(A) - 1:
			if A[i] > A[i + 1]:
				return 0
	return 1
dic = {}

def call(A):
	if isincrease(A) == 1:
		return 0
	if tuple(A) in dic:
		return dic[tuple(A)]
	if len(A) == 2:
		if A[0] > A[1]:
			return 1
		else:
			return 0
	else:
		l = len(A)
		state = 1
		for i in range(len(A)):
			state = state and call(A[:i] + A[i + 1:])
		dic[tuple(A)] = int(state == 0)
		return dic[tuple(A)]
num = int(input())
for i in range(num):
	int(input())
	A = list(map(int, input().strip().split(' ')))
	if call(A) == 1:
		print('Alice')
	else:
		print('Bob')


from itertools import *
RESULTS = dict()

def splitX(X):
	P = [[next(X)]]
	while True:
		x = next(X, None)
		if x == None:
			break
		if x < P[-1][-1]:
			P.append([x])
		else:
			P[-1].append(x)
	return P

def isIncreasing(P):
	cnt = len(P)
	for i in range(len(P) - 1):
		if P[i][-1] < P[i + 1][0]:
			cnt -= 1
	return cnt == 1

def pack(P):
	res = 0
	for p in chain(*P):
		res = (res << 4) + p
	return res

def isWin(P, isAliceMove=True):
	packed = pack(P)
	r = RESULTS.get(packed, None)
	if r != None:
		return r
	if isIncreasing(P):
		return None
	if len(P) == 2 and (len(P[0]) == 1 or len(P[1]) == 1):
		RESULTS[packed] = True
		return True
	isBobMove = not isAliceMove
	for i in range(len(P)):
		if len(P[i]) == 1:
			PN = P[:i] + P[i + 1:]
			if isIncreasing(PN):
				RESULTS[packed] = True
				return True
			if not isWin(PN, not isAliceMove):
				RESULTS[packed] = True
				return True
		else:
			for j in range(len(P[i])):
				PN = P[:i] + [P[i][:j] + P[i][j + 1:]] + P[i + 1:]
				if isIncreasing(PN):
					RESULTS[packed] = True
					return True
				if not isWin(PN, not isAliceMove):
					RESULTS[packed] = True
					return True
	RESULTS[packed] = False
	return False
T = int(input())
for _ in range(T):
	N = int(input())
	X = map(int, input().split())
	P = splitX(X)
	print(('Bob', 'Alice')[isWin(P)])


from functools import lru_cache

@lru_cache(None)
def solve(perm):
	if all((perm[i - 1] < perm[i] for i in range(1, len(perm)))):
		return False
	if all((perm[i - 1] > perm[i] for i in range(1, len(perm)))):
		return len(perm) % 2 == 0
	return any((not solve(perm[:i] + perm[i + 1:]) for i in range(len(perm))))
for _ in range(int(input())):
	input()
	solve.cache_clear()
	if solve(tuple((int(x) for x in input().split()))):
		print('Alice')
	else:
		print('Bob')


alice_winnings = set()
bob_winnings = set()

def is_inc_seq(N, arr):
	for i in range(1, N):
		if arr[i] - arr[i - 1] <= 0:
			return False
	return True

def is_weak_dec_seq(N, arr):
	for i in range(1, N):
		if arr[i] - arr[i - 1] > 0:
			return False
	return True

def to_key(arr):
	return ':'.join(map(str, arr))

def alice_wins(N, arr, alice_turn):
	if is_inc_seq(N, arr):
		return not alice_turn
	if N == 2:
		return alice_turn
	if is_weak_dec_seq(N, arr):
		return alice_turn if N % 2 == 0 else not alice_turn
	key = to_key(arr)
	if alice_turn and key in alice_winnings:
		return True
	if not alice_turn and key in bob_winnings:
		return False
	for i in range(N):
		arr2 = arr[:i] + arr[i + 1:]
		alice_won = alice_wins(N - 1, arr2, not alice_turn)
		if alice_turn and alice_won:
			alice_winnings.add(key)
			return True
		elif not alice_turn and (not alice_won):
			bob_winnings.add(key)
			return False
	return False if alice_turn else True

def solve(N, arr):
	if alice_wins(N, arr, True):
		print('Alice')
	else:
		print('Bob')
T = int(input())
for t in range(T):
	N = int(input())
	arr = list(map(int, input().strip().split()))
	solve(N, arr)


T = int(input().strip())

def memoizer(x):
	if x not in D.keys():
		x = list(x)
		if sorted(x) == x:
			x = tuple(x)
			D[x] = 1
		else:
			x = tuple(x)
			D[x] = 1 - max([memoizer(x[:k] + x[k + 1:]) for k in range(len(x))])
	return D[x]
for kar in range(T):
	N = int(input().strip())
	numbers = tuple(map(int, input().strip().split(' ')))
	D = {}
	if memoizer(numbers) == 1:
		print('Bob')
	else:
		print('Alice')


import sys
from time import time

def increasing(aa):
	if not aa:
		return False
	last = aa[0]
	for i in range(1, len(aa)):
		if aa[i] <= last:
			return False
		last = aa[i]
	return True
ncache = dict()

def nimber(aa):
	if aa in ncache:
		return ncache[aa]
	rval = 0
	if not increasing(aa):
		nn = set()
		for i in range(len(aa)):
			nn.add(nimber(aa[:i] + aa[i + 1:]))
		rval = 0
		while rval in nn:
			rval += 1
	ncache[aa] = rval
	return rval

def solve(aa):
	print('aa=%s' % (aa,), file=sys.stderr)
	ncache.clear()
	n = nimber(tuple(aa))
	print('\tncache=%s' % (sorted(ncache.items()),), file=sys.stderr)
	print('\tn=%d' % (n,), file=sys.stderr)
	return n > 0
tm = time()
t = int(input())
for _ in range(t):
	_ = int(input())
	aa = list(map(int, input().split()))
	if solve(aa):
		print('Alice')
	else:
		print('Bob')


T = int(input())
cache = {}

def iswin(A):
	if A in cache:
		return cache[A]
	for i in range(1, len(A)):
		if A[i] < A[i - 1]:
			break
	else:
		cache[A] = False
		return False
	for i in range(len(A)):
		if not iswin(A[:i] + A[i + 1:]):
			cache[A] = True
			return True
	cache[A] = False
	return False
for t in range(T):
	N = int(input())
	A = tuple((int(x) for x in input().split()))
	print('Alice' if iswin(A) else 'Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


import os
import sys
from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


import os
import sys
from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from itertools import combinations
t = int(input())
for _ in range(t):
	n = int(input())
	a_turn = [i for i in range(n, 0, -2)]
	arr = list(map(int, input().split()))
	letters = 'AABCDEFGHIJKLMNO'
	s_start = ''.join([letters[i] for i in arr])
	states = []
	(graph, wl_log) = (dict(), dict())
	for i in range(2, n + 1):
		for vl in combinations(s_start, i):
			vs = ''.join(vl)
			graph[vs] = set()
			states.append(vs)
			wl_log[vs] = 'U'
	for vs in graph:
		length = len(vs)
		if length > 2:
			edges = set()
			for el in combinations(vs, length - 1):
				es = ''.join(el)
				edges.add(es)
			graph[vs] = edges
	for s in states:
		if wl_log[s] == 'U':
			lst = list(s)
			if len(s) not in a_turn:
				if lst == sorted(lst):
					wl_log[s] = 'W'
				else:
					count_wins = 0
					for sub_s in graph[s]:
						if wl_log[sub_s] == 'W':
							count_wins += 1
					if count_wins != 0 and count_wins == len(graph[s]):
						wl_log[s] = 'W'
					else:
						wl_log[s] = 'L'
			elif len(s) != n and lst == sorted(lst):
				wl_log[s] = 'L'
			else:
				for sub_s in graph[s]:
					if wl_log[sub_s] == 'W':
						wl_log[s] = 'W'
						break
				if len(s) == 2:
					wl_log[s] = 'W'
	print('Alice' if wl_log[s_start] == 'W' else 'Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


t = int(input())

def get_bit(m, i):
	return m >> i & 1
while t > 0:
	n = int(input())
	f = [0 for i in range(1 << n)]
	arr = list(map(int, input().split()))
	for m in range(1, 1 << n):
		prev = -1
		flag = True
		for i in range(n):
			if not get_bit(m, i):
				continue
			if prev >= 0 and arr[prev] > arr[i]:
				flag = False
				break
			else:
				prev = i
		if flag:
			continue
		for i in range(n):
			if get_bit(m, i):
				f[m] = f[m] or f[m ^ 1 << i] ^ 1
	print('Alice' if f[(1 << n) - 1] else 'Bob')
	t = t - 1


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


def play(arr):
	key = tuple(arr)
	v = d.get(key, None)
	if v is not None:
		return v
	if all((a < b for (a, b) in zip(arr[:-1], arr[1:]))):
		return False
	for i in range(len(arr)):
		if not play(arr[:i] + arr[i + 1:]):
			d[key] = True
			return True
	d[key] = False
	return False
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = '1' * len(arr)
	d = {}
	r = play(arr)
	if r == True:
		print('Alice')
	else:
		print('Bob')


from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = arr.copy()
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from functools import lru_cache

@lru_cache(maxsize=None)
def alphabeta(noeud, t, alpha, beta):
	if all((x < y for (x, y) in zip(noeud, noeud[1:]))):
		return (-t, t)[t % 2]
	if t % 2:
		v = float('inf')
		for i in range(len(noeud)):
			v = min(v, alphabeta(noeud[:i] + noeud[i + 1:], t + 1, alpha, beta))
			if alpha >= v:
				return v
			beta = min(beta, v)
	else:
		v = float('-inf')
		for i in range(len(noeud)):
			v = max(v, alphabeta(noeud[:i] + noeud[i + 1:], t + 1, alpha, beta))
			if beta <= v:
				return v
			alpha = max(alpha, v)
	return v
for _ in range(int(input())):
	n = int(input())
	noeud = tuple(map(int, input().split()))
	result = alphabeta(noeud, 0, float('-inf'), float('inf'))
	print(('Bob', 'Alice')[result > 0])


import sys

def memoize(function):
	cache = dict()

	def memoized_function(*args):
		if args in cache:
			return cache[args]
		else:
			result = function(*args)
			cache[args] = result
			return result
	return memoized_function

@memoize
def is_increasing(xs):
	if not xs:
		return True
	x0 = xs[0]
	for x in xs:
		if x < x0:
			return False
		x0 = x
	return True

@memoize
def is_winning_position(xs):
	if is_increasing(xs):
		return False
	return not all([is_winning_position(xs[:i] + xs[i + 1:]) for (i, _x) in enumerate(xs)])
T = int(sys.stdin.readline())
for case in range(T):
	_N = int(sys.stdin.readline())
	xs = tuple([int(X) for X in sys.stdin.readline().split()])
	print('Alice' if is_winning_position(xs) else 'Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')


from copy import copy
from collections import defaultdict

def renumber(arr):
	l = len(arr)
	old_num = sorted(arr)
	return [old_num.index(x) + 1 for x in arr]

def F(arr):
	if tuple(arr) in d:
		return d[tuple(arr)]
	elif arr == sorted(arr):
		d[tuple(arr)] = 0
		return d[tuple(arr)]
	else:
		ans = set()
		for x in arr:
			temp = copy(arr)
			temp.remove(x)
			temp = renumber(temp)
			ans.add(F(temp))
		result = 0
		while result in ans:
			result += 1
		d[tuple(arr)] = result
		return d[tuple(arr)]
d = defaultdict(int)
d[tuple([1])] = 0
for _ in range(int(input())):
	arr_count = int(input())
	arr = list(map(int, input().rstrip().split()))
	print('Alice') if F(arr) else print('Bob')