n x n matrix and solving for the shortest path move in only 3 directions. I attached the text file explaining more.