Johnny is trapped inside a matrix of numbers. The matrix is a grid with $M$ rows ($1 \le M \le 100$) and $N$ columns ($1 \le N \le 100$); every cell holds a single digit from $0$ to $9$.
Johnny may start at any cell in the first row, and to escape he must reach any cell in the last row (row $M$). He moves one step at a time up, down, left, or right; diagonal moves are not allowed.
Before he starts moving, Johnny chooses exactly three digits from $0$ to $9$ (a "trinity"). The three digits need not be distinct. Johnny may only stand on a cell whose digit is one of his three chosen digits, and this applies to his starting cell as well. Every cell along the path, from the starting cell in row $1$ to the finishing cell in row $M$, must contain one of the chosen digits.
Determine which trinity Johnny should choose.
The first line contains two integers $N$ and $M$.
Each of the next $M$ lines contains $N$ digits separated by single spaces, describing the grid one row at a time.
Print three integers separated by single spaces: the trinity of digits Johnny should choose in order to escape.
If at least one valid trinity exists, print the lexicographically smallest one, comparing the three digits as an ordered triple (so 0 0 0 comes before 0 0 1, which comes before 0 0 2, ..., which comes before 9 9 8, which comes before 9 9 9). The three digits need not be distinct.
If no trinity lets Johnny reach the last row, print -1 -1 -1.