IOI'94 - Day 2 - Problem 2: The Buses

A man arrives at a bus stop at 12:00. He remains there during 12:00-12:59. The bus stop is used by a number of bus routes. The man notes the times of arriving buses. The times when buses arrive are given. Find the schedule with the fewest number of bus routes that must stop at the bus stop to satisfy the input data. For each bus route, output the starting time and the interval.

Input Data

The input file, INPUT.TXT, contains a number n (n<=300) telling how many arriving buses have been noted, followed by the arrival times in ascending order. Our example:
0 3 5 13 13 15 21 26 27 29 37 39 39 45 51 52 53

Output Data

Write a table to the OUTPUT.TXT file with one line for each bus route. Each line in the file gives the time of arrival for the first bus and the time interval in minutes. The order of the bus routes does not matter. If there are several solutions, only one is required. Our example gives:
0 13
3 12
5 8