The European Space Agency has $N$ telescopes observing distant planets. They have classified $M$ different types of events. They noticed that every day on each planet there is exactly one type of event. They measure events in days because they discovered each event lasts at least one day, and at most 365 days. Events last only complete numbers of days, they never last a fractional part of a day. Each event of the same type lasts exactly the same number of days every time it occurs, regardless of the planet it occurs on.

After many years of observation they want to analyze data. The telescopes logged all observations, but unfortunately they forgot to write down the year the observations took place! Each telescope entry consists of start date, end date and the number of events observed of each type. Given all observations on all the planets, calculate the duration of each type of event. Note that the telescopes are super precise and start working exactly when the event starts and end when an event ends, not necessarily the same one.

Note: for this task, each year has exactly 365 days.

-----Input-----
The first line contains $N$ and $M$ ($1 \le N, M \le 200$) - the number of telescopes and the number of event types. The next $N$ lines each contains $M + 4$ numbers each:

$D_1\text { }M_1\text { }D_2\text { }M_2\text { }F_1\text { }F_2\text { }...\text { }F_ M$

where $D_1, M_1$ ($01 \le D \le 31, 01 \le M \le 12$) is the start date, $D_2, M_2$ is the end date and $F_ i$ ($0 \le F_ i \le 200$) is the number of times event $I$ was observed.

Note that the days $D_ i$ and months $M_ i$ will always be zero-padded to exactly 2 characters.

-----Output-----
One line containing $M$ numbers, the durations of the event types. If more than one solution exists, output any one. If no solution exists, output “-1” (without quotes).

-----Examples-----
Sample Input 1:
1 1
26 02 03 03 1
Sample Output 1:
5

Sample Input 2:
1 1
26 02 03 03 2
Sample Output 2:
185

Source: kattis | Difficulty: HARD


Solutions: