Var
a : array [1..100,1..100] of longint;
n,m,i,j,sum,mnj : longint;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do read(a[i,j]);
sum:=0;
mnj :=1;
for i:=1 to n do
for j:=1 to m do
if (a[i,j] mod 3)=0 or ((a[i,j] mod 2)=0) then begin sum:=sum+a[i,j]); mnj:=mnj*a[i,j]; end;
writeln(sum,' ',mnj);
end.