#include<iostream> #include<cmath> #include<cstdlib> #include<cstdio> #include<algorithm> #include<string> #include<cstring> #include<vector> #include<deque> #include<stack> using namespace std; int f[130][130],a[130][130],d,n,x[25],y[25],s[25],cnt = 0,maxn; int main(){ freopen("wireless.in","r",stdin); freopen("wireless.out","w",stdout); scanf("%d%d",&d,&n); for(int i = 0;i < n;i++) scanf("%d%d%d",&x[i],&y[i],&s[i]); for(int i = 0;i < 129;i++) for(int j = 0;j < 129;j++) for(int k = 0;k < n;k++) if(x[k]>=i-d&&x[k]<=i+d&&y[k]>=j-d&&y[k]<=j+d) f[i][j] += s[k]; for(int i = 0;i < 129;i++) for(int j = 0;j < 129;j++) maxn = max(maxn,f[i][j]); for(int i = 0;i < 129;i++) for(int j = 0;j < 129;j++) if(f[i][j]==maxn) cnt++; printf("%d %d",cnt,maxn); return 0; }