SP8391 BALL - The Ball
Description
In a coordinate plane, there are N horizontal conveyor belts, each moving either leftwards or rightwards. When the ball falls on a belt, the belt drags it in direction it's moving. When the ball reaches the end of the belt, it falls vertically downwards. For example, if the belt is moving rightwards and it ends in the unit square with x-coordinate 12, the ball will fall from the belt on the x-coordinate 13, and continue falling on the same x-coordinate until it falls on another belt or reaches the ground (the height of 0).
Frane drops a ball many times (from the height that is greater than any of the belt heights), from various x-coordinates, and your task is: for each ball Frane drops, determine the direction of each belt such that this ball falls on as many belts as possible.
This picture reprezents the first test example: 
Input Format
In the first line of input, there is an integer N (the number of conveyor belts, 1
In each of the next N lines, there are integers X1, X2, Y (X1
In the next line, there is an integer Q (the number of falling balls, 1
In the next Q lines there is an integer less than 10 $ ^{9} $ , reprezenting the x-coordinate of the unit square Frane drops the ball from.
Output Format
For each of the Q queries, output the greatest possible number of the conveyor belts visited by the ball.