Under construction

Still being built. Things may change

Baklawa

Time limit2sMemory limit512 MB

Summary
Given a huge cuboid with up to 100 poisonous unit cells, players alternate cutting off a safe cuboid half; decide who wins under optimal play.
Level

Hard8 of 10

Topics
Game theory, Geometry, Combinatorics, Implementation
Solved
No attempts yet

Problem

Baklawa, or baklava, is a sweet Middle Eastern dessert made mainly from phyllo dough sheets, walnuts, and sugar syrup. It is cut into small cubic pieces and served in cuboid boxes that contain multiple layers.

Alice and Bob love to play what they call the last Baklawa game. The rules are as follows.

  • They choose a cuboid containing X by Y by Z cells of Baklawa to play with.
  • There are N poisonous cells, and both players know them.
  • Alice plays first, and the two players alternate.
  • On your turn you have to cut the cuboid into two cuboids such that at least one of them is safe (contains no poisonous cube) and eat the safe part. The game continues with the other part.
  • A cut is made by slicing along one of the axes X, Y, or Z.
  • The person who cannot make a move on their turn loses the game.

Assuming both players play optimally, answer the following question: who wins the game?

Input

Your program will be tested on one or more test cases. The first line of the input contains a single integer T, the number of test cases (1 ≤ T ≤ 100).

Each test case starts with a line containing four space-separated integers:

  • X: the length of the cuboid (1 ≤ X ≤ 1,000,000,000)
  • Y: the width of the cuboid (1 ≤ Y ≤ 1,000,000,000)
  • Z: the height of the cuboid (1 ≤ Z ≤ 1,000,000,000)
  • N: the number of poisonous cells (0 ≤ N ≤ 100)

This is followed by N lines, each containing three space-separated integers:

  • xi: the x-coordinate of the i-th cube (1 ≤ xi ≤ X)
  • yi: the y-coordinate of the i-th cube (1 ≤ yi ≤ Y)
  • zi: the z-coordinate of the i-th cube (1 ≤ zi ≤ Z)

Output

For each test case, print a single line containing 'Alice' if Alice wins the game, or 'Bob' otherwise.

Hint

The figure below is an example of the first test case.

Examples1

  1. Example 1

    Input
    2
    3 3 3 4
    3 2 1
    3 1 1
    3 3 1
    3 2 2
    5 5 5 1
    3 4 2
    
    Expected output
    Alice
    Bob