Олимпиадный тренинг

Задача 44936. Exploring Specular Colors


Crew members of the Pegasus spacecraft landed on the third planet of the Medusa System to study mirror colors. Their ship landed at the beginning of a narrow field of a flower farm. Mirror flowers begin to sprout after midnight. The kind farm workers provided the crew with a plan for the germination of flowers in the form of a germination point and time. The crew of the ship needs to leave the planet at the next midnight. The ship's exploration team can move around the planet at a maximum speed of vmax. The group needs time d to study one flower. It is necessary to explore the flower all at once, it will not be possible to return to it later. Flowers germinate the later, the farther they are located from the beginning of the field. At one point, only one flower sprouts, and each flower sprouts at its own moment in time. No two flowers sprouted at the same time.
The crew team wants to determine the point in time when the research team can return to the ship by examining all the flowers in as little time as possible.

Input
The program receives several lines as input. The first line contains 2 integers separated by one space: vmax (in cm/min) and d (in minutes) , 0 < vmax <= 200, 0 <= d <= 500.
The second line contains a single number N – number of flowers (in pieces). 0 <= N <= 1400 if d = 0, otherwise 0 <= N <= 200.
Then there are N lines, each of which contains two numbers separated by a space: integer xi – the distance from the flower to the beginning of the field (in centimeters), 0 <= xi <= 32767, and the number ti  – moment of flower germination (in hh:mm format). The pairs are listed in ascending order of distance.

Imprint
Print the time the research team returned to the ship (in hh:mm format), rounded up to whole minutes.

Notes
1. There are 60 minutes in an hour, 24 hours in a day.
2. Time in a day changes from 00:00 to 23:59.
3. We can assume that the research team does not change direction until they reach the last flower.

 
Examples
# Input Output
1
3 1
1
100 00:01
01:08