// Arup Guha
// 3/11/2023
// Solution to 2022 SER D1 Problem: Triangle Containment

import java.util.*;
import java.io.*;

public class trianglecontainment {

	public static int n;
	public static long[] xList;
	public static long[] yList;
	
	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		long xOff = Long.parseLong(tok.nextToken());
		
		pt[] left = new pt[n];
		pt[] right = new pt[n];
		
		// Read points "relative" to start.
		for (int i=0; i<n; i++) {
			tok = new StringTokenizer(stdin.readLine());
			long x = Long.parseLong(tok.nextToken());
			long y = Long.parseLong(tok.nextToken());
			long w = Long.parseLong(tok.nextToken());
			left[i] = new pt(x, y, w, i);
			right[i] = new pt(x-xOff, y, w, i);
		}
		
		// Sort and create a map for the right points.
		Arrays.sort(left);
		Arrays.sort(right);
		int[] rightMap = new int[n];
		for (int i=0; i<n; i++)
			rightMap[right[i].id] = i;
		
		// This is the bound for the query for each i.
		int[] bound = new int[n];
		for (int i=0; i<n; i++)
			bound[i] = rightMap[left[i].id];
		
		// Initial bit is full.
		bit myb = new bit(n+1);
		for (int i=0; i<n; i++) 
			myb.add(i+1, right[i].w);
		
		// Store all answers here.
		long[] res = new long[n];
		
		// Sweep through points from left end, by angle.
		for (int i=0; i<n; i++) {
			
			// This point doesn't count.
			long sub = left[i].w;
			int pos = bound[i]+1;
			myb.add(pos, -sub);
			
			// This is the answer to my query, so save it.
			long tmp = myb.tot(pos);
			res[left[i].id] = tmp;
		}
		
		// Ta da!
		StringBuilder sb = new StringBuilder();
		for (int i=0; i<n; i++) sb.append(res[i]+"\n");
		System.out.print(sb);
	}

}

class pt implements Comparable<pt> {

	public long x;
	public long y;
	public int id;
	public long w;
	
	public pt(long myx, long myy, long myw, int i) {
		x = myx;
		y = myy;
		w = myw;
		id = i;
	}
	
	// Sort by angle from 180 downto 0.
	public int compareTo(pt other) {
		if (x<0 && other.x>=0) return -1;
		if (other.x<0 && x>=0) return 1;
		if (y*other.x > other.y*x) return -1;
		if (other.y*x > y*other.x) return 1;
		return 0;
	}
}

class bit {
	
	public int n;
	public long[] sum;
	
	public bit(int sz) {
		int i = 1;
		while ( (1<<i) <sz+1) i++;
		n = (1<<i);
		sum = new long[n];
	}
	
	// Sum 1 to k.
	public long tot(int k) {
		long res = 0;
		while (k>0) {
			res += sum[k];
			k -= (k&(-k));
		}
		return res;
	}
	
	public void add(int k, long v) {
		while (k < n) {
			sum[k] += v;
			k += (k&(-k));
		}
	}
}