School Ball
During the school ball, there are plans to launch m identical balloons. n enthusiastic senior students, each with different levels of stamina and endurance, have volunteered to fill them with air. For the i-th student, it takes A[i] minutes to fill one balloon. After inflating B[i] balloons, they need to take a break lasting C[i] minutes (i=1..N). We need to determine the minimum time (in minutes) required to inflate all the balloons, ensuring all participants perform optimally.
Input data: The first line contains the integers M and N (1<=M<=1000, 1<=N<=100). The following N lines each contain three integers: A[i], B[i], and C[i] respectively (1<= A[i], B[i], C[i] <=100, i=1..N).
Output data: The minimum time in minutes required to inflate all the balloons.