There are balls along a number line, each ball is represented by a point on the line. Ball moves at velocity () along this number line and is initially at point .
When two balls collide (occupy the same point along the number line), their velocities switch. For example, if ball with velocity collides with ball with velocity , ball will have velocity and ball will have velocity after the collision.
Given each ball's initial distinct position and velocity, find for each ball the sum of the floor of the times that ball collides with another ball. Formally, ball collides with another ball times in total at times . Print, for each ball.
It is guaranteed that whenever two balls collide, the signs of their velocities will be different ().
Input format
Output format
Print integers denoting the being the sum of the floors of each time ball collides with another ball.
Constraints
It is guaranteed that, in the given input, whenever two balls collide the signs of their velocities will be different.
It is guaranteed that the sum of over all test cases is less than or equal to .
No two pairs of balls collide at the same place at the same time.
In the first test case, the balls never collide so the total sum of times will be .
In the second test case, the ball collides exactly ones at , so the sum of the floor of times for each ball will be .
In the third test case, the first collision happens between the 2nd and 3rd balls at time . When they collide, the second ball and third ball switch velocities so the second ball is now traveling at velocity and the third ball is now traveling at velocity . The third ball never hits anything else so it's final value is . The second ball then hits the first ball at and then no balls ever collide again. Thus, the answer for the second ball is and the answer for the second ball is simply .