

If we have 3 lists as [1, 10, 11], [2, 3, 20], [5, 6, 12] then the [1, 5] is the range that includes 1 from the first list, 2,3 from the second list, and 5 from the third list i.e, this range contains at least one element from each list.
The first line of the input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains two space-separated positive integers ‘N’ and ‘K’ denoting the number of the elements present in each list and the number of the lists respectively.
In the next ‘K’ lines of each test case, the ith line contains ‘N’ space-separated integers denoting the elements of the ith list.
For every test case, print a positive integer denoting the minimum length of the range.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= 'T' <= 50
1 <= 'N' <= 10 ^ 4
1 <= 'K' <= 10 ^ 4
1 <= 'N' * 'K' <= 10 ^ 4
1 <= 'VAL' <= 10 ^ 9
Where 'VAL' is the value of any element of any list.
Time Limit: 1 sec
Approach:
Approach:
Approach: