#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int lim = 1e5 + 5;
struct fenwick {
ll a[lim];
fenwick() {
memset(a, 0, sizeof(a));
}
void upd(int idx, int val) {
++idx;
while(idx < lim) {
a[idx] += val;
idx += idx&-idx;
}
}
ll query(int idx) {
++idx;
ll ret = 0;
while(idx) {
ret += a[idx];
idx -= idx&-idx;
}
return ret;
}
ll query(int l, int r) {
return query(r) - (l == 0 ? 0 : query(l - 1));
}
};
pair<int, int> pvt, l, r;
struct point {
int x, y, pos, treasure;
};
double compute(point x) {
x.x -= pvt.fi;
x.y -= pvt.se;
return x.x / (double)x.y;
}
bool cs(point x, point y) {
return compute(x) < compute(y);
}
int main() {
int n, buang;
cin >> n >> buang;
l = mp(0, 0), r = mp(buang, 0);
point a[n];
pair<int, int> ori[n];
for(int i = 0; i < n; ++i) {
int x, y, v;
cin >> a[i].x >> a[i].y >> a[i].treasure;
ori[i].fi = a[i].x;
ori[i].se = a[i].y;
}
sort(a, a + n, cs);
for(int i = 0; i < n; ++i) {
a[i].pos = i;
}
pvt = r;
sort(a, a + n, cs);
map<pair<int, int>, ll> ans;
fenwick bit;
for(auto x : a) {
ans[mp(x.x, x.y)] = bit.query(x.pos, n);
bit.upd(x.pos, x.treasure);
}
for(auto i : ori) {
cout << ans[i] << endl;
}
}s