uses crt;
var a:array[1..100,1..100]of integer;
n,m,i,t1,t,ln:integer;
begin
clrscr;
readln(n,m);
for i:=1 to n do
for j:=1 to m do readln(a[i,j]);
t:=0;
for i:=1 to n do
for j:=1 to m do
t:=t+a[i,j];
writeln(t);
t1:=0;
for i:=1 to n do
begin
ln:=a[i,1];
for j:=1 to m do
if ln<a[i,j] then ln:=a[i,j];
t1:=t1+ln;
end;
writeln(t1);
readln;
end.