After a long period of relaxation Alice and Bob decided to play a game.
This time of course not a number game. The rules of the game are as follows:

There is a vehicle situated at the point (m, n) of a rectangular grid.
Only one corner of the rectangular grid is defined, i.e. the left-top point (0, 0),
which is also known as the origin. The grid extends infinitely towards east and infinitely towards south.
Alice and Bob are both sitting in a vehicle, initially situated at the point (m, n).
The game they are playing ends as soon as one of them reaches (p, q).

Now, Alice and Bob have to drive the vehicle in their respective turn.
In their own turn they can move the vehicle, from (x, y) to (x', y)
or (x, y'); where p ≤ x' < x and q ≤ y' < y.
They can also move the vehicle to the point (x-a, y-a), where 0 < a ≤ min(x-p, y-q).
Also, 0 ≤ p < m and 0 ≤ q < n.
The winner is the game is the one who drives the vehicle to (p, q).

Cunning Alice uses a biased coin for tossing purpose and always plays first.
It is assumed that both Alice and Bob play optimally in their respective turns.

------ Input ------ 

The first line contains a single integer T denoting the number of test cases.
T test cases follow. Each test case consists of a single line consisting of four space separated integers m, n, p, q
respectively.

------ Output ------ 

For each test case print a string - either "Alice" or "Bob" (without the quotes), denoting the winner.

------ Constraints ------ 

1 ≤ T ≤ 1000

1  ≤ m, n  ≤ 1000

0 ≤ p < m

0 ≤ q < n

----- Sample Input 1 ------ 
2
1 1 0 0
2 4 1 2
----- Sample Output 1 ------ 
Alice
Bob
----- explanation 1 ------ 
In the second test case, initially the vehicle is at co-ordinate (2, 4).
Alice now has four possible moves. Alice can move the vehicle to position (1, 4), (1, 3), (2, 3) and (2, 2).
For all moves that Alice can do, Bob can move the vehicle to the position (1, 2), winning the game.

Difficulty: MEDIUM
Tags: Preprocessing

Game theory

Constructive algorithms

Starter code:

Solutions:
import sys

def solve(m, n):
	mapXY = [[-1 for j in range(n + 1)] for i in range(m + 1)]
	fails = [(1, 2), (3, 5), (4, 7), (6, 10), (8, 13), (9, 15), (11, 18), (12, 20), (14, 23), (16, 26), (17, 28), (19, 31), (21, 34), (22, 36), (24, 39), (25, 41), (27, 44), (29, 47), (30, 49), (32, 52), (33, 54), (35, 57), (37, 60), (38, 62), (40, 65), (42, 68), (43, 70), (45, 73), (46, 75), (48, 78), (50, 81), (51, 83), (53, 86), (55, 89), (56, 91), (58, 94), (59, 96), (61, 99), (63, 102), (64, 104), (66, 107), (67, 109), (69, 112), (71, 115), (72, 117), (74, 120), (76, 123), (77, 125), (79, 128), (80, 130), (82, 133), (84, 136), (85, 138), (87, 141), (88, 143), (90, 146), (92, 149), (93, 151), (95, 154), (97, 157), (98, 159), (100, 162), (101, 164), (103, 167), (105, 170), (106, 172), (108, 175), (110, 178), (111, 180), (113, 183), (114, 185), (116, 188), (118, 191), (119, 193), (121, 196), (122, 198), (124, 201), (126, 204), (127, 206), (129, 209), (131, 212), (132, 214), (134, 217), (135, 219), (137, 222), (139, 225), (140, 227), (142, 230), (144, 233), (145, 235), (147, 238), (148, 240), (150, 243), (152, 246), (153, 248), (155, 251), (156, 253), (158, 256), (160, 259), (161, 261), (163, 264), (165, 267), (166, 269), (168, 272), (169, 274), (171, 277), (173, 280), (174, 282), (176, 285), (177, 287), (179, 290), (181, 293), (182, 295), (184, 298), (186, 301), (187, 303), (189, 306), (190, 308), (192, 311), (194, 314), (195, 316), (197, 319), (199, 322), (200, 324), (202, 327), (203, 329), (205, 332), (207, 335), (208, 337), (210, 340), (211, 342), (213, 345), (215, 348), (216, 350), (218, 353), (220, 356), (221, 358), (223, 361), (224, 363), (226, 366), (228, 369), (229, 371), (231, 374), (232, 376), (234, 379), (236, 382), (237, 384), (239, 387), (241, 390), (242, 392), (244, 395), (245, 397), (247, 400), (249, 403), (250, 405), (252, 408), (254, 411), (255, 413), (257, 416), (258, 418), (260, 421), (262, 424), (263, 426), (265, 429), (266, 431), (268, 434), (270, 437), (271, 439), (273, 442), (275, 445), (276, 447), (278, 450), (279, 452), (281, 455), (283, 458), (284, 460), (286, 463), (288, 466), (289, 468), (291, 471), (292, 473), (294, 476), (296, 479), (297, 481), (299, 484), (300, 486), (302, 489), (304, 492), (305, 494), (307, 497), (309, 500), (310, 502), (312, 505), (313, 507), (315, 510), (317, 513), (318, 515), (320, 518), (321, 520), (323, 523), (325, 526), (326, 528), (328, 531), (330, 534), (331, 536), (333, 539), (334, 541), (336, 544), (338, 547), (339, 549), (341, 552), (343, 555), (344, 557), (346, 560), (347, 562), (349, 565), (351, 568), (352, 570), (354, 573), (355, 575), (357, 578), (359, 581), (360, 583), (362, 586), (364, 589), (365, 591), (367, 594), (368, 596), (370, 599), (372, 602), (373, 604), (375, 607), (377, 610), (378, 612), (380, 615), (381, 617), (383, 620), (385, 623), (386, 625), (388, 628), (389, 630), (391, 633), (393, 636), (394, 638), (396, 641), (398, 644), (399, 646), (401, 649), (402, 651), (404, 654), (406, 657), (407, 659), (409, 662), (410, 664), (412, 667), (414, 670), (415, 672), (417, 675), (419, 678), (420, 680), (422, 683), (423, 685), (425, 688), (427, 691), (428, 693), (430, 696), (432, 699), (433, 701), (435, 704), (436, 706), (438, 709), (440, 712), (441, 714), (443, 717), (444, 719), (446, 722), (448, 725), (449, 727), (451, 730), (453, 733), (454, 735), (456, 738), (457, 740), (459, 743), (461, 746), (462, 748), (464, 751), (465, 753), (467, 756), (469, 759), (470, 761), (472, 764), (474, 767), (475, 769), (477, 772), (478, 774), (480, 777), (482, 780), (483, 782), (485, 785), (487, 788), (488, 790), (490, 793), (491, 795), (493, 798), (495, 801), (496, 803), (498, 806), (499, 808), (501, 811), (503, 814), (504, 816), (506, 819), (508, 822), (509, 824), (511, 827), (512, 829), (514, 832), (516, 835), (517, 837), (519, 840), (521, 843), (522, 845), (524, 848), (525, 850), (527, 853), (529, 856), (530, 858), (532, 861), (533, 863), (535, 866), (537, 869), (538, 871), (540, 874), (542, 877), (543, 879), (545, 882), (546, 884), (548, 887), (550, 890), (551, 892), (553, 895), (554, 897), (556, 900), (558, 903), (559, 905), (561, 908), (563, 911), (564, 913), (566, 916), (567, 918), (569, 921), (571, 924), (572, 926), (574, 929), (576, 932), (577, 934), (579, 937), (580, 939), (582, 942), (584, 945), (585, 947), (587, 950), (588, 952), (590, 955), (592, 958), (593, 960), (595, 963), (597, 966), (598, 968), (600, 971), (601, 973), (603, 976), (605, 979), (606, 981), (608, 984), (609, 986), (611, 989), (613, 992), (614, 994), (616, 997), (618, 1000)]
	for (x, y) in fails:
		mapXY[x][y] = mapXY[y][x] = 0
	return mapXY

def workOn(count):
	matrix = solve(1000, 1000)
	for i in range(int(count)):
		val = sys.stdin.readline().strip().split(' ')
		m = int(val[0])
		n = int(val[1])
		p = int(val[2])
		q = int(val[3])
		m -= p
		n -= q
		if matrix[m][n] == 0:
			print('Bob')
		else:
			print('Alice')
workOn(int(sys.stdin.readline()))


size = 1001
lose = [(0, 0)] * (size + 1)
numbers = list(range(1, size + 1))
idx = 1
for idx in range(1, size + 1):
	if len(numbers) == 0:
		break
	x = numbers.pop(0)
	y = x + idx
	if y <= size:
		numbers.remove(y)
	lose[idx] = (x, y)

def winner(x, y):
	mx = min(x, y)
	my = max(x, y)
	delta = my - mx
	if mx == lose[delta][0] and my == lose[delta][1]:
		return 'Bob'
	else:
		return 'Alice'
tc = int(input())
for t in range(tc):
	(m, n, p, q) = list(map(int, input().split(' ')))
	x = m - p
	y = n - q
	print(winner(x, y))