Asteroid Collision

2

4 votes
Easy
Problem

Supergirl wants to save planet form asteroid. She has an List of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). But since we are in the fantasy world these asteroids are also special, each of the asteroid moves at the same speed.

Supergirl wants to find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.

INPUT

-The first line of the input contains an integer T denoting the number of test cases.
-Each test case will contain N space seperated elements of List.

OUTPUT

-The state of the asteroids after all collisions.
-If after collision no astroides left then ouput NOTHING.

CONSTRAINTS

1 ≤ T ≤ 10000
1 ≤ N ≤ 2000
-1000 ≤ N[i] ≤ 1000

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In First case 10 and -5 collide resulting in 10. The 5 and 10 never collide.

In the second case 8 and -8 collide exploding each other.

In the third case 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.

In the fourth case -2 and -1 are moving left, while the 1 and 2 are moving right.


Asteroids moving the same direction never meet, so no asteroids will meet each other.

Editor Image

?