Board Game

Time limit: 0.5s Memory limit: 256MB Input: Output:

Alice and Bob, a sibling pair, have been blessed with a weighted directed acyclic graph with NN nodes and MM edges under the Christmas tree. They are super competitive, so they decided to play a game on the graph.

The game begins with a marker placed on vertex 11. At every turn, Alice and Bob make a move alternately with Alice beginning. In a move, the current player can move the marker from vertex uu to vertex vv if there is an edge from uu to vv. For such a move, the player needs to pay Wu>vW_{u->v} money. The player who can not move the marker loses. They are incredibly smart, so they immediately understand who will win the game if they play optimally. Thus, the loser (being a sore loser) will do everything in their power to get the winner to pay as much money as possible. The loser does not care how much they have to pay.

Task

Given the graph, your task is to find who will win the game and the minimum amount the winner has to pay if both siblings play optimally.

Input data

The input consists of:

  • a line containing integers NN, MM.
  • MM lines, the ii-th of which consisting of integers UiU_{i}, ViV_{i}, WiW_{i}, representing an edge from node UiU_{i} to node ViV_{i} with a weight of WiW_{i}.

Output data

The output must consists of two lines:

  • The first line should consist of a single string which is Alice or Bob, the winner of the game.
  • The second line should consist of a single integer, the minimum amount of money the winner needs to spend.

Constraints and clarifications

  • 1N100 0001 \le N \le 100 \ 000
  • 1M200 0001 \le M \le 200 \ 000
  • 1Ui,ViN1 \le U_i, V_i \le N for each i=0M1i=0\ldots M-1
  • There is at most one edge between every pair of nodes, that is, each (Ui,Vi)(U_i, V_i) pair is unique.
  • The edges form a directed acyclic graph.
  • 0Wi1 000 000 0000 \le W_i \le 1 \ 000 \ 000 \ 000 for each i=0M1i=0\ldots M-1
# Points Constraints
1 0 Examples
2 10 N10N \le 10, M20M \le 20
3 15 Wi=0W_i = 0 for each i=0M1i=0\ldots M-1
4 40 Wi=1W_i = 1 for each i=0M1i=0\ldots M-1
5 35 No additional constraints

Example

stdin

8 8
1 2 1
1 5 8
2 3 3
1 4 2
4 5 4
4 6 5
5 7 5
6 8 4

stdout

Alice
7

Explanation

In the sample case:

  • The only way for Alice to secure her victory is to move the marker from vertex 11 to vertex 44 (for a cost of 22).
  • To maximize Alice's payment, Bob will move the marker from vertex 44 to vertex 55.
  • making Alice pay 55 on her last move to vertex 77.

Since Bob is unable to move, Alice wins, and she payed a total of 77

Log in or sign up to be able to send submissions!