Solves Matrix Paths