CF1091H.New Year and the Tricolore Recreation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice and Bob play a game on a grid with nn rows and infinitely many columns. In each row, there are three tokens, blue, white and red one. Before the game starts and after every move, the following two conditions must hold:

  • Any two tokens are not in the same cell.
  • In each row, the blue token is to the left of the white token, and the red token is to the right of the white token.

First, they pick a positive integer ff , whose value is valid for the whole game. Second, the starting player is chosen and makes his or her first turn. Then players take alternating turns. The player who is unable to make a move loses.

During a move, a player first selects an integer kk that is either a prime number or a product of two (not necessarily distinct) primes. The smallest possible values of kk are thus 2,3,4,5,6,7,9,10,11,13,14,15,17,19,2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 19, \dots . Furthermore, kk must not be equal to the previously picked integer ff . Each turn, a move is performed in exactly one of the rows.

If it is Alice's turn, she chooses a single blue token and moves it kk cells to the right. Alternatively, she may move both the blue and the white token in the same row by the same amount kk to the right.

On the other hand, Bob selects a single red token and moves it kk cells to the left. Similarly, he may also move the white and the red token in the corresponding row by kk to the left.

Note that Alice may never move a red token, while Bob may never move a blue one. Remember that after a move, the two conditions on relative positions of the tokens must still hold.

Both players play optimally. Given the initial state of the board, determine who wins for two games: if Alice starts and if Bob starts.

输入格式

The first line contains a two integers nn and ff ( 1n1051 \leq n \leq 10^5 , 2f21052 \leq f \leq 2 \cdot 10^5 ) — the number of rows and the forbidden move, respectively.

Each of the next nn lines contains three integers bib_i , wiw_i , rir_i ( 105bi<wi<ri105-10^5 \leq b_i < w_i < r_i \leq 10^5 ) — the number of column in which the blue, white and red token lies in the ii -th row, respectively.

输出格式

Output two lines.

The first line should contain the name of the winner when Alice starts, and the second line should contain the name of the winner when Bob starts.

输入输出样例

  • 输入#1

    1 6
    0 3 9
    

    输出#1

    Alice
    Bob
    
  • 输入#2

    1 2
    0 3 9
    

    输出#2

    Alice
    Bob
    
  • 输入#3

    10 133
    -248 -193 -187
    97 101 202
    -72 67 91
    23 89 215
    -129 -108 232
    -223 -59 236
    -99 86 242
    -137 -109 -45
    -105 173 246
    -44 228 243
    

    输出#3

    Bob
    Alice
    

说明/提示

The first example is as follows:

When Alice starts, she can win by moving the blue and white token to right by 22 cells, getting into position 2 5 92~5~9 . Regardless of what Bob does, Alice will have one more move and then the game is over. For instance, he can move both the red and white token by 22 cells to the left, reaching state 2 3 72~3~7 . Alice can then move blue and white token by 22 to move into 4 5 74~5~7 , where no more moves are possible.

If Bob starts, he gains enough advantage to win. For instance, he may move the red token by 33 to the left, getting into position 0 3 60~3~6 . Alice can, for example, move the blue token by 22 , which is countered by Bob by moving the red token by 22 . The game ends in position 2 3 42~3~4 .

In the second example, it is forbidden to move by 22 , but this doesn't stop Alice from winning! She can move the blue and white token by 44 , getting into position 4 7 94~7~9 . Now Bob has no move, since moving by 22 is forbidden.

首页