How can I get a different answer in each row along the matrix?