AdvancedRating 1900
Smallest Range Touching Every List
k sorted lists are given. Find the smallest range [a, b] containing at least one number from every list (smaller b − a wins; on a tie, smaller a). Print a and b.
Input
k, then k lines (each starts with its length).
Output
Two integers.
Sample 1
Input
3 5 4 10 15 24 26 4 0 9 12 20 4 5 18 22 30
Output
20 24
Sample 2
Input
3 3 1 2 3 3 1 2 3 3 1 2 3
Output
1 1
Output appears here