Given k non empty multiple sets, each multiple set only contains integers with absolute values not exceeding 10^9.
It is required to select exactly one number from each multiple set to form an array (a1,a2,…,ak) with a length of k.
Assuming d=max(a1,a2,…,ak)−min(a1,a2,…,ak).Please calculate the minimum d.
Each test contains multiple test cases.The first line of input contains a single integer t(1≤t≤10^6)---the number of test cases.The desc
The first line of each test case contains a single integer k(1≤k≤10^6) —— the number of multiple sets.
The following k lines of each test case first read in a parameter ci —— indicating the size of the i-th multiple set, followed by ci integers with absolute values not exceeding 10^9 —— indicating the elements of the i-th multiple set.
Guarantee that ∑i=1kci for each test case does not exceed 106106, the sum of ∑i=1kci for all test cases does not exceed 4×10^6.
3
2
1 6
3 -7 7 10
4
9 -5 -9 2 8 5 4 3 3 8
2 10 8
1 -7
3 1 6 10
1
1 9
1
15
0