Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).

Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the chip is currently in the cell i, the player can move it into cell i - 1, i - 2 or i - k). The chip should not leave the borders of the paper strip: it is impossible, for example, to move it k cells to the left if the current cell has number i < k. The player who can't make a move loses the game.

Who wins if both participants play optimally?

Alice and Bob would like to play several games, so you should determine the winner in each game.


-----Input-----

The first line contains the single integer T (1 ≤ T ≤ 100) — the number of games. Next T lines contain one game per line. All games are independent.

Each of the next T lines contains two integers n and k (0 ≤ n ≤ 10^9, 3 ≤ k ≤ 10^9) — the length of the strip and the constant denoting the third move, respectively.


-----Output-----

For each game, print Alice if Alice wins this game and Bob otherwise.


-----Example-----
Input
4
0 3
3 3
3 4
4 4

Output
Bob
Alice
Bob
Alice

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Game theory

Mathematics


Solutions:
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % 3 != 0:
		print('Bob' if n % 3 == 0 else 'Alice')
	else:
		n = n % (k + 1)
		if n == k:
			print('Alice')
		else:
			print('Bob' if n % 3 == 0 else 'Alice')


T = int(input())
Query = [list(map(int, input().split())) for _ in range(T)]
for (N, K) in Query:
	if K % 3 != 0:
		if N % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		A = K // 3 - 1
		cycle = 3 * A + 4
		N %= cycle
		if N % 3 == 0 and N != cycle - 1:
			print('Bob')
		else:
			print('Alice')


import sys
Q = int(input())

def check(N, k):
	if k % 3:
		return N % 3 == 0
	if N % (k + 1) == k:
		return False
	return N % (k + 1) % 3 == 0
for _ in range(Q):
	(N, k) = map(int, sys.stdin.readline().split())
	if check(N, k):
		print('Bob')
	else:
		print('Alice')


import sys
import math

def get_num():
	return int(input())

def get_numbers():
	return map(int, input().split())

def get_numbers_list():
	return list(get_numbers())

def solve(n, k):
	if k % 3 == 0:
		if n % (k + 1) != k and n % (k + 1) % 3 == 0:
			return 'Bob'
		return 'Alice'
	if n % 3 == 0:
		return 'Bob'
	return 'Alice'

def main():
	q = get_num()
	for _ in range(q):
		(n, k) = get_numbers()
		print(solve(n, k))
main()


def find(n, k):
	if k % 3 != 0:
		if n % 3 == 0:
			return 'Bob'
		else:
			return 'Alice'
	position = n % (k + 1)
	if position == k:
		return 'Alice'
	if position % 3 == 0:
		return 'Bob'
	else:
		return 'Alice'
ans = []
for _ in range(int(input())):
	(n, k) = list(map(int, input().strip().split(' ')))
	ans += [find(n, k)]
print('\n'.join(ans))


from math import ceil

def solve(n, k):
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		l = n % (k + 1)
		if l == k:
			print('Alice')
		elif l % 3 == 0:
			print('Bob')
		else:
			print('Alice')
for _ in range(int(input().strip())):
	(n, k) = map(int, input().strip().split())
	solve(n, k)


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

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

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = True
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	(n, k) = get_tuple()
	if k % 3 != 0:
		print('Alice') if n % 3 != 0 else print('Bob')
	else:
		mod = n % (k + 1)
		print('Bob') if mod % 3 == 0 and mod < k else print('Alice')
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


def Game(n, k):
	if k % 3 != 0:
		return [1, 0, 0][n % 3]
	else:
		n %= k + 4
		if n == k + 3:
			return 0
		else:
			return [1, 0, 0][n % 3]
for i in range(int(input())):
	(N, K) = map(int, input().split())
	print(['Alice', 'Bob'][Game(N, K - 3)])


def main():
	q = int(input())
	while q > 0:
		q -= 1
		line = input().split()
		n = int(line[0])
		k = int(line[1])
		if k % 3 != 0:
			if n % 3 != 0:
				print('Alice')
			else:
				print('Bob')
			continue
		k -= 2
		lo = 1
		hi = n / k + 2
		pos = -1
		while lo <= hi:
			mid = (lo + hi) // 2
			last = mid * k + (mid - 1) * 3 - 1
			last = last - k + 1
			if last <= n:
				pos = mid
				lo = mid + 1
			else:
				hi = mid - 1
		R = pos * k + (pos - 1) * 3 - 1
		L = R - k + 1
		if n > R:
			print('Alice')
		elif (n - L) % 3 != 0:
			print('Alice')
		else:
			print('Bob')
main()


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	win = True
	if k % 3 == 0:
		np = n % (k + 1)
		if np % 3 == 0 and np != k:
			win = False
	elif n % 3 == 0:
		win = False
	print('Alice' if win else 'Bob')


for nt in range(int(input())):
	(n, k) = map(int, input().split())
	flag = 0
	if k % 3 == 0:
		x = n % (k + 1)
		if x % 3 == 0 and x != k:
			flag = 1
	else:
		x = n % 3
		if x == 0:
			flag = 1
	if flag:
		print('Bob')
	else:
		print('Alice')


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	if k % 3 == 0:
		y = n % (k + 1)
		if y % 3 == 0 and y != k:
			print('Bob')
		else:
			print('Alice')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


for _ in range(int(input())):
	(n, k) = [*map(int, input().split())]
	if k % 3 != 0:
		loss = n % 3 == 0
	else:
		cycle_length = (k // 3 - 1) * 3 + 4
		n = n % cycle_length
		loss = n % 3 == 0 and n != cycle_length - 1
	print('Bob' if loss else 'Alice')


import sys
from collections import defaultdict
input = sys.stdin.readline

def main():
	q = int(input())
	for _ in range(q):
		(n, k) = map(int, input().split())
		if k % 3 != 0:
			print('Bob' if n % 3 == 0 else 'Alice')
		else:
			x = n % (k + 1)
			if x == k:
				print('Alice')
			else:
				print('Bob' if x % 3 == 0 else 'Alice')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k % 3 == 0:
		if n % (k + 1) == 0 or (n % (k + 1) % 3 == 0 and n % (k + 1) != k):
			print('Bob')
		else:
			print('Alice')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n < k:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif n == k:
		print('Alice')
	elif k == 3:
		if n % 4 == 0:
			print('Bob')
		else:
			print('Alice')
	elif k % 3 == 0:
		if n % (k + 1) == k:
			print('Alice')
		elif n % (k + 1) % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


t = int(input())
for i in range(1, t + 1, 1):
	(a, b) = map(int, input().split())
	x = b % 3
	y = b + 1
	z = a % y
	k = z % 3
	if x != 0:
		if a % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif k != 0 or z == b:
		print('Alice')
	else:
		print('Bob')


from sys import stdin
c = int(stdin.readline().strip())
for i in range(c):
	(n, m) = list(map(int, stdin.readline().strip().split()))
	if n == 0:
		print('Bob')
		continue
	if m % 3 == 0:
		n = n % (m + 1)
		if (n == 0 or n % 3 == 0) and n != m:
			print('Bob')
		else:
			print('Alice')
		continue
	if n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


from math import ceil
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	if K % 3 == 0:
		row = N // 3 % (K + 1)
		if row == K:
			print('Alice')
		elif row // (K // 3) == N % 3:
			print('Bob')
		else:
			print('Alice')
	elif N % 3 == 0:
		print('Bob')
	else:
		print('Alice')


class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def main():
	(n, k) = Read.list_int()
	if n == k or n == 2 or n == 1:
		print('Alice')
		return
	elif n == 0 or n == 3:
		print('Bob')
		return
	elif k % 3 == 0:
		n %= k + 1
		if n == k or n % 3 > 0:
			print('Alice')
		else:
			print('Bob')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')
q = Read.int()
for j in range(q):
	main()


def f():
	print('Alice' if n % 3 else 'Bob')
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k % 3:
		f()
	else:
		n %= k + 1
		if n > k - 3:
			print('Alice')
		else:
			f()


import sys, math, queue, bisect
MOD = 998244353
sys.setrecursionlimit(1000000)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k % 3 != 0:
		print('Bob' if n % 3 == 0 else 'Alice')
	else:
		n = n % (k + 1)
		print('Bob' if n % 3 == 0 and n != k else 'Alice')


import math
T = int(input())
for i in range(0, T):
	(n, k) = map(int, input().split())
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		m = k // 3
		y = n - n // (3 * m + 1)
		x2 = math.ceil((y // 3 + 1) / m) - 1
		if y % 3 != 0:
			print('Alice')
		elif y + x2 == n:
			print('Bob')
		else:
			print('Alice')


import sys
from collections import Counter
import itertools

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

def dinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rt(e, t):
	return (e + 1) * (t - e)

def main():
	(n, k) = rinput()
	if k % 3 == 0:
		t = n % (k + 1)
		if t % 3 == 0 and t != k:
			print('Bob')
			return 0
		print('Alice')
	else:
		if n % 3 == 0:
			print('Bob')
			return 0
		print('Alice')
for i in range(int(input())):
	main()


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	if k % 3:
		if n % 3:
			print('Alice')
		else:
			print('Bob')
	else:
		loop = k + 1
		idx = n % loop
		if idx == k:
			print('Alice')
		elif idx % 3:
			print('Alice')
		else:
			print('Bob')


import sys
sys.setrecursionlimit(100500)

def grundy(n, k):
	if n == 1:
		return 0
	s = set([grundy(n - 1, k)])
	if n >= 3:
		s.add(grundy(n - 2, k))
	if n >= k + 1:
		s.add(grundy(n - k, k))
	for i in range(10):
		if i not in s:
			return i

def g(n, k):
	if k % 3 > 0:
		return n % 3
	p = k // 3 * 3 + 1
	n %= p
	if n == p - 1:
		return 3
	if n == p - 2:
		return 2
	if n == p - 3:
		return 1
	if n == p - 4:
		return 0
	return n % 3
T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	if g(n, k) != 0:
		print('Alice')
	else:
		print('Bob')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	(n, k) = map(int, input().split())
	if k == n:
		print('Alice')
	elif k < n:
		if k % 3 == 0:
			count = k // 3
			if n % (k + 1) == 0 or (n % (k + 1) % 3 == 0 and n % (k + 1) // 3 < count):
				print('Bob')
			else:
				print('Alice')
		elif n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	if k == 3:
		print('Bob' if n % 4 == 0 else 'Alice')
	elif k % 3:
		print('Bob' if n % 3 == 0 else 'Alice')
	else:
		d = n // k % 3
		print('Bob' if n % (k + 1) < k and n % (k + 1) % 3 == 0 else 'Alice')


t = int(input())
for x in range(t):
	(n, k) = list(map(int, input().split()))
	if k % 3 != 0:
		n = n + 1
		if n % 3 == 1:
			print('Bob')
		else:
			print('Alice')
	else:
		m = (n + 1) % (4 + 3 * (k // 3 - 1))
		if m == 0:
			print('Alice')
		elif m <= 3 * (k // 3 - 1):
			r = m % 3
			if r == 1:
				print('Bob')
			else:
				print('Alice')
		elif m == 1 + 3 * (k // 3 - 1):
			print('Bob')
		else:
			print('Alice')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 3:
		if not n % 4:
			print('Bob')
		else:
			print('Alice')
		continue
	if k % 3:
		if not n % 3:
			print('Bob')
		else:
			print('Alice')
	else:
		n = n % (k + 1)
		if not n % 3 and n != k:
			print('Bob')
		else:
			print('Alice')


import io, sys
input = lambda f=io.StringIO(sys.stdin.buffer.read().decode()).readline: f().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
out = []
for _ in range(ii()):
	(n, k) = mi()
	if k % 3 or n < k:
		win = n % 3
	else:
		n %= k + 1
		win = n % 3 or n == k
	out.append('Alice' if win else 'Bob')
print(*out, sep='\n')


Q = int(input())
for q in range(Q):
	(n, m) = map(int, input().split())
	if m % 3 == 0 and n >= m:
		n %= m + 1
	if n % 3 or n == m:
		print('Alice')
	else:
		print('Bob')


import sys, os

def Solve(n, k):
	if n == k or n == 1 or n == 2:
		return 1
	if n == 0:
		return 0
	if k > n or k % 3 != 0:
		return n % 3 != 0
	return n % (k + 1) % 3 != 0 or n % (k + 1) == k
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print('Alice' if Solve(n, k) else 'Bob')


w = int(input())
for i in range(w):
	(a, b) = list(map(int, input().split()))
	a += 1
	if b % 3 != 0:
		if a % 3 == 1:
			print('Bob')
		else:
			print('Alice')
	elif a % (b + 1) % 3 == 1:
		print('Bob')
	else:
		print('Alice')


import sys

def rl(proc=None):
	if proc is not None:
		return proc(sys.stdin.readline())
	else:
		return sys.stdin.readline().rstrip()

def srl(proc=None):
	if proc is not None:
		return list(map(proc, rl().split()))
	else:
		return rl().split()

def solve(n, k):
	if k % 3:
		return n % 3
	n = n % (k + 1)
	if n == k:
		return 1
	return n % 3

def main():
	T = rl(int)
	for t in range(1, T + 1):
		(n, k) = srl(int)
		print('Alice' if solve(n, k) else 'Bob')
main()


import sys
t = int(input())
for ti in range(t):
	(n, k) = map(int, input().split())
	if n == 0:
		print('Bob')
	elif n < k:
		print('Alice' if n % 3 != 0 else 'Bob')
	elif n == k:
		print('Alice')
	elif k % 3 == 0:
		np = n % (k + 1)
		if np % 3 == 0 and np != k:
			print('Bob')
		else:
			print('Alice')
	else:
		np = n % 3
		print('Alice' if np != 0 else 'Bob')


from sys import stdin
T = int(stdin.readline())
for _ in range(T):
	(n, k) = [int(x) for x in stdin.readline().split()]
	if k % 3 == 1:
		w = k + 2
	else:
		w = k + 1
	n_mod_w = n % w
	if n_mod_w % 3 in {1, 2} or n_mod_w == k:
		print('Alice')
	else:
		print('Bob')


def solve(n, k):
	if k % 3 != 0:
		return n % 3 != 0
	else:
		n = n % (k + 1)
		if n == k:
			return True
		else:
			return n % 3 != 0
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	ans = solve(n, k)
	if ans:
		print('Alice')
	else:
		print('Bob')


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		n = n % (k + 1)
		if n == k:
			print('Alice')
		elif n % 3 == 0:
			print('Bob')
		else:
			print('Alice')


ans = ['Bob', 'Alice']
for q in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	if n <= 1:
		print(ans[n])
		continue
	if k % 3 == 0:
		mod = k + 1
		nb = n % mod
		if nb == k:
			n = 1
		elif nb % 3 == 0:
			n = 0
		else:
			n = 1
	if n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


T = int(input())
while T:
	T -= 1
	str = list(map(int, input().split()))
	n = str[0]
	k = str[1]
	if k % 3 != 0:
		print('Bob' if n % 3 == 0 else 'Alice')
	else:
		n = n % (k + 1)
		if n == k or n % 3 != 0:
			print('Alice')
		else:
			print('Bob')


def game(n, k):
	if not k % 3:
		if n % (k + 1) % 3 == 0 and n % (k + 1) != k:
			return False
	elif not n % 3:
		return False
	return True
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if game(n, k):
		print('Alice')
	else:
		print('Bob')


def test(n, k):
	if k % 3 == 0:
		n = n % (k + 1)
		if n != k and n % 3 == 0:
			return 2
		return 1
	if n % 3 == 0:
		return 2
	return 1
t = int(input())
x = []
for i in range(t):
	(n, k) = map(int, input().split())
	if test(n, k) == 1:
		x += ['Alice']
	else:
		x += ['Bob']
for i in x:
	print(i)


from sys import stdin
read = stdin.readline

def test(n, k):
	DP = ['B'] * (n + 1)
	for i in range(n + 1):
		if DP[i] == 'B':
			if i + 1 <= n:
				DP[i + 1] = 'A'
			if i + 2 <= n:
				DP[i + 2] = 'A'
			if i + k <= n:
				DP[i + k] = 'A'
	return ''.join(DP)
T = int(read())
for t in range(T):
	(n, k) = map(int, read().split())
	if k % 3:
		if n % 3:
			print('Alice')
		else:
			print('Bob')
	else:
		n = n % (k + 1)
		if n == k or n % 3:
			print('Alice')
		else:
			print('Bob')


t = int(input())

def main():
	(n, k) = [int(x) for x in input().split()]
	c = d = 0
	if k % 3 == 0:
		c = n % (k + 1)
		if c == 0 or (c != k and c % 3 == 0):
			print('Bob')
		else:
			print('Alice')
	else:
		d = n % 3
		if d == 0:
			print('Bob')
		else:
			print('Alice')
while t > 0:
	main()
	t -= 1


def mp():
	return map(int, input().split())
q = int(input())
for qq in range(q):
	(n, k) = mp()
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif (n - n // (k + 1)) % 3 == 0 and (n % k + (n % k + 1) * k) % (k * (k + 1)) != n % (k * (k + 1)):
		print('Bob')
	else:
		print('Alice')


def Grundy(N):
	return -1
T = int(input())
for _ in range(T):
	s = input().rstrip().split()
	n = int(s[0])
	k = int(s[1])
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		v = n // (k + 1)
		start_cycle = (k + 1) * v
		if (n - start_cycle) % 3 == 0 and n - start_cycle != k:
			print('Bob')
		else:
			print('Alice')


l = int(input())
osy = 0
for i in range(l):
	(n, k) = map(int, input().split())
	if n < k:
		osy = n % 3
		if osy == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		prom = k - 1
		if prom % 3 == 2:
			if n % (k + 1) == k:
				print('Alice')
			elif (n - k) % (k + 1) % 3 == 1:
				print('Bob')
			else:
				print('Alice')
		else:
			osy = n % 3
			if osy == 0:
				print('Bob')
			else:
				print('Alice')


T = int(input())
for i in range(1, T + 1):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	if n == 0:
		print('Bob')
	elif k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		temp = n % (k + 1)
		if (temp + 1) % (k + 1) == 0:
			print('Alice')
		elif temp % 3 != 0:
			print('Alice')
		else:
			print('Bob')


import sys
import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		n += 1
		n = n % (k + 1)
		if n % 3 == 1:
			print('Bob')
		else:
			print('Alice')


q = int(input())
for query in range(q):
	(n, k) = map(int, input().split())
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		n = n % (k + 1)
		if n == k:
			print('Alice')
		elif n % 3 == 0:
			print('Bob')
		else:
			print('Alice')


res = []
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = k % 3 == 0
	y = n % 3 == 0
	z = n % (k + 1) != k
	w = n % (k + 1) % 3 == 0
	if not x and y or (x and z and w):
		res.append('Bob')
	else:
		res.append('Alice')
print('\n'.join(res))


T = int(input())
for i in range(T):
	(n, k) = list(map(int, input().split()))
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		quotient = k + 1
		remainder = n % quotient
		if remainder % 3 == 0 and remainder != k:
			print('Bob')
		else:
			print('Alice')


q = int(input())
for i in range(q):
	ints = [int(x) for x in input().split()]
	n = ints[0]
	k = ints[1]
	if k % 3 == 0:
		if n % (k + 1) % 3 != 0 or n % (k + 1) == k:
			print('Alice')
		else:
			print('Bob')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 7)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))

def main():
	t = iin()
	ans = ['Bob', 'Alice']
	while t:
		t -= 1
		(n, k) = lin()
		win = 1
		if k % 3 == 0:
			ch = n % (k + 1)
			if ch % 3 == 0 and ch != k:
				win = 0
		else:
			ch = n % 3
			if ch == 0:
				win = 0
		print(ans[win])
main()


t = int(input())

def solve(n, k):
	if k % 3 != 0:
		return n % 3
	elif n % (k + 1) == k:
		return 3
	else:
		return n % (k + 1) % 3
for _ in range(t):
	(n, k) = map(int, input().split())
	if solve(n, k):
		print('Alice')
	else:
		print('Bob')


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	if k % 3 != 0 or k > n:
		print('Bob' if n % 3 == 0 else 'Alice')
	else:
		print('Bob' if n % (k + 1) % 3 == 0 and n % (k + 1) != k else 'Alice')


def multiset(lst):
	dct = {}
	lst = list(lst)
	for i in lst:
		if i not in dct:
			dct[i] = 0
		dct[i] += 1
	if 0 not in dct:
		dct[0] = 0
	if 1 not in dct:
		dct[1] = 0
	return dct

def judge(k, n):
	lst = [None] * (n + 1)
	lst[0] = 1
	for i in range(1, n + 1):
		chk = set()

		def check(d):
			if i >= d and lst[i - d] == 1:
				chk.add(0)
			if i >= d and lst[i - d] == 0:
				chk.add(1)
		check(1)
		check(2)
		check(k)
		chk = multiset(chk)
		jdg = 2
		if chk[0] > 0:
			jdg = 0
		else:
			jdg = 1
		lst[i] = jdg
	print('   '.join(('(%d, %d)' % (i, lst[i]) for i in range(0, n + 1))))
	print(lst)
	return

def main():
	T = int(input())
	for _ in range(0, T):
		(n, k) = map(int, input().split(' '))
		result = 0
		if k % 3 != 0:
			if n % 3 == 0:
				result = 1
		else:
			rem = n % (k + 1)
			if rem != k and rem % 3 == 0:
				result = 1
		print('Alice' if result == 0 else 'Bob')
	return
main()


def alice():
	print('Alice')

def bob():
	print('Bob')
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % 3 == 0:
		new_n = n % (k + 1)
		if new_n % 3 == 0 and new_n != k:
			bob()
		else:
			alice()
	elif n % 3 == 0:
		bob()
	else:
		alice()


from sys import stdin, stdout
from collections import Counter

def rsingle_int():
	return int(stdin.readline().rstrip())

def rmult_int():
	return [int(x) for x in stdin.readline().rstrip().split()]

def rmult_str():
	return stdin.readline().rstrip().split()

def r_str():
	return stdin.readline().rstrip()

def rsingle_char():
	return stdin.read(1)

def main():
	q = rsingle_int()
	for q in range(q):
		(n, k) = rmult_int()
		code_k = k % 3
		if code_k != 0:
			code_n = (n + 1) % 3
			if code_n == 0 or code_n == 2:
				print('Alice')
			else:
				print('Bob')
		else:
			code_n_k = (n + 1) % (k + 1)
			if code_n_k == 0:
				print('Alice')
			else:
				code_n = code_n_k % 3
				if code_n == 0 or code_n == 2:
					print('Alice')
				else:
					print('Bob')
main()


import sys
import math
from collections import defaultdict, deque
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		x = k + 1
		a = n % x
		if a % 3 != 0 or a == k:
			print('Alice')
		else:
			print('Bob')


tc = int(input())
while tc > 0:
	tc -= 1
	(a, b) = [int(x) for x in input().split()]
	if b % 3 != 0:
		if a % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		a = a % (b + 1)
		if a == b:
			print('Alice')
		elif a % 3 == 0:
			print('Bob')
		else:
			print('Alice')


n = int(input())
for i in range(n):
	(m, k) = map(int, input().split())
	if m == 0:
		print('Bob')
	else:
		if k % 3 == 0:
			m %= k + 1
		if m != k and m % 3 == 0:
			print('Bob')
		else:
			print('Alice')


def solve():
	(n, k) = map(int, input().split())
	if k % 3:
		if n % 3:
			return 'Alice'
		return 'Bob'
	if n % (k + 1) == k:
		return 'Alice'
	if n % (k + 1) % 3:
		return 'Alice'
	return 'Bob'
q = int(input())
for _ in range(q):
	print(solve())


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	if k % 3 == 0:
		t = k + 1
		r = n % t
		if r < t - 1:
			ans = r % 3 > 0
		else:
			r1 = (r - k) % 3
			ans = r % 3 > 0 or r1 == 0
	else:
		ans = n % 3 > 0
	print('Alice' if ans else 'Bob')


from sys import stdin, stdout
import collections
import math

def minimax(number, K, turn):
	if number == 0:
		if turn == 'A':
			return -1
		else:
			return 1
	else:
		if turn == 'B':
			alpha = 9999999
			for minus in [1, 2, K]:
				if minus <= number:
					alpha = min(alpha, minimax(number - minus, K, 'A'))
		elif turn == 'A':
			alpha = -9999999
			for minus in [1, 2, K]:
				if minus <= number:
					alpha = max(alpha, minimax(number - minus, K, 'B'))
		return alpha
T = int(input())
for t in range(T):
	(N, K) = [int(x) for x in stdin.readline().split()]
	if K % 3 != 0:
		if N % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		d = K + 1
		mod = N % d
		if mod % 3 == 0 and mod != K:
			print('Bob')
		else:
			print('Alice')


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if k % 3 != 0:
		d = (n + 1) % 3
		if d != 1:
			print('Alice')
		else:
			print('Bob')
	elif n == 0:
		print('Bob')
	else:
		d = n % (k + 1)
		if d == k:
			print('Alice')
		elif d % 3 == 0:
			print('Bob')
		else:
			print('Alice')


import sys
input = sys.stdin.readline
from collections import Counter
Q = int(input())
for testcases in range(Q):
	(n, k) = list(map(int, input().split()))
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		l = n % (k + 1)
		if l == k:
			print('Alice')
		elif l % 3 == 0:
			print('Bob')
		else:
			print('Alice')


def naiveSolve():
	return

def main():
	A = 'Alice'
	B = 'Bob'
	t = int(input())
	allans = []
	for _ in range(t):
		(n, k) = readIntArr()
		if k % 3 != 0:
			if n % 3 == 0:
				allans.append(B)
			else:
				allans.append(A)
		elif n % (k + 1) != k and n % (k + 1) % 3 == 0:
			allans.append(B)
		else:
			allans.append(A)
	multiLineArrayPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split(' '))
	if k % 3 == 0:
		n = n % (k + 1)
	if n % 3 == 0 and n != k:
		print('Bob')
	else:
		print('Alice')


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	if k % 3 != 0 or n < k:
		if n % 3 != 0:
			print('Alice')
		else:
			print('Bob')
		continue
	if n >= k:
		if (n - (n + 1) // (k + 1)) % 3 != 0:
			print('Alice')
		else:
			print('Bob')


cases = int(input())
for _ in range(cases):
	(n, k) = map(int, input().split())
	if k % 3:
		ans = n % 3
	else:
		n %= k + 1
		ans = n % 3 if n < k else n
	print('Alice' if ans else 'Bob')


T = int(input())
for t in range(T):
	(n, k) = [int(i) for i in input().split()]
	win = 1
	if k % 3 == 0:
		np = n % (k + 1)
		if np % 3 == 0 and np != k:
			win = 0
	else:
		np = n % 3
		if np == 0:
			win = 0
	if win:
		print('Alice')
	else:
		print('Bob')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = list(map(int, input().split(' ')))
	if n == 0:
		print('Bob')
	elif n == 0:
		print('Bob')
	elif k == n:
		print('Alice')
	elif k > n:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif k % 3 == 0:
		np = n % (k + 1)
		if np % 3 == 0 and np != k:
			print('Bob')
		else:
			print('Alice')
	else:
		np = n % 3
		if np:
			print('Alice')
		else:
			print('Bob')


t = int(input())
while t:
	(n, k) = map(int, input().split())
	if k % 3 == 0:
		n = n % (k + 1)
	if n % 3 == 0 and n != k:
		print('Bob')
	else:
		print('Alice')
	t -= 1


def solve(n, k):
	sol = [None] * (n + 1)
	for i in range(n + 1):
		if i == 0:
			sol[i] = 'B'
			continue
		for offset in (1, 2, k):
			if i - offset >= 0 and sol[i - offset] == 'B':
				sol[i] = 'A'
				break
		else:
			sol[i] = 'B'
	print(''.join(sol))
	return sol[-1]

def solve2(n, k):
	if k % 3 > 0:
		return n % 3 != 0
	d = k // 3 - 1
	m = d * 3 + 4
	r = n % m
	return r % 3 != 0 or r == m - 1
T = int(input().strip())
for _ in range(T):
	(n, k) = list(map(int, input().strip().split()))
	print('Alice' if solve2(n, k) else 'Bob')


def go():
	(n, k) = [int(i) for i in input().split(' ')]
	if k % 3 == 0:
		x = n % (k + 1)
		if x % 3 == 0 and x != k:
			return 'Bob'
	else:
		x = n % 3
		if x == 0:
			return 'Bob'
	return 'Alice'
t = int(input())
o = ''
for _ in range(t):
	o += f'{go()}\n'
print(o)


def check(n, k):
	flag = True
	if k % 3 == 0:
		p = n % (k + 1)
		if p % 3 == 0 and p != k:
			flag = False
	else:
		p = n % 3
		if p == 0:
			flag = False
	if flag:
		return 'Alice'
	return 'Bob'
t = int(input())
a = list()
for i in range(t):
	(N, K) = [int(j) for j in input().split()]
	a.append(check(N, K))
for elem in a:
	print(elem)


def solve():
	[n, k] = (int(x) for x in input().split())
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	else:
		tc = k // 3
		n = n % (1 + 3 * tc)
		if n == 3 * tc:
			print('Alice')
		elif n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
t = int(input())
for _ in range(t):
	solve()


ll = lambda : list(map(int, input().split()))
testcases = 1
testcases = int(input())
ans = ['Bob', 'Alice']
for testcase in range(testcases):
	[n, k] = ll()
	if k % 3:
		print(ans[not not n % 3])
	else:
		condition = n % (k + 1) % 3 == 0 and n % (k + 1) != k
		print(ans[not condition])


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = int(input())

def issub(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	s2 = 'Bob'
	s1 = 'Alice'
	if k % 3 != 0:
		if n % 3 == 0:
			return s2
		else:
			return s1
	else:
		x = n % (k + 1)
		if x % 3 == 0 and x != k:
			return s2
		else:
			return s1
for _ in range(t):
	(n, k) = map(int, input().split())
	print(solve())


def gns():
	return list(map(int, input().split()))
t = int(input())

def one():
	(n, k) = gns()
	if k % 3 != 0:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
		return
	if n % (k + 1) == k:
		print('Alice')
		return
	n = n % (k + 1)
	if n % 3 == 0:
		print('Bob')
	else:
		print('Alice')
for i in range(t):
	one()


from sys import stdin, stdout, exit

def z(a):
	if a == 0:
		stdout.write('Bob\n')
	else:
		stdout.write('Alice\n')
T = int(input())
for it in range(T):
	(n, k) = map(int, stdin.readline().split())
	if k % 3 != 0:
		if n % 3 == 0:
			z(0)
		else:
			z(1)
		continue
	period = k + 1
	rem = n % period
	if rem == period - 1:
		z(1)
	elif rem % 3 == 0:
		z(0)
	else:
		z(1)


T = int(input())
A = 'Alice'
B = 'Bob'
for _ in range(T):
	(n, k) = map(int, input().split())
	if n == 0:
		print(B)
	elif k % 3 != 0:
		print(B) if n % 3 == 0 else print(A)
	elif n % (k + 1) % 3 == 0 and n % (k + 1) != k:
		print(B)
	else:
		print(A)


def game(n, k):
	if k % 3 != 0:
		return n % 3 != 0
	elif n % (k + 1) % 3 != 0:
		return 1
	elif n % (k + 1) == k:
		return 1
	else:
		return 0
T = int(input())
for t in range(T):
	n_k = input().split(' ')
	(n, k) = (int(n_k[0]), int(n_k[1]))
	ans = game(n, k)
	if ans:
		print('Alice')
	else:
		print('Bob')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n < k:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif k % 3 == 0:
		hog = n % (3 * k + 3)
		if hog < k:
			if n % 3 == 0:
				print('Bob')
			else:
				print('Alice')
		elif k <= hog and hog < 2 * k:
			if n % 3 == 1:
				print('Bob')
			else:
				print('Alice')
		elif 2 * k <= hog and hog < 3 * k:
			if n % 3 == 2:
				print('Bob')
			else:
				print('Alice')
		else:
			print('Alice')
	elif k % 3 == 1:
		if n % 3 == 0:
			print('Bob')
		else:
			print('Alice')
	elif n % 3 == 0:
		print('Bob')
	else:
		print('Alice')


q = int(input())
for you in range(q):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	n += 1
	if n <= k or k % 3:
		if n % 3 == 1:
			print('Bob')
		else:
			print('Alice')
	else:
		n -= k + 1
		n %= k + 1
		if n % 3 == 1:
			print('Bob')
		else:
			print('Alice')


def win(n, k):
	if k == 3:
		return n % 4 != 0
	if k % 3 != 0 or n < k:
		return n % 3 != 0
	q = n % (k + 1)
	if q == 0:
		return False
	return q % 3 != 0 or q == k
tests = int(input())
for test in range(tests):
	(n, k) = map(int, input().split())
	print('Alice' if win(n, k) else 'Bob')