// Arup Guha
// 11/6/2010
// Solution to 2010 SE Regional Problem A: Ballons
import java.util.*;

public class a implements Comparable<a> {
	
	// Our object just stores the distance to both balloon places
	// and how many balloons our team needs.
	public int distR1;
	public int distR2;
	public int numBalloons;
	
	public a(int k, int da, int db) {
		numBalloons = k;
		distR1 = da;
		distR2 = db;
	}
	
	// What matters is the DIFFERENCE between the distances to the two places.
	// ie. RELATIVE DISTANCE matters.
	public int compareTo(a other) {
		return Math.abs(other.distR1-other.distR2) - Math.abs(distR1-distR2);
	}
	
	public static void main(String[] args) {
		
		Scanner stdin =new Scanner(System.in);
		
		int n = stdin.nextInt();
		int numBalA = stdin.nextInt();
		int numBalB = stdin.nextInt();
		
		// Go through each case.
		while (n != 0 || numBalA != 0 || numBalB != 0) {
			
			a[] teams = new a[n];
			
			// Go through all the team information and store in the array.
			for (int i=0; i<n; i++) {
				int k = stdin.nextInt();
				int da = stdin.nextInt();
				int db = stdin.nextInt();
				teams[i] = new a(k,da,db);
			}
			
			System.out.println(solve(teams, numBalA, numBalB));
			
			// Read in data for the next case.
			n = stdin.nextInt();
			numBalA = stdin.nextInt();
			numBalB = stdin.nextInt();
		}
	}
	
	// Greedy solution =)
	public static int solve(a[] teams, int A, int B) {
		
		// Sort by difference, greatest to least.
		Arrays.sort(teams);
		
		int distance = 0;
		
		// Go through each team, in this order, handing out balloons.
		for (int i=0; i<teams.length; i++) {
			int balA = 0;
			
			// We are closer to balloon dispensary A. But we can't get 
			// more balloons than they have there.
			if (teams[i].distR1 < teams[i].distR2)
				balA = Math.min(A, teams[i].numBalloons);
			else
				balA = teams[i].numBalloons - Math.min(B, teams[i].numBalloons);
				
			// Rest of the balloons MUST come from B.
			int balB = teams[i].numBalloons - balA;
			
			// Update our total distance and the number of balloons left.
			distance = distance + balA*teams[i].distR1 + balB*teams[i].distR2;
			A -= balA;
			B -= balB;
		}	
			
		return distance;
	}
}