Winnie the Pooh likes honey a lot. But many sorts of honey exist in the world.
Winnie eats a barrel of honey in an integral number of days. Two barrels of
honey of the same sort need the same number of days to be eaten. Any event that
corresponds to the problem is one of the following:
- New sort of honey appears. It is assigned the smallest non-negative number not assigned yet.
No other information about this sort is provided.
- Winnie investigated (empirically maybe…), that if he has to eat A0 barrels
of honey of 0th sort, A1 of the 1st, …, Ak of the k-th sort,
starting at weekday S, the first weekday after eating will be E (0, …, k —
sorts that are already known to exist; Ai are integers,
0 ≤ Ai ≤ 106).
- Winnie plans to eat A0 barrels of honey of the 0th sort, A1 of the 1st,
… Ak of the k-th sort, starting at weekday S, where 0, …, k
are sorts that are already known to exist. You have to find the first day after eating according to the information
from preceding queries.
The first line contains N
— number of queries (0 ≤ N
Events of type 1, 2, 3 are given as follows respectively:
- Learn A0 A1 A2 … Ak S E
- Eat A0 A1 A2 … Ak S
The queries are given one per line.
If you can determine the weekday output it. If there is more than one
possibility output "Don't know" without quotes. If you determined some contradiction
before this Eat query, output "Already crazy" without quotes.
Learn 5 2 Saturday Monday
Eat 3 3 Tuesday
Learn 0 9 4 Friday Thursday
Eat 3 0 6 Sunday
Learn 3 2 10 Saturday Friday
Eat 3 4 11 Monday
Problem Source: Novosibirsk SU Contest. Petrozavodsk training camp, September 2007