#arc174f. F - Final Stage

F - Final Stage

Points: 900900 points

问题陈述

玩家Alice和Bob使用长度为NN的序列LLRR进行游戏,规则如下:

  • 游戏由NN个回合组成。
  • 如果ii是奇数,第ii个回合由Alice进行;如果ii是偶数,第ii个回合由Bob进行。
  • 游戏开始时,有一个包含一些石头的堆。
  • 对于i=1,2,,Ni=1,2,\dots,N,按照这个顺序,他们执行以下操作(称为第ii个回合):
    • 进行第ii个回合的玩家从堆中取走LiL_iRiR_i(包括LiL_iRiR_i)之间的整数个石头。
    • 如果玩家不能取走满足上述条件的石头,他们就输了,另一个玩家赢了。
  • 如果到第NN个回合结束时,没有玩家输掉游戏,游戏以平局结束。

游戏开始前,两位玩家都会知道序列LLRR以及游戏开始时堆中的石头数量。

可以证明,游戏恰好有以下三种结果之一:

  • Alice ... Alice有一个获胜策略。
  • Bob ... Bob有一个获胜策略。
  • Draw ... 没有玩家有获胜策略。

回答关于这个游戏的QQ个问题。第ii个问题如下:

  • 假设游戏开始时堆中包含CiC_i个石头。报告游戏的结果:AliceBobDraw

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

Players Alice and Bob play a game using sequences LL and RR of length NN, as follows.

  • The game consists of NN turns.
  • If ii is odd, turn ii is played by Alice; if ii is even, turn ii is played by Bob.
  • Initially, there is a pile with some number of stones.
  • For i=1,2,,Ni=1,2,\dots,N in this order, they perform the following operation (called turn ii):
    • The player who plays turn ii takes an integer number of stones between LiL_i and RiR_i, inclusive, from the pile.
    • If the player cannot take stones satisfying the above, they lose, and the other player wins.
  • If neither player has lost by the end of turn NN, the game ends in a draw.

Before the game starts, both players are informed of the sequences LL and RR and the number of stones in the pile at the start of the game.

It can be proved that the game has exactly one of the following three consequences:

  • Alice ... Alice has a winning strategy.
  • Bob ... Bob has a winning strategy.
  • Draw ... Neither player has a winning strategy.

Answer QQ queries about this game. The ii-th query is as follows:

  • Assume that the pile contains CiC_i stones at the start of the game. Report the consequence of the game: Alice, Bob, or Draw.

Constraints

  • NN, LiL_i, RiR_i, QQ, and CiC_i are integers.
  • 1N3×1051 \le N \le 3 \times 10^5
  • 1LiRi1091 \le L_i \le R_i \le 10^9
  • 1Q3×1051 \le Q \le 3 \times 10^5
  • 1Cii=1NRi1 \le C_i \le \sum_{i=1}^{N} R_i

Input

The input is given from Standard Input in the following format:

NN

L1L_1 R1R_1

L2L_2 R2R_2

\vdots

LNL_N RNR_N

QQ

C1C_1

C2C_2

\vdots

CQC_Q

Output

Print QQ lines. The ii-th line should contain the answer to the ii-th query.

Sample Input 1

4
1 3
1 2
3 4
1 2
11
1
2
3
4
5
6
7
8
9
10
11

Sample Output 1

Alice
Alice
Alice
Bob
Bob
Alice
Alice
Alice
Draw
Draw
Draw

This input contains 1111 queries.

  • When Ci3C_i \le 3, Alice can take all CiC_i stones on turn 11, leaving no stones in the pile, so Alice has a winning strategy.
  • When 4Ci54 \le C_i \le 5, Bob has a winning strategy.
  • When 6Ci86 \le C_i \le 8, Alice has a winning strategy.
  • When Ci9C_i \ge 9, neither player has a winning strategy.
    • For example, if Ci=9C_i=9, the game could proceed as follows:
      • On turn 11, Alice takes 33 stones. 66 stones remain.
      • On turn 22, Bob takes 11 stone. 55 stones remain.
      • On turn 33, Alice takes 44 stones. 11 stone remains.
      • On turn 44, Bob takes 11 stone. No stones remain.
      • Since neither player has lost by the end of turn 44, the game ends in a draw.
    • Various other progressions are possible, but it can be shown that when Ci=9C_i=9, neither player has a winning strategy (if both players play optimally, the game will end in a draw).