You are the Supreme Ninja Warrior on a visit to Ninja Class, and class can be represented as a rectangular matrix ‘ARR’ of ‘N’ rows and ‘M’ columns.
Each Ninja has a skill level, and each element in matrix ‘ARR’ represents the skill level of the Ninja present in the class. More formally, ‘ARR[i][j]’ represents the skill level of Ninja sitting in the ‘jth’ column of the ‘ith’ row.
A ninja is said to be ‘Chunin’ if he has maximum skill among all Ninjas in his column and minimum skill level among all Ninjas in his row.
Can you find all the ‘Chunin’ Ninjas present in the class?
Example :
N = 3 M = 3
ARR = [ [3, 4, 5], [2, 7, 6] , [1, 2, 4] ]
Ninja at Position (0,0) has maximum skill in ‘0th’ column and minimum skill in ‘0th’ row, it is the only Chunin Ninja.
So, we return [ 3 ] as our ‘ANS’.
Input Format :
The first line contains an integer ‘T’ denoting the number of test cases. Then each test case follows.
The first input line of each test case contains two integers, ‘N’ and ‘M’, denoting the number of rows and columns in the matrix ‘ARR’, respectively.
Each of the following for each test case. Print ‘N’ lines contain ‘M’ space-separated integers denoting the skill level of Ninjas.
Output format :
For each test case, print all ‘Chunin’ Ninja present in the class. Print the output of each test case in a new line.
Note :
You don’t need to print anything. It has already been taken care of. Just implement the given function.
Constraints :
1 <= T <= 10
1 <= N , M <= 10^5
0 <= ARR[i][j] <= 10^9
Sum of N*M over all Test cases <= 10^5
Time Limit: 1 sec