#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=111;
int x[maxn],y[maxn],sum[maxn],ans=0,Ans=0;
char ch;
int n,d;
int read(){
int num=0;ch=getchar();
while (ch<'!') ch=getchar();
while (ch>='0'&&ch<='9'){num=num*10+ch-'0';ch=getchar();}
return num;
}
int main(){
freopen("wireless.in","r",stdin);
freopen("wireless.out","w",stdout);
d=read(); n=read();
for (int i=1;i<=n;++i){
x[i]=read();
y[i]=read();
sum[i]=read();
}
for (int i=0;i<=128;++i)
for (int j=0;j<=128;++j){
int l=max(0,i-d);
int r=min(i+d,128);
int s=max(0,j-d);
int xia=min(128,j+d);
int tot=0;
for (int k=1;k<=n;++k)
if (x[k]>=l&&x[k]<=r&&y[k]>=s&&y[k]<=xia)
tot+=sum[k];
if (tot>ans){
ans=tot; Ans=1;
}else if (tot==ans) Ans++;
}
printf("%d %d",Ans,ans);
//system("pause");
}
/*1 2
4 4 10
6 6 20*/