Electricity

No attempts yetTime limit1sMemory limit128 MB

Problem

Martin and Isa got married and moved to a new house in a remote place. Electricity is very expensive there, so they want to keep their consumption under control.

The house has an electricity meter that shows, as a whole number of kilowatt-hours (KWh), the total amount of electricity consumed since they arrived. At the beginning of each day they check the meter and write down its reading — some days Martin does it, some days Isa. By comparing the readings of two consecutive days, they can tell how much electricity was consumed during the day in between.

Some days, however, they forget, so their record now has gaps. They have a list of dates together with the meter reading taken on the morning of each date, but the dates are not all consecutive.

The consumption of a given day can be determined exactly only if they have the meter reading for the morning of that day and for the morning of the next day. In other words, only when two records fall on two consecutive calendar days can the consumption of the earlier day be known exactly.

Determine how many days have an exactly determinable consumption, and the total consumption over those days.

Input

The input contains several test cases.

The first line of each test case contains one integer $N$ ($2 \le N \le 10^3$), the number of readings. Each of the following $N$ lines contains four integers $D$, $M$, $Y$ and $C$, separated by single spaces: the day $D$ ($1 \le D \le 31$), month $M$ ($1 \le M \le 12$), year $Y$ ($1900 \le Y \le 2100$) and cumulative consumption $C$ ($0 \le C \le 10^6$) read on the morning of that day.

These $N$ lines are sorted in increasing order of date and may include leap years. The sequence of consumptions is strictly increasing (no two readings are equal). $D$, $M$ and $Y$ always represent a valid date.

Recall that a year is a leap year if it is divisible by 4 and not by 100, or if it is divisible by 400.

The end of the input is indicated by a line containing a single zero.

Output

For each test case, print a single line with two integers separated by a single space: the number of days whose consumption can be determined exactly, and the sum of the consumptions over those days.