Print the elements of a matrix in cyclic order