Year 3001. Your company needs to know if new model of watch is precise enough, so you need to run a small experiment. You'll take several watches, set them to "00:00", wait for a couple of years and then compute the watch imprecision which is equal to the largest difference between the two times shown on the watches. For example, if you've taken four watches and at the end of the experiment they've shown "11:11", "10:59", "11:02" and "11:13", then the biggest difference is 14 minutes (between "11:13" and "10:59").
To make the experiment a bit more interesting you've decided to give the watches to volunteers living in different time zones. The time zones have positive 0-based indices, so time zone number K is K hours ahead of yours. For example, 2:15 in your zone, 4:15 in zone 2 and 8:15 in zone 6 are the same moment of time. The watches of the volunteers were set according to the time zones they are from, so the watch for the volunteer from time zone X was set to X hours zero minutes at the beginning of the experiment.
Before the start of the experiment you wrote down the time zones your volunteers are from, and at the end of the experiment each of the volunteers recorded the time shown on his watch. Unfortunately, you messed up the order of the records, so now you do not know which time zone corresponds to which volunteer. You are optimistic so you want to find the minimal possible imprecision under given data. Please note that the watches does not show date, so, for example, the difference between "23:50" and "00:10" can be only 20 minutes (or 23 hours and 40 minutes, if needed).
You will be given a String times, giving you the times recorded by volunteers. Each element of times is formatted as "HH:MM" (quotes for clarity), where HH is an hour between 00 and 23 and MM is a minute between 00 and 59. You will be also given a int zones, giving you the time zones for the volunteers. You are to assign each time zone to exactly one volunteer and return the minimal watch imprecision in minutes.