Convert matrix format magic squares into line format