English · Original
Chinese · Translation
Formal · Original
Imagine that Alice is playing a card game with her friend Bob. They both have exactly $8$ cards and there is an integer on each card, ranging from $0$ to $4$. In each round, Alice or Bob in turns choose two cards from different players, let them be $a$ and $b$, where $a$ is the number on the player's card, and $b$ is the number on the opponent's card. It is necessary that $a \cdot b \ne 0$. Then they calculate $c = (a + b) \bmod 5$ and replace the number $a$ with $c$. The player who ends up with numbers on all $8$ cards being $0$, wins.
Now Alice wants to know who wins in some situations. She will give you her cards' numbers, Bob's cards' numbers and the person playing the first round. Your task is to determine who wins if both of them choose the best operation in their rounds.
## Input
The first line contains one positive integer $T$ ($1 \leq T \leq 100\,000$), denoting the number of situations you need to consider.
The following lines describe those $T$ situations. For each situation:
* The first line contains a non-negative integer $f$ ($0 \leq f \leq 1$), where $f = 0$ means that Alice plays first and $f = 1$ means Bob plays first.
* The second line contains $8$ non-negative integers $a_1, a_2, \ldots, a_8$ ($0 \leq a_i \leq 4$), describing Alice's cards.
* The third line contains $8$ non-negative integers $b_1, b_2, \ldots, b_8$ ($0 \leq b_i \leq 4$), describing Bob's cards.
We guarantee that if $f=0$, we have $\sum_{i=1}^{8}a_i \ne 0$. Also when $f=1$, $\sum_{i=1}^{8}b_i \ne 0$ holds.
## Output
Output $T$ lines. For each situation, determine who wins. Output
* "_Alice_" (without quotes) if Alice wins.
* "_Bob_" (without quotes) if Bob wins.
* "_Deal_" (without quotes) if it gets into a deal, i.e. no one wins.
[samples]
## Note
In the first situation, Alice has all her numbers $0$. So she wins immediately.
In the second situation, Bob picks the numbers $4$ and $1$. Because we have $(4 + 1) \bmod 5 = 0$, Bob wins after this operation.
In the third situation, Alice picks the numbers $1$ and $4$. She wins after this operation.
In the fourth situation, we can prove that it falls into a loop.
想象爱丽丝正在和她的朋友鲍勃玩一种纸牌游戏。他们每人恰好有 $8$ 张牌,每张牌上有一个介于 $0$ 到 $4$ 之间的整数。每轮中,爱丽丝或鲍勃轮流选择两张来自不同玩家的牌,记为 $a$ 和 $b$,其中 $a$ 是当前玩家牌上的数字,$b$ 是对手牌上的数字。必须满足 $a \dot{\text{op}} b \ne 0$。然后他们计算 $c = (a + b) \bmod 5$,并将 $a$ 替换为 $c$。当某位玩家所有 $8$ 张牌上的数字都变为 $0$ 时,该玩家获胜。
现在爱丽丝想知道在某些情况下谁会获胜。她会提供她的牌面数字、鲍勃的牌面数字以及先手玩家。你的任务是确定,当双方都采取最优操作时,谁会获胜。
第一行包含一个正整数 $T$ ($1 \lt.eq T \lt.eq 100 \thin 000$),表示你需要考虑的情况数量。
接下来的行描述这 $T$ 种情况。对于每种情况:
我们保证,若 $f = 0$,则有 $\sum_{i = 1}^8 a_i \ne 0$;当 $f = 1$ 时,$\sum_{i = 1}^8 b_i \ne 0$ 成立。
输出 $T$ 行。对于每种情况,判断谁获胜。输出
在第一种情况中,爱丽丝的所有数字均为 $0$,因此她立即获胜。
在第二种情况中,鲍勃选择数字 $4$ 和 $1$。由于 $(4 + 1) \bmod 5 = 0$,鲍勃在此次操作后获胜。
在第三种情况中,爱丽丝选择数字 $1$ 和 $4$,她在此次操作后获胜。
在第四种情况中,我们可以证明游戏会进入循环。
## Input
第一行包含一个正整数 $T$ ($1 \lt.eq T \lt.eq 100 \thin 000$),表示你需要考虑的情况数量。接下来的行描述这 $T$ 种情况。对于每种情况:
第一行包含一个非负整数 $f$ ($0 \lt.eq f \lt.eq 1$),其中 $f = 0$ 表示爱丽丝先手,$f = 1$ 表示鲍勃先手。
第二行包含 $8$ 个非负整数 $a_1, a_2, \dots.h, a_8$ ($0 \lt.eq a_i \lt.eq 4$),描述爱丽丝的牌。
第三行包含 $8$ 个非负整数 $b_1, b_2, \dots.h, b_8$ ($0 \lt.eq b_i \lt.eq 4$),描述鲍勃的牌。
我们保证,若 $f = 0$,则有 $\sum_{i = 1}^8 a_i \ne 0$;当 $f = 1$ 时,$\sum_{i = 1}^8 b_i \ne 0$ 成立。
## Output
输出 $T$ 行。对于每种情况,判断谁获胜。输出
"_Alice_"(不含引号)表示爱丽丝获胜。
"_Bob_"(不含引号)表示鲍勃获胜。
"_Deal_"(不含引号)表示进入平局,即无人获胜。
[samples]
## Note
在第一种情况中,爱丽丝的所有数字均为 $0$,因此她立即获胜。
在第二种情况中,鲍勃选择数字 $4$ 和 $1$。由于 $(4 + 1) \bmod 5 = 0$,鲍勃在此次操作后获胜。
在第三种情况中,爱丽丝选择数字 $1$ 和 $4$,她在此次操作后获胜。
在第四种情况中,我们可以证明游戏会进入循环。
**Definitions**
Let $ T \in \mathbb{Z}^+ $ be the number of test cases.
For each test case $ k \in \{1, \dots, T\} $:
- Let $ A_k = (a_1, a_2, \dots, a_8) \in \{0,1,2,3,4\}^8 $ be Alice’s card values.
- Let $ B_k = (b_1, b_2, \dots, b_8) \in \{0,1,2,3,4\}^8 $ be Bob’s card values.
- Let $ f_k \in \{0,1\} $ denote the starting player: $ f_k = 0 $ for Alice, $ f_k = 1 $ for Bob.
**Constraints**
1. $ 1 \le T \le 100000 $
2. For all $ i \in \{1, \dots, 8\} $, $ a_i, b_i \in \{0,1,2,3,4\} $
3. If $ f_k = 0 $, then $ \sum_{i=1}^8 a_i \ne 0 $
4. If $ f_k = 1 $, then $ \sum_{i=1}^8 b_i \ne 0 $
**Game Rules**
On a player’s turn (say Player $ P $ with hand $ H_P $, opponent has hand $ H_O $):
- Choose $ a \in H_P $, $ b \in H_O $ such that $ a \cdot b \not\equiv 0 \pmod{5} $
- Replace $ a $ with $ c = (a + b) \bmod 5 $
- The player who first achieves $ H_P = (0,0,\dots,0) $ wins.
**Objective**
For each test case $ k $, determine the winner under optimal play:
- Output `Alice` if Alice wins, `Bob` if Bob wins, `Loop` if the game enters an infinite loop.
API Response (JSON)
{
"problem": {
"name": "F. A Game With Numbers",
"description": {
"content": "Imagine that Alice is playing a card game with her friend Bob. They both have exactly $8$ cards and there is an integer on each card, ranging from $0$ to $4$. In each round, Alice or Bob in turns choo",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 4000,
"memory_limit": 524288
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF919F"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Imagine that Alice is playing a card game with her friend Bob. They both have exactly $8$ cards and there is an integer on each card, ranging from $0$ to $4$. In each round, Alice or Bob in turns choo...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "想象爱丽丝正在和她的朋友鲍勃玩一种纸牌游戏。他们每人恰好有 $8$ 张牌,每张牌上有一个介于 $0$ 到 $4$ 之间的整数。每轮中,爱丽丝或鲍勃轮流选择两张来自不同玩家的牌,记为 $a$ 和 $b$,其中 $a$ 是当前玩家牌上的数字,$b$ 是对手牌上的数字。必须满足 $a \\dot{\\text{op}} b \\ne 0$。然后他们计算 $c = (a + b) \\bmod 5$,并将 $a$...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ T \\in \\mathbb{Z}^+ $ be the number of test cases. \nFor each test case $ k \\in \\{1, \\dots, T\\} $: \n- Let $ A_k = (a_1, a_2, \\dots, a_8) \\in \\{0,1,2,3,4\\}^8 $ be Alice’s card v...",
"is_translate": false,
"language": "Formal"
}
]
}