Any help regarding the following problem!!!!

Problem statement:

A 2-dimensional array having equal number of rows and columns (i.e. a square matrix ) .Implement a function such that it returns the maximum product that can be formed from four adjacent numbers.numbers can be adjacent to each other in either of the given directions :up,down,left,right diagonal or anti-diagonal.Ensure that four adjacent numbers are choosen in such a way that the direction doesnt change while choosing the number.

assume ‘n’>=4

Example:

input:

5
1 2 3 4 5 
6 7 8 9 1
2 3 4 5 6
7 8 9 1 0
9 6 4 2 3

output:
3024

explanation:
here the numbers 6,7,8,9 in the second row,which are horizontally adjacent form the product 3024 which is the maximum product of any four adjacent numbers in the given array

sample input

6
2 4 6 8 10 12
3 6 9 1 15 18 
4 8 2 6 20 24 
5 1 5 2 25 30
6 1 8 4 30 36
7 4 1 8 35 42

sample output
1088640