Picky Eater


Jasmine the Cat is a very picky eater. Some days she wants wet food, and other days she only has eyes for the dry stuff.

Over a long enough time period, however, Jackson has determined that Jasmine will eat exactly aa portions of wet food and bb portions of dry food.

Jackson has just received an email detailing all of the different discount bundles on offer at his nearest pet store. For bundle ii, he can purchase xix_i portions of wet food and yiy_i portions of dry food for cic_i dollars.

Jackson hates food wastage, so he wants to buy a combination of these bundles to receive exactly aa portions of wet food, and bb portions of dry food.

Jackson naturally also hates money wastage, so he would like to select these bundles to spend the least dollars possible.

Input

Input will begin with three integers nn, aa and bb. These are the number of bundles, the amount of wet food, and dry food that Jasmine will eat respectively.

The next nn lines contain the bundle information. Each line contains 3 integers xix_i, the amount of wet food in the bundle, yiy_i, the amount of dry food in the bundle, and cic_i, the cost of the bundle. Each bundle can be purchased multiple times, as the pet store has near-unlimited stock.

Output

Output should begin with a single integer, the total amount of dollars spent, CC. You should then output nn integers on separate lines, corresponding to the amount of times you will use each bundle. If multiple solutions exist, you can output any of them, as long as it buys exactly aa wet food, bb dry food, and minimises cost.

If it is not possible to purchase exactly aa wet food and bb dry food, your program should output only the integer -1.

Constraints

  • All inputs are integers,
  • 1n1001 \leq n \leq 100,
  • 0a,b2000 \leq a, b \leq 200,
  • 0xi,yi2000 \leq x_i, y_i \leq 200,
  • 0ci1090 \leq c_i \leq 10^9.

Example 1

Input 1
3 10 10
2 2 20
5 2 0
1 2 12
Output 1
56
1
1
3
Explanation

In this example, there are multiple ways to purchase the required 10 wet and 10 dry, but the cheapest way involves buying 1 of the first and second bundles, and 3 of the final. Total cost is 20+0+36 = 56.

Example 2

Input 2
2 0 0
1 2 4
2 1 4
Output 2
0
0
0
Explanation

In this example, Jasmine doesn't need any food, so it is cheapest not to buy anything!

Example 3

Input 3
2 0 4
1 1 5
0 3 5
Output 3
-1
Explanation

In this example, it is impossible to buy exactly 0 wet food and 4 dry food, so we output -1.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.