#P7267. [BalticOI 2000] Time Zones (Day1)

[BalticOI 2000] Time Zones (Day1)

Description

You’re a businessman that has customers all over the world. During one day you get exactly one message from each time zone, including the zone you stay in. The messages come with their sending time specified in them (the messages are transported instantly). Unfortunately due to a millennium bug the senders’ local time is given without anything that identifies their time zone.

Task: Your task is to identify from which time zones the messages originated.

In this task the number of hours, nn, in one day varies between 5605\dots60. The number of time zones is always the same as the number of hours and each time zone has a time displacement which is an integral number of hours.

The zones are numbered from 00 to n1n−1. You are living and receiving the messages in ”GMT”, that is in time zone 00 without any time displacement. The time zones are counted westward. That means that you should add zz hours to the local time in zone zz to get the time in your zone. Note that this is not the common way to count the zones, normally zone 22 would be known as “2:00-2:00”.

For example, if the local time in time zone 22 is 03:1503:15 it is 05:1505:15 in your zone (”GMT”).

The messages can arrive anytime during the day (that is between 0:000:00-(n1):59(n-1):59), but no two messages arrive at the same time. The date line goes between zone 00 and the last zone and can thus be ignored.

Input Format

The first row contains the number of hours in one day, nn, 5n605\le n\le60, which also is the number of time zones and the number of messages you received.

Each of the following nn rows contains the local sending time given as hhmm\text{hhmm} (22 digits for hours and 22 digits for minutes where 0hhn10\le hh\le n-1 and 0mm590\le mm\le59). The rows areordered in chronological order, i.e. the first message that arrived is on the first row.

There is one unique solution to all given test examples.

Output Format

The output must contain a single row with nn numbers from 00 to n1n−1 identifying in which time zones the nn messages originated. The first number corresponds to the first time given in the input etc.

5
0017
0250
0400
0201
0002
3 1 0 2 4

Hint

Note that message 33 must come from time-zone 00 or it would have arrived at a time later than 4:594:59 which is the last minute in the 55-hour days in the first sample.