Alice and Bob are playing a game with strings. There will be $t$ rounds in the game. In each round, there will be a string $s$ consisting of lowercase English letters.

Alice moves first and both the players take alternate turns. Alice is allowed to remove any substring of even length (possibly empty) and Bob is allowed to remove any substring of odd length from $s$.

More formally, if there was a string $s = s_1s_2 \ldots s_k$ the player can choose a substring $s_ls_{l+1} \ldots s_{r-1}s_r$ with length of corresponding parity and remove it. After that the string will become $s = s_1 \ldots s_{l-1}s_{r+1} \ldots s_k$.

After the string becomes empty, the round ends and each player calculates his/her score for this round. The score of a player is the sum of values of all characters removed by him/her. The value of ${a}$ is $1$, the value of ${b}$ is $2$, the value of ${c}$ is $3$, $\ldots$, and the value of ${z}$ is $26$. The player with higher score wins the round. For each round, determine the winner and the difference between winner's and loser's scores. Assume that both players play optimally to maximize their score. It can be proved that a draw is impossible.


-----Input-----

The first line of input contains a single integer $t$ ($1\leq t\leq 5\cdot 10^4$) denoting the number of rounds.

Each of the next $t$ lines contain a single string $s$ ($1\leq |s|\leq 2\cdot 10^5$) consisting of lowercase English letters, denoting the string used for the round. Here $|s|$ denotes the length of the string $s$.

It is guaranteed that the sum of $|s|$ over all rounds does not exceed $2\cdot 10^5$.


-----Output-----

For each round, print a single line containing a string and an integer. If Alice wins the round, the string must be "Alice". If Bob wins the round, the string must be "Bob". The integer must be the difference between their scores assuming both players play optimally.


-----Examples-----

Input
5
aba
abc
cba
n
codeforces
Output
Alice 2
Alice 4
Alice 4
Bob 14
Alice 93


-----Note-----

For the first round, ${"aba"}\xrightarrow{{Alice}}{"}{{{ab}}}{a"}\xrightarrow{} {"a"}\xrightarrow{{Bob}}{"}{{{a}}}{"}\xrightarrow{}{""}$. Alice's total score is $1+2=3$. Bob's total score is $1$.

For the second round, ${"abc"}\xrightarrow{{Alice}}{"a}{{{bc}}}{"}\xrightarrow{} {"a"}\xrightarrow{{Bob}}{"}{{{a}}}{"}\xrightarrow{}{""}$. Alice's total score is $2+3=5$. Bob's total score is $1$.

For the third round, ${"cba"}\xrightarrow{{Alice}}{"}{{{cb}}}{a"}\xrightarrow{} {"a"}\xrightarrow{{Bob}}{"}{{{a}}}{"}\xrightarrow{}{""}$. Alice's total score is $3+2=5$. Bob's total score is $1$.

For the fourth round, ${"n"}\xrightarrow{{Alice}}{"n"}\xrightarrow{} {"n"}\xrightarrow{{Bob}}{"}{{{n}}}{"}\xrightarrow{}{""}$. Alice's total score is $0$. Bob's total score is $14$.

For the fifth round, ${"codeforces"}\xrightarrow{{Alice}}{"}{{{codeforces}}}{"}\xrightarrow{} {""}$. Alice's total score is $3+15+4+5+6+15+18+3+5+19=93$. Bob's total score is $0$.

Difficulty: EASY
Tags: String algorithms

Game theory

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	n = len(s)
	score = 0
	for c in s:
		score += ord(c) - ord('a') + 1
	if n % 2 == 0:
		print('Alice ' + str(score))
	else:
		sb = min(ord(s[0]) - ord('a') + 1, ord(s[-1]) - ord('a') + 1)
		if sb > score - sb:
			print('Bob ' + str(2 * sb - score))
		else:
			print('Alice ' + str(score - 2 * sb))
for _ in range(int(input())):
	solve()


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_string():
	return list(map(str, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_print_int(x):
	sys.stdout.write(str(x) + '\n')

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')

def solve():
	for _ in range(get_int()):
		s = get_string()
		n = len(s)
		summ = 0
		for i in s:
			summ += ord(i) - ord('a') + 1
		if n % 2 == 0:
			get_print('Alice {}'.format(summ))
		else:
			a1 = summ - (ord(s[0]) - ord('a') + 1)
			a2 = summ - (ord(s[-1]) - ord('a') + 1)
			b1 = summ - a1
			b2 = summ - a2
			if a1 > b1 and a2 > b2:
				get_print('Alice {}'.format(max(a1 - b1, a2 - b2)))
			elif a1 > b1:
				get_print('Alice {}'.format(a1 - b1))
			elif a2 > b2:
				get_print('Alice {}'.format(a2 - b2))
			else:
				get_print('Bob {}'.format(min(b1 - a1, b2 - a2)))
solve()


def cringe(s):
	k = 0
	if len(s) == 1:
		return 'Bob ' + str(ord(s[0]) - 96)
	else:
		if len(s) % 2 == 0:
			for i in range(len(s)):
				k = k + ord(s[i]) - 96
		elif ord(s[0]) > ord(s[len(s) - 1]):
			for i in range(len(s) - 1):
				k = k + ord(s[i]) - 96
			k = k - ord(s[len(s) - 1]) + 96
		else:
			for i in range(1, len(s)):
				k = k + ord(s[i]) - 96
			k = k - ord(s[0]) + 96
		if k > 0:
			k = str(k)
			return 'Alice ' + k
		else:
			k = str(abs(k))
			return 'Bob ' + k
n = int(input())
p = []
for i in range(n):
	h = input()
	p.append(cringe(h))
print('\n'.join(p))


import sys

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		s = sys.stdin.readline().rstrip()
		ln = len(s)
		alice = 0
		bob = 0
		if ln % 2 == 0:
			for l in s:
				alice += ord(l) - 96
		elif ln % 2 == 1 and ln > 2:
			if s[0] >= s[-1]:
				for l in s[:-1]:
					alice += ord(l) - 96
				bob += ord(s[-1]) - 96
			else:
				for l in s[1:]:
					alice += ord(l) - 96
				bob += ord(s[0]) - 96
		else:
			for l in s:
				bob += ord(l) - 96
		if alice > bob:
			print('Alice', alice - bob)
		else:
			print('Bob', bob - alice)
main()


import sys
n = int(sys.stdin.readline())
for i in range(n):
	s = sys.stdin.readline().strip()
	if len(s) == 1:
		res = ord(s[0]) - ord('a') + 1
		print(f'Bob {res}')
	elif len(s) % 2 == 0:
		res = sum([ord(ch) - ord('a') + 1 for ch in s])
		print(f'Alice {res}')
	elif len(s) % 2 == 1:
		fl = ord(s[0]) - ord('a') + 1
		ll = ord(s[-1]) - ord('a') + 1
		at = sum([ord(ch) - ord('a') + 1 for ch in s[1:-1]]) + max(fl, ll) - min(fl, ll)
		print(f'Alice {at}')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input()[:-1]
	x = len(s)
	if x == 1:
		print('Bob', ord(s) - 96)
	else:
		c = -96 * x
		for i in s:
			c += ord(i)
		if x % 2:
			print('Alice', c - ord(s[0]) - ord(s[-1]) + 96 * 2 + abs(ord(s[0]) - ord(s[-1])))
		else:
			print('Alice', c)


def f(s):
	cnt = 0
	for i in s:
		cnt += ord(i) - 96
	return cnt
t = int(input())
a = [input() for i in range(t)]
for i in a:
	length = len(i)
	if length > 1:
		if length % 2 == 1:
			cnt0 = 0
			if ord(i[0]) > ord(i[-1]):
				cnt0 += f(i[:-1]) - (ord(i[-1]) - 96)
			else:
				cnt0 += f(i[1:]) - (ord(i[0]) - 96)
			print(f'Alice {cnt0}')
		else:
			print(f'Alice {f(i)}')
	else:
		print(f'Bob {ord(i[0]) - 96}')


def solve(s):
	first = ord('a') - 1
	if len(s) == 1:
		return 'Bob ' + str(ord(s) - first)
	elif len(s) % 2 == 1:
		if ord(s[0]) < ord(s[-1]):
			bob = s[0]
			alice = s[1:]
		else:
			bob = s[-1]
			alice = s[:-1]
		aCount = 0
		for i in alice:
			aCount += ord(i) - first
		difference = aCount - (ord(bob) - first)
		return 'Alice ' + str(difference)
	else:
		aCount = 0
		for i in s:
			aCount += ord(i) - first
		return 'Alice ' + str(aCount)
t = int(input())
cases = []
for i in range(t):
	cases.append(input())
ans = []
for i in cases:
	ans.append(solve(i))
for i in ans:
	print(i)


import sys
input = sys.stdin.readline
for _ in range(int(input().rstrip())):
	s = input().rstrip()
	(first, last) = (ord(s[0]) - ord('a') + 1, ord(s[-1]) - ord('a') + 1)
	total = 0
	for c in s:
		total += ord(c) - ord('a') + 1
	if not len(s) % 2:
		print(f'Alice {total}')
	else:
		bob = min(first, last)
		alice = total - bob
		if alice > bob:
			print(f'Alice {alice - bob}')
		else:
			print(f'Bob {bob - alice}')


import sys
t = int(sys.stdin.readline())
list2 = []
for i in range(t):
	a = 0
	b = 0
	list1 = input()
	if len(list1) % 2 == 0:
		for j in list1:
			a += ord(j) - 96
		list2.append('Alice %d' % a)
	elif len(list1) == 1:
		list2.append('Bob %d' % (ord(list1[0]) - 96))
	else:
		temp1 = 0
		temp2 = 0
		for j in range(len(list1) - 1):
			temp1 += ord(list1[j]) - 96
		for j in range(1, len(list1)):
			temp2 += ord(list1[j]) - 96
		if temp1 > temp2:
			c = 0
			a = temp1
		else:
			c = 1
			a = temp2
		if c == 0:
			b = ord(list1[-1]) - 96
		else:
			b = ord(list1[0]) - 96
		list2.append('Alice %d' % (a - b))
for i in list2:
	print(i)


t = int(input())
res = []
for i in range(t):
	st = input()
	if len(st) % 2 == 0:
		sum = 0
		for item in st:
			sum = sum + ord(item) - 96
		res.append('Alice ' + str(sum))
	elif len(st) == 1:
		res.append('Bob ' + str(ord(st) - 96))
	else:
		m = min(ord(st[0]), ord(st[len(st) - 1]))
		sum = 0
		for item in st:
			sum = sum + ord(item) - 96
		res.append('Alice ' + str(sum - 2 * (m - 96)))
for i in res:
	print(i)


import sys

def solve():
	s = sys.stdin.readline().strip()
	n = len(s)
	s = list(map(ord, s))
	x = sum(s) - (ord('a') - 1) * n
	if n % 2 == 1:
		b = min(s[0], s[-1]) - ord('a') + 1
		a = x - b
	else:
		a = x
		b = 0
	if a > b:
		print('Alice', a - b)
	else:
		print('Bob', b - a)

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


n = int(input())
lis = []
for i in range(n):
	s = str(input())
	summa = 0
	for j in range(len(s)):
		summa = summa + (ord(s[j]) - 96)
	start = ord(s[0]) - 96
	fin = ord(s[-1]) - 96
	if len(s) == 1:
		lis.append('Bob ' + str(ord(s[0]) - 96))
	elif len(s) % 2 == 1:
		alis = max(summa - start, summa - fin)
		fail = min(start, fin)
		lis.append('Alice ' + str(alis - fail))
	else:
		lis.append('Alice ' + str(summa))
for i in range(n):
	print(lis[i])


t = int(input())
in_list = []
for i in range(t):
	inp_str = input()
	in_list.append(inp_str)
for s in in_list:
	li = []
	for x in s:
		li.append(ord(x) - 96)
	n = len(s)
	alice = 0
	bob = 0
	if n % 2 == 0:
		alice = sum(li)
	elif sum(li[1:]) > sum(li[:n - 1]):
		alice = sum(li[1:])
		bob = li[0]
	else:
		alice = sum(li[:n - 1])
		bob = li[n - 1]
	if alice > bob:
		print('Alice ', alice - bob)
	else:
		print('Bob ', bob - alice)


t = int(input())
l = []
for i in range(t):
	l.append(input())
for i in l:
	k = len(i)
	if k == 1:
		print(f'Bob {ord(i) - 96}')
	else:
		m = k % 2
		h = 1
		if i[0] < i[-1]:
			h = 0
		diff = sum([ord(j) - 96 for j in i[(1 - h) * m:k - h * m]]) - (ord(i[-h]) - 96) * m
		print(f'Alice {diff}')


import sys
input = lambda : sys.stdin.readline().strip()
for i in range(int(input())):
	s = input()
	l = len(s)
	if l <= 1:
		print('Bob', int(ord(s)) - 96)
	elif l % 2 == 0:
		lis = list(s)
		ans = 0
		for i in s:
			ans += int(ord(i)) - 96
		print('Alice', ans)
	elif int(ord(s[0])) - 96 > int(ord(s[-1])) - 96:
		lis = list(s[:-1])
		ans = 0
		for i in lis:
			ans += int(ord(i)) - 96
		x = int(ord(s[-1])) - 96
		if ans > x:
			print('Alice', ans - x)
		else:
			print('Bob', x - ans)
	else:
		lis = list(s[1:])
		ans = 0
		for i in lis:
			ans += int(ord(i)) - 96
		x = int(ord(s[0])) - 96
		if ans > x:
			print('Alice', ans - x)
		else:
			print('Bob', x - ans)


import sys
input = sys.stdin.readline

def S():
	return input().rstrip()
for i in range(int(input())):
	s = S()
	score = 0
	for j in range(len(s)):
		score += ord(s[j]) - ord('a') + 1
	if len(s) % 2 == 0:
		print('Alice', score)
	else:
		score1 = score - (ord(s[0]) - ord('a') + 1)
		score2 = score - (ord(s[-1]) - ord('a') + 1)
		score_a = max(score1, score2)
		score_b = score - score_a
		if score_a > score_b:
			print('Alice', score_a - score_b)
		else:
			print('Bob', score_b - score_a)


letters = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
words = []
for i in range(n):
	words.append(input())
for i in words:
	aliceVal = 0
	bobVal = 0
	if len(i) % 2 == 0:
		for j in i:
			aliceVal += letters.index(j) + 1
		print('Alice', str(aliceVal - bobVal))
	elif letters.index(i[0]) > letters.index(i[-1]):
		for j in range(len(i) - 1):
			aliceVal += letters.index(i[j]) + 1
		bobVal += letters.index(i[-1]) + 1
		if bobVal > aliceVal:
			print('Bob', str(bobVal - aliceVal))
		else:
			print('Alice', str(aliceVal - bobVal))
	else:
		for j in range(1, len(i)):
			aliceVal += letters.index(i[j]) + 1
		bobVal += letters.index(i[0]) + 1
		if bobVal > aliceVal:
			print('Bob', str(bobVal - aliceVal))
		else:
			print('Alice', str(aliceVal - bobVal))


t = int(input())
l = []
for i in range(t):
	a = input()
	l.append(a)
for i in l:
	if len(i) % 2 != 0:
		if len(i) == 1:
			print('Bob ', ord(i) - 96)
		elif ord(i[0]) >= ord(i[-1]):
			s = 0
			for j in range(len(i) - 1):
				s = s + (ord(i[j]) - 96)
			else:
				if s > ord(i[len(i) - 1]) - 96:
					print('Alice ', s - (ord(i[len(i) - 1]) - 96))
				else:
					print('Bob ', ord(i[len(i) - 1]) - 96 - s)
		else:
			s = 0
			for k in range(1, len(i)):
				s = s + ord(i[k]) - 96
			else:
				if s > ord(i[0]) - 96:
					print('Alice ', s - (ord(i[0]) - 96))
				else:
					print('Bob ', ord(i[0]) - 96)
	else:
		s = 0
		for n in range(len(i)):
			s = s + (ord(i[n]) - 96)
		print('Alice ', s)


import sys
import math
from math import gcd, sqrt, log2, ceil, floor
import heapq as hq
from bisect import bisect_right, bisect_left, bisect
import itertools
from sys import stdin, stdout, setrecursionlimit
MOD = int(1000000000.0) + 7
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
T = int(stdin.readline())
for _ in range(T):
	s = list(stdin.readline().strip('\n'))
	n = len(s)
	for i in range(n):
		s[i] = ord(s[i]) - ord('a') + 1
	if n % 2 == 0:
		print('Alice', sum(s))
	elif n == 1:
		print('Bob', s[0])
	else:
		print('Alice', sum(s) - 2 * min(s[0], s[-1]))


n = int(input())
l = []
d = []
for i in range(n):
	s = input()
	if len(s) == 1:
		l.append('Bob')
		d.append(ord(s) - 96)
		continue
	l.append('Alice')
	if len(s) % 2 == 0:
		diff = 0
		for i in range(len(s)):
			diff += ord(s[i]) - 96
	else:
		if ord(s[0]) > ord(s[len(s) - 1]):
			bc = ord(s[len(s) - 1]) - 96
			ac = 0
			for i in range(len(s) - 1):
				ac += ord(s[i]) - 96
		else:
			bc = ord(s[0]) - 96
			ac = 0
			for i in range(1, len(s)):
				ac += ord(s[i]) - 96
		diff = ac - bc
	d.append(diff)
for i in range(len(l)):
	print(l[i], d[i])


def chr_score(chr):
	return ord(chr) - ord('a') + 1

def str_score(str):
	chr_score_list = [chr_score(chr) for chr in str]
	return sum(chr_score_list)

def alice_bob_scores(str):
	if len(str) % 2 == 0:
		return [str_score(str), 0]
	elif chr_score(str[-1]) <= chr_score(str[0]):
		return [str_score(str[:-1]), chr_score(str[-1])]
	else:
		return [str_score(str[1:]), chr_score(str[0])]

def winner_and_score_difference(str):
	scores = alice_bob_scores(str)
	if scores[0] > scores[1]:
		return ['Alice', scores[0] - scores[1]]
	else:
		return ['Bob', scores[1] - scores[0]]

def print_winner_score(str):
	(winner, score_diff) = winner_and_score_difference(str)
	print(winner, score_diff)
input_str_list = [input() for _ in range(int(input()))]
for str in input_str_list:
	print_winner_score(str)


let = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
name = []
dif = []
t = int(input())
for i in range(t):
	word = input()
	word1 = []
	for w in word:
		word1.append(w)
	result = 0
	if len(word) == 1:
		name.append('Bob')
		dif.append(let.index(word) + 1)
	elif len(word) % 2 == 0:
		name.append('Alice')
		for num in word1:
			result = result + let.index(num) + 1
		dif.append(result)
		result = 0
	else:
		name.append('Alice')
		for num in word1:
			result = result + let.index(num) + 1
		num1 = result - let.index(word1[0]) - let.index(word1[0]) - 2
		num2 = result - let.index(word1[-1]) - let.index(word1[-1]) - 2
		if num1 > num2:
			dif.append(num1)
		elif num2 > num1:
			dif.append(num2)
		else:
			dif.append(num1)
		result = 0
for i in range(t):
	print(name[i] + ' ' + str(dif[i]))


a = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}

def fun():
	s = input()
	b = len(s)
	ali = 0
	bob = 0
	while b > 0:
		if b % 2 == 0:
			for i in s:
				ali += a[i]
			return f'Alice {ali}'
		else:
			if b == 1:
				return f'Bob {a[s]}'
			if a[s[0]] >= a[s[-1]]:
				bob += a[s[-1]]
			else:
				bob += a[s[0]]
			for i in s:
				ali += a[i]
			ali -= bob
			if ali < bob:
				return f'Bob {bob - ali}'
			else:
				return f'Alice {ali - bob}'
		b = len(s)
for i in range(int(input())):
	print(fun())


def score(s):
	w = 0
	for c in s:
		w += ord(c) - 96
	return w

def solve(s):
	if len(s) & 1 == 0:
		print(f'Alice {score(s)}')
	elif len(s) == 1:
		print(f'Bob {score(s)}')
	else:
		if score(s[:-1]) <= score(s[1:]):
			alice_score = score(s[1:])
			bob_score = score(s[0])
		else:
			alice_score = score(s[:-1])
			bob_score = score(s[-1])
		if alice_score > bob_score:
			print(f'Alice {alice_score - bob_score}')
		else:
			print(f'Bob {bob_score - alice_score}')

def main():
	for _ in range(int(input())):
		solve(input())
main()


t = int(input())
for _ in range(t):
	s = input()
	(a, b) = (0, 0)
	if len(s) == 1:
		print('Bob ' + str(ord(s) - 96))
		continue
	if len(s) % 2 == 0:
		for i in s:
			a += ord(i) - 96
		b = 0
	else:
		for i in s[1:len(s) - 1]:
			a += ord(i) - 96
		if s[0] > s[-1]:
			a += ord(s[0]) - 96
			b += ord(s[-1]) - 96
		else:
			a += ord(s[-1]) - 96
			b += ord(s[0]) - 96
	if a > b:
		print('Alice ' + str(a - b))
	else:
		print('Bob ' + str(b - a))


from collections import Counter

def score(string):
	coll = Counter(string)
	score_ = 0
	for i in coll:
		score_ += coll[i] * (ord(i) - 96)
	return score_

def value(string):
	if len(string) > 1:
		if len(string) % 2 == 0:
			print('Alice', score(string))
		elif score(string[0]) > score(string[-1]):
			print('Alice', score(string[:-1]) - score(string[-1]))
		else:
			print('Alice', score(string[1:]) - score(string[0]))
	else:
		print('Bob', score(string))

def main():
	n = int(input())
	data = []
	for i in range(n):
		string = input()
		data.append(string)
	for string in data:
		value(string)
main()


def q(w):
	z = 0
	for i in w:
		z += ord(i) - 96
	if len(w) % 2 == 0:
		return 'Alice ' + str(z)
	else:
		a = 0
		b = 0
		if z - ord(w[-1]) + 96 > z - ord(w[0]) + 96:
			a += z - ord(w[-1]) + 96
			b += ord(w[-1]) - 96
			if a > b:
				return 'Alice ' + str(abs(a - b))
			else:
				return 'Bob ' + str(abs(a - b))
		else:
			a += z - ord(w[0]) + 96
			b += ord(w[0]) - 96
			if a > b:
				return 'Alice ' + str(abs(b - a))
			else:
				return 'Bob ' + str(abs(a - b))
s = int(input())
for i in range(s):
	f = input()
	print(q(f))


for _ in range(int(input())):
	val = input()
	val = [ord(i) - 96 for i in val]
	if len(val) == 1:
		print('Bob ' + str(val[0]))
	elif len(val) % 2 == 1:
		print('Alice ' + str(sum(val) - 2 * min(val[0], val[-1])))
	else:
		print('Alice ' + str(sum(val)))


t = int(input())
for _ in range(t):
	s = input()
	total = 0
	size = len(s)
	for c in s:
		total += ord(c) - 96
	if size == 1:
		print(f'Bob {total}')
	else:
		if size % 2 != 0:
			total -= min(ord(s[0]) - 96, ord(s[size - 1]) - 96) * 2
		print(f'Alice {total}')


def main():
	n = int(input())
	start_pos = ord('a')
	end_pos = ord('z')

	def max_deletion(in_data, isChet=True):
		if len(in_data) == 0:
			return ''
		if isChet:
			if len(in_data) % 2 == 0:
				return in_data
			elif ord(in_data[0]) > ord(in_data[-1]):
				return in_data[0:-1]
			else:
				return in_data[1:]
		elif len(in_data) % 2 == 1:
			return in_data
		elif ord(in_data[0]) > ord(in_data[-1]):
			return in_data[0:-1]
		else:
			return in_data[1:]

	def count(in_data):
		result = 0
		for i in in_data:
			result = result + ord(i) - start_pos + 1
		return result
	for _ in range(n):
		data = input()
		new_data = data
		Alice = max_deletion(data)
		new_data = new_data.replace(Alice, '')
		Bob = max_deletion(new_data, False)
		Alice_count = count(Alice)
		Bob_count = count(Bob)
		if Alice_count > Bob_count:
			print(f'Alice {Alice_count - Bob_count}')
		else:
			print(f'Bob {Bob_count - Alice_count}')
main()


for _ in range(int(input())):
	string = input()
	if len(string) % 2 == 0:
		score = sum((ord(c) - 96 for c in string))
		print(f'Alice {score}')
	else:
		score = sum((ord(c) - 96 for c in string))
		alice = max(score - ord(string[0]) + 96, score - ord(string[-1]) + 96)
		bob = score - alice
		if alice > bob:
			print(f'Alice {alice - bob}')
		elif alice < bob:
			print(f'Bob {bob - alice}')


def getSum(s: str):
	sums = 0
	for i in s:
		sums += ord(i) - 96
	return sums
for t in range(int(input())):
	s = input()
	n = len(s)
	if n % 2 == 0:
		print('Alice %d' % getSum(s))
	elif n == 1:
		print('Bob %d' % getSum(s))
	else:
		print('Alice %d' % max(getSum(s[1:n]) - (ord(s[0]) - 96), getSum(s[0:n - 1]) - (ord(s[n - 1]) - 96)))


t = int(input())
while t > 0:
	s = input()
	n = len(s)
	sum = 0
	for i in s:
		sum += ord(i) - 96
	if n == 1:
		print(f'Bob {sum}')
	else:
		if n % 2 == 1:
			if ord(s[0]) > ord(s[-1]):
				sum = sum - 2 * (ord(s[-1]) - 96)
			else:
				sum = sum - 2 * (ord(s[0]) - 96)
		print(f'Alice {sum}')
	t -= 1


t = int(input())
for i in range(t):
	a = []
	b = []
	s = input()
	for j in s:
		a.append(ord(j) - 96)
	if len(a) % 2 == 0:
		print(f'Alice {sum(a)}')
	elif len(a) == 1:
		print(f'Bob {sum(a)}')
	elif a[0] >= a[-1]:
		print(f'Alice {sum(a[:-1]) - a[-1]}')
	else:
		print(f'Alice {sum(a[1:]) - a[0]}')


def w(c):
	return ord(c) - 96
for _ in range(int(input())):
	s = input()
	if len(s) % 2:
		b = w(min(s[0], s[-1]))
		a = sum(map(w, s)) - b
		r = str(abs(a - b))
		print('Alice ' + r if a > b else 'Bob ' + r)
	else:
		print('Alice', sum(map(w, s)))


dict1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
tc = int(input())
for _ in range(tc):
	s = input()
	cnt = 0
	for i in s:
		cnt += dict1[i]
	if len(s) % 2 == 0:
		print('Alice ' + str(cnt))
	else:
		cnt -= min(dict1[s[0]], dict1[s[-1]])
		a = min(dict1[s[0]], dict1[s[-1]])
		if max(a, cnt) == a:
			print('Bob ' + str(a))
		else:
			print('Alice ' + str(cnt - a))


n = int(input())
for i in range(n):
	sum = 0
	s = input()
	f = ord(s[0]) - 96
	l = ord(s[-1]) - 96
	for j in s:
		sum += ord(j) - 96
	if len(s) % 2 == 0:
		print('Alice  ' + str(sum))
	else:
		a = sum - min(f, l)
		b = min(f, l)
		if a > b:
			print('Alice  ' + str(a - b))
		else:
			print('Bob  ' + str(b - a))


def getScore(s):
	counter = 0
	for c in s:
		counter += ord(c) - 96
	return counter
t = int(input())
while t > 0:
	t -= 1
	s = input()
	if len(s) == 1:
		print(f'Bob {ord(s) - 96}')
	elif len(s) % 2 == 0:
		print(f'Alice {getScore(s)}')
	elif s[0] > s[-1]:
		print(f'Alice {getScore(s[:-1]) - getScore(s[-1])}')
	else:
		print(f'Alice {getScore(s[1:]) - getScore(s[0])}')


N = int(input())
for _ in range(N):
	cur_str = input()
	sum = 0
	if len(cur_str) % 2 == 0:
		for ch in cur_str:
			sum += ord(ch) - 96
		sum = str(sum)
		print(f'Alice {sum}')
	elif len(cur_str) == 1:
		sum = ord(cur_str[0]) - 96
		sum = str(sum)
		print(f'Bob {sum}')
	else:
		for ch in cur_str:
			sum += ord(ch) - 96
		sum = sum - 2 * min(ord(cur_str[0]) - 96, ord(cur_str[-1]) - 96)
		print(f'Alice {sum}')


d = dict()
for i in range(ord('a'), ord('z') + 1):
	d[chr(i)] = i - ord('a') + 1
for _ in range(int(input())):
	summ = 0
	st = input()
	if len(st) == 1:
		print('Bob', d[st[0]])
	else:
		for x in st:
			summ += d[x]
		if len(st) % 2 == 1:
			summ -= 2 * min(d[st[0]], d[st[-1]])
		print('Alice', summ)


def find_winner(word):
	if len(word) < 2:
		return f'Bob {ord(word) - 96}'
	if len(word) % 2 == 0:
		return f'Alice {sum([ord(char) - 96 for char in word])}'
	return f'Alice {sum([ord(char) - 96 for char in word]) - min((ord(word[0]) - 96) * 2, (ord(word[-1]) - 96) * 2)}'
t = int(input())
for _ in range(t):
	word = input()
	print(find_winner(word))


def ri():
	return int(input())
t = ri()

def cal(s):
	return sum([ord(x) - ord('a') + 1 for x in s])
for _ in range(t):
	s = input()
	n = len(s)
	if n % 2 == 0:
		print('Alice %d' % cal(s))
	else:
		(alice, bob) = (0, 0)
		if ord(s[0]) < ord(s[-1]):
			alice = cal(s[1:])
			bob = ord(s[0]) - ord('a') + 1
		else:
			alice = cal(s[0:-1])
			bob = ord(s[-1]) - ord('a') + 1
		if alice > bob:
			print('Alice %d' % (alice - bob))
		else:
			print('Bob %d' % (bob - alice))


def solve():
	b = input()
	f = [ord(u) - 96 for u in b]
	if len(b) == 1:
		print('Bob', f[0])
	elif len(b) % 2 == 0:
		print('Alice', sum(f))
	else:
		print('Alice', sum(f) - 2 * min(f[0], f[-1]))
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	s = input()
	ls = []
	for c in s:
		ls.append(ord(c) - 96)
	if len(ls) % 2 == 0:
		print('Alice', sum(ls))
	elif len(ls) == 1:
		print('Bob', sum(ls))
	elif ls[0] > ls[-1]:
		print('Alice', sum(ls[:-1]) - ls[-1])
	else:
		print('Alice', sum(ls[1:]) - ls[0])


def poo():
	t = int(input())
	for _ in range(t):
		s = input()
		if len(s) % 2 == 0:
			foo = 0
			for c in s:
				foo += ord(c) - 96
			print('Alice', foo)
		elif len(s) == 1:
			print('Bob', ord(s) - 96)
		else:
			first = ''.join(sorted(s[1:]))
			foo = 0
			for char in first:
				foo += ord(char) - 96
			sec = ''.join(sorted(s[:-1]))
			foo2 = 0
			for char in sec:
				foo2 += ord(char) - 96
			c = ord(s[0]) - 96
			d = ord(s[-1]) - 96
			ma = max(foo - c, foo2 - d)
			print('Alice', ma)
poo()


def solution(content):
	n = len(content)
	total = sum((ord(i) - ord('a') + 1 for i in content))
	if n == 1:
		print('Bob', total)
		return
	if n % 2 == 0:
		print('Alice', total)
		return
	bob_score = min(ord(content[0]) - ord('a') + 1, ord(content[-1]) - ord('a') + 1)
	alice_score = total - bob_score
	if alice_score > bob_score:
		print('Alice', alice_score - bob_score)
		return
	else:
		print('Bob', bob_score - alice_score)
		return
t = int(input())
for i in range(t):
	content = input()
	solution(content)


t = int(input())
for _ in range(t):
	s = input()
	l = len(s)
	if l == 1:
		print('Bob ' + str(ord(s) - 96))
	elif l % 2 == 0:
		res = 0
		for i in s:
			res += ord(i) - 96
		print('Alice ' + str(res))
	else:
		res = 0
		if s[0] > s[-1]:
			for i in range(l - 1):
				res += ord(s[i]) - 96
			res -= ord(s[-1]) - 96
		else:
			for i in range(1, l):
				res += ord(s[i]) - 96
			res -= ord(s[0]) - 96
		print('Alice ' + str(res))


def calcScore(s):
	score = 0
	for char in s:
		score += ord(char) - 96
	return score
t = int(input())
for _ in range(t):
	s = input().strip()
	if len(s) % 2 == 1 and len(s) > 1:
		a_left = calcScore(s[:-1])
		a_right = calcScore(s[1:])
		if a_left > a_right:
			b = calcScore(s[-1:])
			print('Alice', a_left - b)
		else:
			b = calcScore(s[0])
			print('Alice', a_right - b)
	elif len(s) % 2 == 0:
		a = calcScore(s)
		print('Alice', a)
	else:
		b = calcScore(s)
		winner = 'Bob'
		print('Bob', b)


t = int(input())
for i in range(t):
	a = input()
	s = len(a)
	score = 0
	for j in a:
		score += ord(j) - 96
	if s % 2 == 0:
		print('Alice', score)
	elif s == 1:
		print('Bob', ord(a) - 96)
	else:
		start = ord(a[0]) - 96
		end = ord(a[-1]) - 96
		if score - start > score - end:
			scorea = score - start
		else:
			scorea = score - end
		scoreb = score - scorea
		if scorea > scoreb:
			print('Alice', scorea - scoreb)
		else:
			print('Bob', scoreb - scorea)


def stringcounter(string):
	sum = 0
	for i in string:
		sum += ord(i) - 96
	return sum

def stringsubtractor(string):
	total = stringcounter(string)
	if string[0] < string[-1]:
		min = ord(string[0]) - 96
	else:
		min = ord(string[-1]) - 96
	return total - 2 * min
for i in range(int(input())):
	string = input()
	if len(string) % 2 == 0:
		score = stringcounter(string)
		print('Alice', score)
	else:
		score = stringsubtractor(string)
		if score < 0:
			print('Bob', abs(score))
		else:
			print('Alice', abs(score))


for _ in range(int(input())):
	s = input()
	n = len(s)
	if n % 2 == 0:
		ans = 0
		for i in s:
			ans += ord(i) - 96
		print('Alice', ans)
	elif ord(s[0]) - 96 >= ord(s[-1]) - 96:
		ans = 0
		for i in range(n - 1):
			ans += ord(s[i]) - 96
		if ans > ord(s[-1]) - 96:
			print('Alice', ans - (ord(s[-1]) - 96))
		else:
			print('Bob', ord(s[-1]) - 96 - ans)
	else:
		ans = 0
		for i in range(1, n):
			ans += ord(s[i]) - 96
		if ans > ord(s[0]) - 96:
			print('Alice', ans - (ord(s[0]) - 96))
		else:
			print('Bob', ord(s[0]) - 96 - ans)


t = int(input())
for _ in range(t):
	s = str(input())
	if len(s) == 1:
		print(f'Bob {ord(s) - 96}')
	elif len(s) % 2 == 0:
		score = 0
		for i in s:
			score += ord(i) - 96
		print(f'Alice {score}')
	else:
		z = []
		for i in s:
			z.append(ord(i) - 96)
		if sum(z) - (ord(s[0]) - 96) >= sum(z) - (ord(s[len(s) - 1]) - 96):
			print(f'Alice {sum(z) - (ord(s[0]) - 96) * 2}')
		else:
			print(f'Alice {sum(z) - (ord(s[len(s) - 1]) - 96) * 2}')


t = int(input())
for _ in range(t):
	s = input()
	if len(s) % 2:
		if s[0] < s[-1]:
			a = 0
			for c in s[1:]:
				a += ord(c) - ord('a') + 1
			b = ord(s[0]) - ord('a') + 1
		else:
			a = 0
			for c in s[:-1]:
				a += ord(c) - ord('a') + 1
			b = ord(s[-1]) - ord('a') + 1
	else:
		a = 0
		for c in s:
			a += ord(c) - ord('a') + 1
		b = 0
	if a > b:
		print('Alice ' + str(a - b))
	else:
		print('Bob ' + str(b - a))


n = int(input())
for _ in range(n):
	s = input()
	if len(s) == 1:
		print(f"Bob {ord(s[0]) - ord('a') + 1}")
	elif len(s) % 2 == 0:
		print(f"Alice {sum([ord(i) - ord('a') + 1 for i in s])}")
	else:
		b = min(ord(s[0]), ord(s[-1])) - ord('a') + 1
		a = sum([ord(i) - ord('a') + 1 for i in s])
		print(f'Alice {a - b - b}')


for t in range(int(input())):
	s = input()
	n = len(s)
	c = 0
	for i in s:
		c += ord(i) - 96
	if n % 2 == 0:
		print('Alice ' + str(c))
		continue
	m = min(ord(s[0]), ord(s[-1])) - 96
	c -= m
	if c > m:
		print('Alice ' + str(c - m))
	else:
		print('Bob ' + str(m - c))


for _ in range(int(input())):
	s = input()
	score = 0
	for i in range(len(s)):
		score += ord(s[i]) - 96
	if len(s) == 1:
		print(f'Bob {ord(s[0]) - 96}')
	elif len(s) % 2 == 0:
		print(f'Alice {score}')
	else:
		bob = min(ord(s[0]), ord(s[len(s) - 1])) - 96
		print(f'Alice {score - bob - bob}')


for it in range(int(input())):
	s = input()
	a = [ord(i) - ord('a') + 1 for i in s]
	if len(a) == 1:
		print('Bob', a[0])
	elif len(a) % 2:
		print('Alice', sum(a) - 2 * min(a[0], a[-1]))
	else:
		print('Alice', sum(a))


for t in range(int(input())):
	s = input()
	v = [ord(i) - 96 for i in s]
	if len(v) == 1:
		print('Bob ' + str(v[0]))
	elif len(v) % 2 == 0:
		print('Alice ' + str(sum(v)))
	else:
		print('Alice ' + str(sum(v) - 2 * min(v[0], v[-1])))


trials = int(input())
for trial in range(trials):
	s = input()
	t = 0
	x = 0
	if len(s) > 1:
		if len(s) % 2 == 0:
			for i in range(len(s)):
				t += ord(s[i]) - ord('a') + 1
			x = 0
		elif s[0] > s[-1]:
			for i in range(0, len(s) - 1):
				t += ord(s[i]) - ord('a') + 1
			x = ord(s[-1]) - ord('a') + 1
		else:
			for i in range(1, len(s)):
				t += ord(s[i]) - ord('a') + 1
			x = ord(s[0]) - ord('a') + 1
		print(f'Alice {t - x}')
	else:
		print(f"Bob {ord(s[0]) - ord('a') + 1}")


t = int(input())
for i in range(t):
	s = input()
	l = [ord(i) - 96 for i in s]
	if len(s) % 2 == 0:
		print('Alice', sum(l))
	elif len(s) == 1:
		print('Bob', l[0])
	else:
		n = len(s)
		su = sum(l)
		s1 = su - 2 * l[n - 1]
		s2 = su - 2 * l[0]
		if s1 > s2:
			print('Alice', s1)
		else:
			print('Alice', s2)


for _ in range(int(input())):
	line = input()
	n = len(line)
	if n == 1:
		print(f"Bob {ord(line[-1]) - ord('a') + 1}")
	else:
		total = sum((ord(ch) - ord('a') + 1 for ch in line))
		if n & 1 == 0:
			print(f'Alice {total}')
		else:
			ans = total - 2 * min(ord(line[0]) - ord('a') + 1, ord(line[-1]) - ord('a') + 1)
			print(f'Alice {ans}') if ans > 0 else print(f'Bob {-ans}')


import string
letter = string.ascii_lowercase
for _ in range(int(input())):
	s = input()
	if len(s) % 2 == 0:
		c = 0
		for i in s:
			c += letter.index(i) + 1
		print(f'Alice {c}')
	elif len(s) == 1:
		print('Bob', letter.index(s) + 1)
	else:
		a = letter.index(s[0]) + 1
		b = letter.index(s[-1]) + 1
		if a >= b:
			c = 0
			for i in s[0:-1]:
				c += letter.index(i) + 1
			print(f'Alice {abs(c - b)}')
		else:
			c = 0
			for i in s[1:]:
				c += letter.index(i) + 1
			print(f'Alice {abs(c - a)}')


import math

def get_num(s):
	return ord(s) - 96
for _ in range(int(input())):
	n = input()
	if len(n) == 1:
		print('Bob', get_num(n))
		continue
	sumer = 0
	for i in n:
		sumer += get_num(i)
	if len(n) % 2 == 0:
		print('Alice', sumer)
	else:
		print('Alice', sumer - 2 * min(get_num(n[0]), get_num(n[-1])))


for _ in range(int(input())):
	s = input()
	if len(s) % 2 == 0:
		ans = 0
		for i in s:
			ans += ord(i) - 96
		print('Alice', ans)
	else:
		a = 0
		b = 0
		if s[0] > s[-1]:
			for i in range(len(s) - 1):
				a += ord(s[i]) - 96
			b += ord(s[-1]) - 96
		else:
			for i in range(1, len(s)):
				a += ord(s[i]) - 96
			b += ord(s[0]) - 96
		if a > b:
			print('Alice', a - b)
		else:
			print('Bob', b - a)


def d(a):
	s = 0
	for i in a:
		s += ord(i) - 96
	return s

def f(a):
	n = len(a)
	if n == 1:
		return ('Bob', ord(a[0]) - 96)
	if n % 2 == 0:
		return ('Alice', d(a))
	if ord(a[0]) < ord(a[-1]):
		return ('Alice', d(a) - 2 * (ord(a[0]) - 96))
	return ('Alice', d(a) - 2 * (ord(a[-1]) - 96))
t = int(input())
for i in range(t):
	s = input()
	(st, c) = f(s)
	print('{} {}'.format(st, c))


def getAns(t: int):
	s = input()
	base = ord('a') - 1
	if len(s) == 1:
		print('Bob {}'.format(ord(s[0]) - base))
	else:
		sm = 0
		for i in range(len(s)):
			sm += ord(s[i]) - base
		if len(s) % 2 == 1:
			sm -= min(ord(s[0]) - base, ord(s[-1]) - base) * 2
		print('Alice {}'.format(sm))
t = int(input())
for i in range(t):
	getAns(i)


t = int(input())

def code(c):
	return ord(c) - 96

def codes(s):
	return sum([code(c) for c in s])
for i in range(t):
	s = input()
	if len(s) == 1:
		print(f'Bob {code(s)}')
	elif len(s) % 2 == 0:
		print(f'Alice {sum([code(c) for c in s])}')
	elif codes(s[0:-1]) > codes(s[1:]):
		print(f'Alice {codes(s[0:-1]) - code(s[-1])}')
	else:
		print(f'Alice {codes(s[1:]) - code(s[0])}')


def solve():
	s = input()
	if len(s) == 1:
		print('Bob', ord(s[0]) - ord('a') + 1)
	else:
		sum = 0
		for x in s:
			sum += ord(x) - ord('a') + 1
		if len(s) % 2:
			sum = sum - 2 * ((ord(s[-1]) if s[-1] < s[0] else ord(s[0])) - ord('a') + 1)
		print('Alice', sum)
for t in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	s = input()
	le = len(s)
	tsum = 0
	for i in s:
		tsum += ord(i) - 96
	if le % 2 == 0:
		print('Alice', tsum)
	elif le == 1:
		print('Bob', tsum)
	else:
		fir = ord(s[0]) - 96
		la = ord(s[-1]) - 96
		ans = min(2 * fir, 2 * la)
		print('Alice', tsum - ans)


for _ in range(int(input())):
	s = input()
	n = len(s)
	if n == 1:
		print('Bob', ord(s[0]) - 96)
	else:
		total = 0
		for i in s:
			total += ord(i) - 96
		if n % 2 == 0:
			print('Alice', total)
		else:
			if ord(s[0]) > ord(s[-1]):
				tmp = ord(s[-1]) - 96
			else:
				tmp = ord(s[0]) - 96
			print('Alice', total - 2 * tmp)


for _ in range(int(input())):
	string = input()
	li = []
	for i in string:
		li.append(ord(i) - 96)
	if len(li) % 2 == 0:
		print('Alice', sum(li))
	elif len(li) > 1:
		print('Alice', sum(li) - 2 * min(li[0], li[-1]))
	else:
		print('Bob', sum(li))


import sys

def main():
	T = int(input())
	for tr in range(1, T + 1):
		ans = solve()
		print(ans)

def solve():
	st = input()
	p = calc_power(st)
	if len(st) % 2 == 0:
		return 'Alice ' + str(p)
	else:
		if len(st) == 1:
			prefix = 'Bob '
		else:
			prefix = 'Alice '
		return prefix + str(abs(p - 2 * (min(ord(st[0]), ord(st[-1])) - ord('a') + 1)))
	return ' '.join((str(s) for s in res))

def calc_power(s):
	return sum([ord(c) - ord('a') + 1 for c in s])

def eprint(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)
main()


def main():
	t = int(input())
	for k in range(t):
		s = input()
		(alice, bob) = ('', '')
		if len(s) == 1:
			print(f'Bob {ord(s[0]) - 96}')
		else:
			if len(s) % 2 == 1:
				if ord(s[0]) > ord(s[len(s) - 1]):
					alice = s[0:len(s) - 1]
					bob = s[len(s) - 1]
				else:
					alice = s[1:len(s)]
					bob = s[0]
			if len(s) % 2 == 0:
				alice = s
			(sc_alice, sc_bob) = (0, 0)
			for i in range(len(alice)):
				sc_alice += ord(alice[i]) - 96
			for i in range(len(bob)):
				sc_bob += ord(bob[i]) - 96
			if sc_alice > sc_bob:
				print(f'Alice {sc_alice - sc_bob}')
			else:
				print(f'Bob {sc_bob - sc_alice}')
main()


def solve(s):
	if len(s) == 1:
		print('Bob', ord(s[0]) - 96)
		return
	if len(s) % 2 == 0:
		result = 0
		for i in range(len(s)):
			result += ord(s[i]) - 96
		print('Alice', result)
		return
	aScore = 0
	bScore = 0
	for i in range(1, len(s) - 1):
		aScore += ord(s[i]) - 96
	if s[0] < s[-1]:
		aScore += ord(s[-1]) - 96
		bScore = ord(s[0]) - 96
	else:
		aScore += ord(s[0]) - 96
		bScore = ord(s[-1]) - 96
	if bScore > aScore:
		print('Bob', bScore - aScore)
		return
	else:
		print('Alice', aScore - bScore)
	return
t = int(input())
for x in range(t):
	s = input()
	solve(s)


from re import X

def real_value(c):
	return ord(c) - ord('a') + 1

def main():
	for i in range(int(input())):
		bob = alice = 0
		s = input()
		if len(s) == 1:
			print('Bob ' + str(real_value(s)))
		elif not len(s) % 2:
			for c in s:
				alice += real_value(c)
			print('Alice ' + str(alice))
		else:
			bob = real_value(s[-1]) if s[0] > s[-1] else real_value(s[0])
			for c in s:
				alice += real_value(c)
			alice -= bob
			if bob > alice:
				print('Bob ' + str(bob - alice))
			else:
				print('Alice ' + str(alice - bob))
main()


t = int(input())
for _ in range(0, t):
	s = input()
	len1 = len(s)
	s1 = 0
	s2 = 0
	if len1 % 2 == 0:
		for i in range(0, len1):
			s1 += ord(s[i]) - 96
	elif len1 == 1:
		s2 = ord(s[0]) - 96
	else:
		pos1 = ord(s[0]) - 96
		pos2 = ord(s[len1 - 1]) - 96
		if pos1 >= pos2:
			for i in range(0, len1 - 1):
				s1 += ord(s[i]) - 96
			s2 = ord(s[len1 - 1]) - 96
		else:
			for i in range(1, len1):
				s1 += ord(s[i]) - 96
			s2 = ord(s[0]) - 96
	if s1 > s2:
		print(f'Alice {s1 - s2}')
	else:
		print(f'Bob {s2 - s1}')


T = int(input())
while T:
	s = input()
	if len(s) == 1:
		print('Bob ', ord(s) - ord('a') + 1)
		T = T - 1
		continue
	value = 0
	for ch in s:
		value += ord(ch) - ord('a') + 1
	if len(s) % 2 == 0:
		print('Alice ', value)
	else:
		(f, s) = (s[0], s[-1])
		if ord(f) >= ord(s):
			print('Alice ', value - (1 + ord(s) - ord('a')) * 2)
		else:
			print('Alice ', value - (1 + ord(f) - ord('a')) * 2)
	T = T - 1


t = int(input())
for i in range(t):
	s = input()
	sum = 0
	bob = 0
	flag = False
	if len(s) % 2 == 0:
		for j in s:
			sum = ord(j) - 96 + sum
			flag = False
	elif len(s) == 1:
		bob = ord(s) - 96
		flag = True
	elif len(s) % 2 == 1:
		if ord(s[0]) >= ord(s[len(s) - 1]):
			x = s[len(s) - 1]
			s = s[0:len(s) - 1]
			for j in s:
				sum = ord(j) - 96 + sum
			if sum > ord(x) - 96:
				flag = False
				bob = ord(x) - 96
			else:
				flag = True
				bob = ord(x) - 96
		else:
			x = s[0]
			s = s[1:len(s)]
			for j in s:
				sum = ord(j) - 96 + sum
			if sum > ord(x) - 96:
				flag = False
				bob = ord(x) - 96
			else:
				flag = True
				bob = ord(x) - 96
	sum = abs(sum - bob)
	if flag == False:
		ans = 'Alice'
	else:
		ans = 'Bob'
	print(ans + ' ' + str(sum))


def get(s):
	a = 0
	h = ord('a') - 1
	for i in s:
		a += ord(i) - h
	return a
for _ in range(int(input())):
	s = input()
	a = 0
	h = ord('a') - 1
	if len(s) == 1:
		print('Bob', ord(s[0]) - h)
		continue
	elif len(s) & 1:
		print('Alice', max(get(s[:-1]) - ord(s[-1]) + h, get(s[1:]) - ord(s[0]) + h))
	else:
		print('Alice', get(s))


N = int(input())
az = [chr(i) for i in range(97, 123)]
d = dict()
for i in range(len(az)):
	d[az[i]] = i + 1
for i in range(N):
	n = input()
	(a, b) = (0, 0)
	if len(n) % 2:
		t = 0
		for i in range(len(n) - 1):
			t += d[n[i]]
		for i in range(1, len(n)):
			a += d[n[i]]
		if a > t:
			b += d[n[0]]
		else:
			b += d[n[len(n) - 1]]
			a = t
	else:
		for i in range(len(n)):
			a += d[n[i]]
	if a > b:
		print('Alice ' + str(a - b))
	else:
		print('Bob ' + str(b - a))


import string
dic = dict(zip(string.ascii_lowercase, range(1, 27)))
t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	val_1 = 0
	val_2 = 0
	Alice = 0
	Bob = 0
	if len(s) == 1:
		print(f'Bob {dic[s]}')
	else:
		if n % 2 == 0:
			for l in s:
				Alice += dic[l]
		else:
			s1 = s[0:n - 1]
			s2 = s[1:n]
			for l in s1:
				val_1 += dic[l]
			for l in s2:
				val_2 += dic[l]
			if val_1 > val_2:
				Alice = val_1
				Bob = dic[s[n - 1]]
			else:
				Alice = val_2
				Bob = dic[s[0]]
		if Alice > Bob:
			print(f'Alice {Alice - Bob}')
		else:
			print(f'Bob {Bob - Alice}')


try:
	t = int(input())
except EOFError as e:
	exit()
while t > 0:
	alpha = input()
	alpha_list = list(alpha)
	n = len(alpha_list)
	if n % 2 == 0:
		difference = 0
		for i in alpha_list:
			difference += ord(i) - 96
		print('Alice ' + str(difference))
	else:
		alice = 0
		if n == 1:
			print('Bob ' + str(ord(alpha_list[0]) - 96))
		if ord(alpha_list[0]) > ord(alpha_list[-1]):
			for i in range(len(alpha_list) - 1):
				alice += ord(alpha_list[i]) - 96
			alice -= ord(alpha_list[-1]) - 96
			print('Alice ' + str(alice))
		if ord(alpha_list[0]) < ord(alpha_list[-1]):
			for i in range(1, len(alpha_list)):
				alice += ord(alpha_list[i]) - 96
			alice -= ord(alpha_list[0]) - 96
			print('Alice ' + str(alice))
		if not n == 1 and ord(alpha_list[0]) == ord(alpha_list[-1]):
			for i in range(1, len(alpha_list)):
				alice += ord(alpha_list[i]) - 96
			alice -= ord(alpha_list[0]) - 96
			print('Alice ' + str(alice))
	t -= 1


def sumPos(s):
	sum = 0
	for i in range(len(s)):
		sum = sum + (ord(s[i]) - 96)
	return sum
n = int(input())
for i in range(n):
	s = input()
	l = len(s)
	if len(s) % 2 == 0:
		diff = sumPos(s)
		print('Alice {}'.format(diff))
	elif l == 1:
		diff = sumPos(s)
		print('Bob {}'.format(diff))
	elif sumPos(s[:l - 1]) > sumPos(s[1:]):
		diff = sumPos(s[:l - 1]) - sumPos(s[l - 1])
		print('Alice {}'.format(diff))
	else:
		diff = sumPos(s[1:]) - sumPos(s[0])
		print('Alice {}'.format(diff))


def sumOfString(string):
	sum = 0
	for c in string:
		sum += ord(c)
	sum = sum - 96 * len(string)
	return sum

def solve():
	s = input()
	if len(s) == 1:
		print('Bob', ord(s) - 96)
	elif len(s) % 2 == 0:
		print('Alice', sumOfString(s))
	else:
		if ord(s[0]) >= ord(s[len(s) - 1]):
			s1 = s[0:len(s) - 1]
			s2 = s[len(s) - 1]
		else:
			s1 = s[1:len(s)]
			s2 = s[0]
		print('Alice', sumOfString(s1) - ord(s2) + 96)
t = int(input())
while t:
	solve()
	t -= 1


n = int(input())
while n > 0:
	s = input()
	p = 0
	for i in range(len(s)):
		p = p + ord(s[i]) - 96
	if len(s) % 2 == 0:
		print('Alice', p)
	else:
		if len(s) == 1:
			print('Bob', p)
			n = n - 1
			continue
		if ord(s[0]) > ord(s[len(s) - 1]):
			print('Alice', p - 2 * (ord(s[len(s) - 1]) - 96))
		else:
			print('Alice', p - 2 * (ord(s[0]) - 96))
	n = n - 1


def winner(strin):
	alpha = list()
	for i in strin:
		alpha.append(ord(i) - 96)
	length = len(alpha)
	if length == 1:
		res = 'Bob ' + str(alpha[0])
		print(res)
		return
	elif length & 1 == 0:
		res = 'Alice ' + str(sum(alpha))
		print(res)
		return
	else:
		bob = min(alpha[0], alpha[length - 1])
		alice = max(alpha[0], alpha[length - 1])
		alice += sum(alpha[1:length - 1])
		if alice > bob:
			res = 'Alice ' + str(alice - bob)
			print(res)
			return
		else:
			res = 'Bob ' + str(bob - alice)
numberOfRounds = int(input())
for _ in range(numberOfRounds):
	s = input()
	winner(s)