A grid has r rows and c columns of integers. Every row reads in non-decreasing order left to right, and every column reads in non-decreasing order top to bottom. Find the k-th smallest value among all r * c entries, counting duplicates.
Input format
Line 1: three integers r, c, and k.
Next r lines: each with c space-separated integers, the grid rows.
Output format
A single integer: the k-th smallest entry in the grid.
Constraints
- 1 <= r <= 100
- 1 <= c <= 100
- 1 <= k <= r * c
- -1000000000 <= each entry <= 1000000000
- rows are non-decreasing left to right; columns are non-decreasing top to bottom