let z()=List.map int_of_string(Str.split(Str.regexp" ")(read_line()))open Array;;match z()with[r;c]->(let a=make_matrix(r+1)(c+1)0in for i=0to r-1do let x=of_list(z())in for j=0to c-1do a.(i).(j)<-x.(j);a.(i).(c)<-a.(i).(c)+x.(j)done done;for i=0to c-1do for j=0to r-1do a.(r).(i)<-a.(r).(i)+a.(j).(i)done;a.(r).(c)<-a.(r).(c)+a.(r).(i)done;for i=0to r do for j=0to c do Printf.printf(if j=0then"%d"else" %d")a.(i).(j)done;print_newline()done)|_->()