Making progress! Stored as a graph with edges and nodes!

Most convoluted solution I can think of looks something like...

1   m   1   1   1   m
1   m   1   m   1   m
1   m   1   m   1   m
1   m   1   m   1   m
1   1   1   m   1   1

m = sys.maxint
so the solution snakes around the matrix.