Problem list
Log in
#icpc00295 · ICPC NCPC 2023

Die Hard

Silver V 5.0 s 2048 MB

John and Hans are playing a game involving 3 dice. Even though they are all 6-sided, they are not guaranteed to be identical.

First John picks one of the dice and then Hans picks one of the remaining two. Then they both roll their chosen die. If they roll the same number, they both re-roll their die. Otherwise the winner is the one who rolled the highest number.

In case neither John or Hans can win with their chosen dice, they do not bother to re-roll the dice indefinitely and no winner is declared.

Can you help John pick a die that guarantees that he wins with a probability of at least $\frac{1}{2}$?

Input

The input consists of three lines. Line $i$ contains $6$ positive integers $x_j$ ($1 \leq x_j \leq 1000$), describing the sides of the $i$'th die.

Output

Output the smallest $i \in {1, 2, 3}$, such that John can pick die $i$ and be guaranteed to win with probability at least $\frac{1}{2}$. If no such die exists, output "No dice".

Example 1

Input
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
Output
1

Example 2

Input
1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
Output
3

Example 3

Input
2 2 4 4 9 9
1 1 6 6 8 8
7 7 5 5 3 3
Output
No dice

Example 4

Input
1 1 1 1 1 1
2 2 2 2 2 2
2 2 2 2 2 2
Output
No dice
Source
ICPC NCPC 2023
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code