start to end paths in matrix