#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ long long N,M; cin>>N>>M; vector x(N),y(N),h(N); rep(i,N){ cin>>x[i]>>y[i]>>h[i]; long long t = x[i]; long long s = y[i]; x[i] = t+s; y[i] = t-s; } vector> a,b,c,d; vector> tx,ty; rep(i,N){ if(h[i]>M)continue; long long rem = M - h[i]; a.emplace_back(-rem,x[i]); b.emplace_back(rem,x[i]); c.emplace_back(-rem,y[i]); d.emplace_back(rem,y[i]); tx.emplace_back(-rem,x[i]); tx.emplace_back(rem,x[i]); ty.emplace_back(-rem,y[i]); ty.emplace_back(rem,y[i]); } //tx.emplace_back(Inf32,Inf32); //ty.emplace_back(Inf32,Inf32); sort(tx.begin(),tx.end(),[&](pair x,pair y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } }); sort(ty.begin(),ty.end(),[&](pair x,pair y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } }); /* rep(i,tx.size()){ cout<(ty.size()+1)); rep(i,a.size()){ int aa = distance(tx.begin(),lower_bound(tx.begin(),tx.end(),a[i], [&](pair x,pair y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); int bb = distance(tx.begin(),upper_bound(tx.begin(),tx.end(),b[i], [&](pair x,pair y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); int cc = distance(ty.begin(),lower_bound(ty.begin(),ty.end(),c[i], [&](pair x,pair y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); int dd = distance(ty.begin(),upper_bound(ty.begin(),ty.end(),d[i], [&](pair x,pair y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); imos[aa][cc]++; imos[aa][dd]--; imos[bb][cc]--; imos[bb][dd]++; } rep(i,tx.size()){ rep(j,ty.size()+1)imos[i+1][j] += imos[i][j]; } rep(i,tx.size()+1){ rep(j,ty.size())imos[i][j+1] += imos[i][j]; } vector ans(N+1); rep(i,tx.size()-1){ rep(j,ty.size()-1){ int num = imos[i][j]; if(num!=2)continue; cout<