#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N >> M; vector X(N), Y(N), H(N); rep(i,N) cin >> X[i] >> Y[i] >> H[i]; vector,pair>>> dp(N+1); set Us,Vs; rep(i,N){ ll d = M-H[i]; ll s = X[i]+Y[i]; ll m = X[i]-Y[i]; Us.insert(s+d); Us.insert(s-d); Vs.insert(m+d); Vs.insert(m-d); } vector U,V; for(auto u:Us){ U.pb(u); } for(auto v:Vs){ V.pb(v); } int A = sz(U), B = sz(V); vector> S(A,vector(B,0)); rep(i,N){ ll d = M-H[i]; ll s = X[i]+Y[i]; ll m = X[i]-Y[i]; int a1 = lower_bound(all(U),s-d)-U.begin(); int a2 = lower_bound(all(U),s+d)-U.begin(); int b1 = lower_bound(all(V),m-d)-V.begin(); int b2 = lower_bound(all(V),m+d)-V.begin(); S[a1][b1]++; S[a1][b2]--; S[a2][b1]--; S[a2][b2]++; } rep(i,A) rep(j,B-1) S[i][j+1]+=S[i][j]; rep(i,A-1) rep(j,B) S[i+1][j]+=S[i][j]; vector ans(N+1,0); rep(i,A-1){ rep(j,B-1){ ans[S[i][j]] += ((U[i+1]-U[i])%mod) * ((V[j+1]-V[j])%mod) % mod; ans[S[i][j]] %= mod; } } rep(i,N){ if(ans[i+1]%2) ans[i+1] += mod; ans[i+1] /= 2; cout << ans[i+1] % mod << '\n'; } return 0; }