eolymp
bolt
Try our new interface for solving problems
Problems

Hamster 2

Hamster 2

\includegraphics{https://static.e-olymp.com/content/d4/d4b8a4f7fde70571c2fd97b7d73a8f84943cc20a.jpg} There is a competition of flying hamsters in Hamsterburg. Each competing hamster is thrown from a sling. The initial speed of the hamsters is \textbf{V_0} m/s. Free fall acceleration is \textbf{g} = \textbf{10} m/s^2. There is no air friction. The size of the hamster and the sling are negligible. When the hamster is thrown from the sling its altitude is \textbf{0} meters. There is a number of vertical gates in the air. Each gate has a lower and an upper bound. If we mark the points directly under each of the gates on the ground -- those points are positioned in one line and on one side from the starting point. A hamster gets as many points as the amount of gates he flies through. You have to calculate the maximal amount of points that a hamster can get in one flight. It is considered that a hamster flies through the gate if he touches the bounds of the gate during the flight of flies between the bounds. \InputFile The first line of the input contains number \textbf{0} < \textbf{t} <= \textbf{10} the amount of test cases. The description of each test case follows. Each test starts with two integers \textbf{0} < \textbf{V_0} <= \textbf{1000} -- the initial speed of the hamster and \textbf{0} < \textbf{n} <= \textbf{20000} -- the total amount of gates. Each of the next \textbf{n} lines contains the description of one of the gates: three integers \textbf{0} < \textbf{x} <= \textbf{10000} -- the distance from the starting point to the point directly under the gate, \textbf{0} < \textbf{y_1} <= \textbf{y_2} <= \textbf{10000} -- lower and upper bound of the gate. \OutputFile For each test case output the maximal amount of gates a hamster can fly through in one flight on a separate line.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
10 2
3 1 2
3 2 3
10 3
1 1 1
2 2 3
3 4 6
10 3
1 1 2
2 3 4
3 5 6
Output example #1
2
1
2
Source All-Ukrainian Collegiate Programming Contest Semi-Final 2010