#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

struct Rational
{
    int64_t n, d;
    
    bool operator<(const Rational &other) const
    {
        return n * other.d < other.n * d;
    }
};

struct SegTree
{
    int l, r;
    int64_t val;
    SegTree *left, *right;
    
    SegTree(int ll, int rr) : l(ll), r(rr)
    {
        if(l == r)
        {
            left = right = NULL;
            val = 0;
        }
        else
        {
            int mid = l + (r-l)/2;
            left = new SegTree(l, mid);
            right = new SegTree(mid+1, r);
            val = 0;
        }
    }    
    
    void insert(int x, int64_t v)
    {
        if(x < l || x > r)
            return;
        if(left)
        {
            left->insert(x, v);
            right->insert(x, v);
            val = left->val + right->val;
        }
        else
            val += v;
    }
    
    int64_t sum(int ql, int qr)
    {
        if(qr < l || ql > r)
            return 0;
        if(ql <= l && qr >= r)
            return val;
        return left->sum(ql, qr) + right->sum(ql, qr);
    }
    
    ~SegTree()
    {
        delete left;
        delete right;
    }
};

struct Point
{
    int64_t x, y;
    int idx;
    int slopeidx;
    int64_t v;
    Rational slope1, slope2;       
};

int main()
{
    int64_t N, X;
    std::cin >> N >> X;
    
    std::vector<Point> points;
    
    for(int i=0; i<N; i++)
    {
        Point p;
        std::cin >> p.x >> p.y >> p.v;
        p.idx = i;
        
        p.slope1 = Rational{p.x, p.y};
        p.slope2 = Rational{p.x - X, p.y};
        points.push_back(p);
    }
    
    std::sort(points.begin(), points.end(),
        [](const Point &p1, const Point &p2) -> bool
        {
            return p1.slope1 < p2.slope1;
        });
        
    for(int i=0; i<N; i++)
        points[i].slopeidx = i;
    
    std::sort(points.begin(), points.end(),
        [](const Point &p1, const Point &p2) -> bool
        {
            return p1.slope2 < p2.slope2;
        });
    
    std::vector<int64_t> answers(N);
    
    SegTree *t = new SegTree(0, N-1);
    
    for(int i=0; i<N; i++)
    {
        answers[points[i].idx] = t->sum(points[i].slopeidx, N-1);
        t->insert(points[i].slopeidx, points[i].v);
    }
        
    for(int i=0; i<N; i++)
        std::cout << answers[i] << std::endl;
        
    delete t;
}
