add python solution for matrix traversal