Turtle
The turtle's home is located at the start of a straight, narrow path where dandelions—her favorite food—are expected to grow. The turtle had a prophetic dream, revealing that after midnight, the dandelions would begin to sprout. She even dreamed of the exact time and location on the path where each dandelion would appear. At exactly midnight, the turtle set out from her home to eat all the dandelions and return by the next midnight.
The turtle can crawl at a speed up to v_max. She consumes a dandelion by stopping for d minutes. If she starts eating a dandelion but doesn't finish, it will wither, so it must be eaten in one sitting. The further the dandelions are from the start of the path, the later they sprout. No two dandelions sprout at the same location or time.
Your task is to determine the exact time when the turtle can return home after eating all the dandelions, minimizing the total time spent on the journey.
Input
The 1st line of the input contains 2 integers separated by a space: v_max (in cm/min) and d (in minutes).
(0 < v_{max }≤ 200, 0 ≤ d ≤ 500)
The 2nd line contains the integer N—the number of dandelions. 0 ≤ N ≤ 1400 when d = 0, otherwise 0 ≤ N ≤ 200.
Each of the following N lines contains: an integer x_i—the distance from the start of the path to the dandelion (in centimeters), 0 ≤ x_i_{ }≤ 32767, followed by a space and t_i—the time the dandelion sprouts (in hh:mm format). The pairs are listed in increasing order of distance.
The input guarantees that the turtle can eat all the dandelions and return home within a day.
Output
The output should be the time when the turtle returns home (in hh:mm format), rounded up to the nearest whole minute.