Problem

6 /12


Minimum and maximum in the matrix

Problem

Write a program that finds the minimum and maximum elements in a matrix. If the matrix has several identical minimum (maximum) elements, you need to find the indices of the first such element in the order of traversal along the lines: from left to right, from top to bottom.

Input 
The first line contains the dimensions of the matrix separated by a space: the number of rows N and the number of columns M  (\(1 <= N , M <= 100\)). The following N lines contain matrix rows, each – by M natural numbers separated by spaces.


Imprint 
On the first line, the program should print the indexes of the minimum element (row and column), and then – its meaning. Numbering of rows and columns starts from one. All numbers are separated by spaces. The second line displays information about the maximum element in the same format.
 

Example
# Input Output
1 4 5
1 3 2 54 24
75 12 3 46 9
13 26 56 9 12
14 90 97 6 34
1 1 1
4 3 97