The Doomsday Clock is a universally-recognized symbolic clock face, representing a countdown to possible political related global catastrophe (nuclear war or climate change). It has been maintained since 1947 by the members of the Science and Security Board of the Bulletin of the Atomic Scientists1, who are in turn advised by the Governing Board and the Board of Sponsors, including 18 Nobel Laureates. The closer they set the Clock to midnight, the closer the scientists believe the world is to global disaster. The Clock — which hangs on a wall in a Bulletin's office in the University of Chicago — originally represented an analogy for the threat of global nuclear war. However, since 2007 it has also reflected climate change and new developments in the life sciences and technology that could inflict irrevocable harm to humanity.

Doomsday ClockBulletin of the Atomic Scientists
Some scientists of the Bulletin of the Atomic Scientists present the Doomsday Clock to the general public in 1947.

In 1947, during the Cold War, the Clock was started at seven minutes to midnight and was subsequently advanced or rewound per the state of the world and nuclear war prospects. The Clock is not set and reset in real time as events occur. Rather than respond to each and every crisis as it happens, the Science and Security Board meets twice annually to discuss global events in a deliberative manner. The closest nuclear war threat, the Cuban Missile Crisis in 1962, reached crisis, climax, and resolution before the Clock could be set to reflect that possible doomsday. In 1991 the Clock was set seventeen minutes before midnight as the United States and the Soviet Union signed the Strategic Arms Reduction Treaty, after which the Soviet Union dissolved. This is the Clock's earliest setting since its inception.

Verloop van de doemsdagklok
Progress of the Doomsday Clock since its inception in 1947 until 2007.

The Doomsday Clock also works as a barometer that indicates how positive people saw the future at certain times in recent history, as evidenced by the 1969 hit song In the Year 2525 (Exordium et Terminus)2 by the American pop-rock duo Zager & Evans.

Assignment

We represent progress of the Doomsday Clock as a string having the following format.

1947 7,1949 3,1953 2,1960 7,1963 12,1968 7,1969 10,1972 12,1974 9,1980 7,1981 4,1983 3,1984 3

This string representation contains a comma-separated sequence of Clock adjustments. Each adjustment is described as the year in which the Clock was reset, followed by a space and the minutes before midnight to which the Clock was set. The Clock adjustments are listed in chronological order, and you may assume that the Clock is never reset twice a year.

The figure below shows a graphical representation of the string representation shown above. If we represent time on a 24-hour clock, it's easy to see from the figure that the Doomsday Clock for example was set to 23:57 in 1950, to 23:48 in 1965 and to 23:51 in 1974. We will always consider the adjusted time in years where the clock was reset.

Verloop van de doemsdagklok
Doomsday Clock graph, 1947-1986. The lower the graph, the higher probability of technology-induced catastrophe.

Your task is to determine the threat in a given year, given the progress of the Doomsday Clock. This threat is expressed as a timestamp on a 24-hour clock.

Example

>>> clock(0)
'00:00'
>>> clock(7)
'23:53'
>>> clock(123)
'21:57'

>>> adjustments = '1947 7,1949 3,1953 2,1960 7,1963 12,1968 7,1969 10,1972 12,1974 9,1980 7,1981 4,1983 3,1984 3'
>>> doomsdayclock = progress(adjustments)
>>> doomsdayclock
((1947, '23:53'), (1949, '23:57'), (1953, '23:58'), (1960, '23:53'), (1963, '23:48'), (1968, '23:53'), (1969, '23:50'), (1972, '23:48'), (1974, '23:51'), (1980, '23:53'), (1981, '23:56'), (1983, '23:57'), (1984, '23:57'))

>>> threat(1974, doomsdayclock)
'23:51'
>>> threat(1950, doomsdayclock)
'23:57'
>>> threat(1965, doomsdayclock)
'23:48'