ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

Novosibirsk SU contest. Petrozavodsk training camp. Summer 2007

About     Problems     Submit solution     Judge status     Standings
Contest is over

J. Winnie the Pooh

Time limit: 2.0 second
Memory limit: 64 MB
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:
  1. New sort of honey appears. It is assigned the smallest non-negative number not assigned yet. No other information about this sort is provided.
  2. 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).
  3. 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.

Input

The first line contains N — number of queries (0 ≤ N ≤ 1000). Events of type 1, 2, 3 are given as follows respectively:
  • Add
  • Learn A0 A1 A2 … Ak S E
  • Eat A0 A1 A2 … Ak S
The queries are given one per line.

Output

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.

Sample

inputoutput
9
Add
Add
Learn 5 2 Saturday Monday
Eat 3 3 Tuesday
Add
Learn 0 9 4 Friday Thursday
Eat 3 0 6 Sunday
Learn 3 2 10 Saturday Friday
Eat 3 4 11 Monday
Don't know
Saturday
Already crazy
Problem Source: Novosibirsk SU Contest. Petrozavodsk training camp, September 2007
To submit the solution for this problem go to the Problem set: 1561. Winnie the Pooh