Jenny's First Exams

Time limit2sMemory limit64 MB

Problem

Jenny has to prepare for several exams under the following rules:

  • Preparing for one exam takes a whole day, and one day of preparation per exam is enough.
  • She can prepare for at most one exam per day.
  • On a day when she has an exam, she cannot study anything.
  • She must not start preparing for the $i$-th exam earlier than $t_i$ days before it; if she prepares too early, she forgets everything by the time of the exam.

Jenny wants to start her preparations as late as possible while still passing every exam. Find the latest day on which she can start.

Input

The first line contains the number of exams $n$ ($1 \le n \le 50,000$). The exam descriptions follow.

Each description consists of three lines: the subject name (a string of Latin letters only, at most 10 characters), the exam date in dd.mm.yyyy format, and the value $t_i$ ($1 \le t_i \le 100,000$) for that exam.

All exams take place between 01.01.1900 and 31.12.2100.

A year is a leap year if it is divisible by 4 and not by 100, or if it is divisible by 400. A leap year has 366 days, with the extra day being February 29.

Output

Print the latest date, in dd.mm.yyyy format, on which Jenny can start preparing and still pass all exams. If passing all exams is impossible, print Impossible.