Maga gives a hard problem to Alex. And Alex couldn't solve yet. Could you help him?
The grid is n by m. Each cell contains a unique number on it. Maga is at the left-top and wants to go to right-bottom. But there is a condition. Maga can go through only two way - right and down. And the path of your move is called the nodes you have passed through over them. The path is called the most beautiful if the following condition is satisfied: The sorted of the path has to be lexicographic smallest as possible as. Output the most beautiful path for given grid.
Input:
In the first line you are given two numbers: the dimensions of grid - n and m.
The next n lines contains m numbers. Each number is unique.
Output:
Output the most beautiful path.
Contraints:
1 <= n,m <= 1000
1 <= A[i][j] <= n*m, All of the numbers in the grid are unique.