SUMMIT - Find summits

no tags 

Given an altitudinal map (0 <= altitudes <= 100000) find the summits i.e. all points which are bigger than all their neighbours. There is at least one summit in each map.

Score is source length.

Input

The number n of maps (n<=50) in the first line.
Then for each map one line with its width w and height h (3<=w, h<=20) separated by a space. After this the h rows of the map.

Output

The space-separated summits in ascending order.

Example

Input:
2
3 3
71034 8558 65941
18265 1226 74076
71003 75481 28446
3 3
22360 72964 47891
75416 7746 80432
95606 4613 83341 Output: 71034 75481
83341 95606

hide comments
nadstratosfer: 2020-07-11 21:42:40

This surely deserves to be in Challenge section.


Added by:HWK
Date:2011-05-02
Time limit:1.981s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64