var
a:array[-1000..1000,-1000..1000]of longint;
b,c,m,i,j,k,d:longint;
sum,max,n:qword;
begin
assign(input,'wireless.in');
assign(output,'wireless.out');
reset(input);
rewrite(output);
read(m,d);
for i:=1 to d do
begin
read(b,c,k);
a[b,c]:=k;
end;
for i:=0 to 128 do
for j:=0 to 128 do
begin
for b:=-m to m do
for c:=-m to m do
n:=n+a[i+b,j+c];
if n>max then begin max:=n; sum:=1; end
else if n=max then inc(sum);
n:=0;
end;
write(sum,' ',max);
close(input);
close(output);
end.