#include #define all(x) x.begin(), x.end() #define MOD 998244353ll using namespace std; using ll = long long; ll powmod(ll a, ll n){ ll ret = 1; while(n){ if (n & 1) { ret = ret * a % MOD; } a = a * a % MOD; n >>= 1; } return ret; } const ll INV2 = powmod(2, MOD - 2); void set_XY(ll n, ll m, vector& X1, vector& Y1, vector& X2, vector& Y2, vector& X, vector& Y) { for(int i = 0; i < n; ++i){ ll x, y, h; cin >> x >> y >> h; ll d = m - h; ll x1 = (x - d) - y, y1 = (x - d) + y; X1.push_back(x1); Y1.push_back(y1); X.push_back(x1); Y.push_back(y1); ll x2 = (x + d) - y, y2 = (x + d) + y; X2.push_back(x2); Y2.push_back(y2); X.push_back(x2); Y.push_back(y2); } sort(all(X)); X.erase(unique(all(X)), X.end()); sort(all(Y)); Y.erase(unique(all(Y)), Y.end()); } int main(void) { ll n, m; cin >> n >> m; vector X1 = {}, Y1 = {}, X2 = {}, Y2 = {}, X = {}, Y = {}; set_XY(n, m, X1, Y1, X2, Y2, X, Y); int w = X.size(), h = Y.size(); vector > dp(w, vector(h)); for(int i = 0; i < n; ++i){ int x1 = lower_bound(all(X), X1[i]) - X.begin(); int x2 = lower_bound(all(X), X2[i]) - X.begin(); int y1 = lower_bound(all(Y), Y1[i]) - Y.begin(); int y2 = lower_bound(all(Y), Y2[i]) - Y.begin(); dp[x1][y1]++; dp[x2][y1]--; dp[x1][y2]--; dp[x2][y2]++; } for(int i = 0; i < w; ++i){ for(int j = 1; j < h; ++j){ dp[i][j] += dp[i][j - 1]; } } for(int i = 1; i < w; ++i){ for(int j = 0; j < h; ++j){ dp[i][j] += dp[i - 1][j]; } } vector area(n + 1); for(int i = 0; i < w - 1; ++i){ for(int j = 0; j < h - 1; ++j){ if(dp[i][j] < 1){ continue; } area[dp[i][j]] += ((X[i + 1] - X[i]) % MOD) * ((Y[j + 1] - Y[j]) % MOD) % MOD; } } for(int i = 1; i < n + 1; ++i){ ll ans = area[i] % MOD * INV2 % MOD; cout << ans << endl; } return 0; }