#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; template struct value_compression : vector { bool built = false; using VS = vector; using VS::VS; value_compression(vector v) : vector(move(v)) {} void build() { sort(this->begin(), this->end()); this->erase(unique(this->begin(), this->end()), this->end()); built = true; } template void convert(T first, T last) { assert(built); for (; first != last; ++first) *first = (*this)(*first); } int operator()(S x) { assert(built); return lower_bound(this->begin(), this->end(), x) - this->begin(); } void clear() { this->clear(); built = false; } }; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; struct S { ll xl, xr, yl, yr; }; vector sq(n); rep(i, n) { ll x, y, h; cin >> x >> y >> h; ll rad = m - h; ll x1 = x - rad, y1 = y; ll x2 = x + rad, y2 = y; sq[i] = {x1 - y1, x2 - y2, x1 + y1, x2 + y2}; } value_compression vcx, vcy; for (auto [xl, xr, yl, yr] : sq) { vcx.emplace_back(xl); vcx.emplace_back(xr); vcy.emplace_back(yl); vcy.emplace_back(yr); } vcx.build(); vcy.build(); int h = vcx.size(), w = vcy.size(); VVI d(h, VI(w)); for (auto [xl, xr, yl, yr] : sq) { xl = vcx(xl); xr = vcx(xr); yl = vcy(yl); yr = vcy(yr); d[xl][yl]++; d[xl][yr]--; d[xr][yl]--; d[xr][yr]++; } rep(i, h) rep(j, w - 1) d[i][j+1] += d[i][j]; rep(i, h - 1) rep(j, w) d[i+1][j] += d[i][j]; vector ans(n + 1); const mint inv2 = mint(2).inv(); rep(i, h) rep(j, w) if (d[i][j]) { ans[d[i][j]] += mint(vcx[i+1] - vcx[i]) * (vcy[j+1] - vcy[j]) * inv2; } for (int i = 1; i <= n; i++) cout << ans[i].val() << '\n'; }