Smallest Range Across Lists
You are given k sorted lists of integers. Find the narrowest range [a, b] (with a ≤ b) such that every list contains at least one value inside [a, b] (inclusive).
If several ranges achieve the smallest width b − a, output the one with the smallest a.
Values may repeat, both within a single list and across different lists.
Input
The first line contains an integer k (1 ≤ k ≤ 10^5) — the number of lists.
Each of the next k lines describes one list: an integer m_i (1 ≤ m_i), the length of the i-th list, followed by m_i integers in non-decreasing order, each in [−10^9, 10^9] — the elements of the list.
The total number of integers across all lists, Σ m_i, is at most 2·10^5.
Output
Print two integers a and b: the bounds of the narrowest range that contains at least one element from every list, choosing the smallest a among ranges of minimum width.
Notes
In the first example, the range [20, 24] contains 24 from the first list, 20 from the second list, and 22 from the third list, and no narrower range works.