Spartakiad for the Lazy
The renowned computer science teacher V.I. is famous not only for his students' achievements in computer science but also for his unique methods of motivating slackers (such as squats with a chair, push-ups from the floor, etc.). He plans to organize a school sports competition right after the Programming Cup. Each class must assemble a team of three students, selected from those V.I. considers slackers, to participate in the competition. The sports program includes the following exercises: pull-ups on a bar, push-ups from the floor, and squats with a chair. The competition consists of three rounds: the first round involves pull-ups on the bar, the second round involves push-ups from the floor, and the third round involves squats with a chair.
The competition jury has decided to implement a rating system.
After each round, an interim team rating is calculated by summing the points scored by the three team members in that exercise. Once all three rounds are completed, the jury determines the overall team rating, which is the sum of the interim ratings from each round. The team with the highest overall rating wins the competition.
Since the exercises vary in difficulty, the jury evaluates the results accordingly. Each pull-up earns the participant X
points, each push-up earns Y
points, and each squat earns Z
points. These criteria objectively reflect the difficulty of the exercises.
However, O.M., the class teacher of the "laziest" 9th grade, encountered some challenges while forming the team. The class has N
students, and the sports data for each student is known: A[i] - the number of pull-ups on the bar, B[i] - the number of push-ups from the floor, and C[i] - the number of squats. Despite having this data, determining the best team composition is quite challenging. Some students excel at pull-ups but struggle with push-ups, while others are the opposite. Your task is to assist O.M. in forming a team of three students to maximize the overall team rating in the competition.
Input
The first line contains three integers X
, Y
, and Z
(1 ≤ X, Y, Z ≤ 10^4), separated by spaces.
The second line contains an integer N
(3 ≤ N ≤ 10^5) – the number of students in the class.
Each of the following N
lines provides the sports data for each student in the class, containing three integers A[i], B[i], and C[i] (1 ≤ A[i], B[i], C[i] ≤ 10^4), separated by spaces.
Output
On the first line, output the maximum total rating that the students can achieve. On the second line, output three integers, separated by spaces, representing the indices of the students who should be in the team. Students are numbered consecutively, starting from one in the order of their data entry. If there are multiple solutions, any of them can be output.