BETA

#### Submissions: 690 Accuracy: 26.23%

Smallest range in K lists (Function Problem)

Given K sorted lists of integers of size N each, find the smallest range that includes at least one element from each of the K lists. If more than one such range's are found, print the first such range found.

```Input:
K = 3
A[] : [4, 7, 9, 12, 15]
B[] : [0, 8, 10, 14, 20]
C[] : [6, 12, 16, 30, 50]

Output:
The smallest range is [6 8]
Explanation: Smallest range is formed by number 7
from first list, 8 from second list and 6 from third list.
```

Input:
The first line of the input contains a single integer T denoting the number of test cases. For each test inputs will be given to the findSmallestRange function. The input's to the function are:

1.) A 2D-array(arr) of size K*N, where each row represents an individual list.

2.) An integer N denoting the size of list's.

3.) An integer K denoting the number of list's.

Output:
For each test case output in a single line two space separated integers denoting the required range.

Constraints:
1<=T<=50
1<=K,N<=500

Example:

Input:
2
5 3
1 3 5 7 9 0 2 4 6 8 2 3 5 7 11
4 3
1 2 3 4 5 6 7 8 9 10 11 12

Output:
1 2
4 9

Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa

##### It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result: