# Message from C, C++ discussions

December 2019

Given a matrix mxn matrix(m,n>3).You have to perform the following operations:

i) Find the same consecutive numbers in the matrix either vertically, horizontally or diagonally such that atleast four consecutive nos. are there.

ii) If there are more than one such set of numbers then print an integer outnum which is the minimum of such consecutive nos.

iii) If no such no. exists print -1.

Input Format

Input: first line contains two space separated integer m and n. Second m lines have n space separated integers.

Constraints

2<=m,n<=1000

Output Format

Output: an integer outnum or -1 if no such nos. exists

Sample Input 0
[29/12, 8:43 PM] FaizI New: output:_
[29/12, 8:44 PM] FaizI New: 5 6
7 8 9 5 4 2
5 7 9 4 5 2
6 8 7 9 2 2
1 4 2 7 6 2
1 1 1 1 1 4
Sample Output 0

1
Explanation 0

Here, There are two number such nos. which is consecutive for 4 times either in row ,column ,diagonals(i.e 1 and 2). Now print the min of( 1,2) ,which is 1.

Message permanent page

—

— User Sultan has 1/2 warnings; be careful!
The latest warn was because:

Message permanent page

— Pls help i hv exams tommrow.

— /report