#C9599. Stabilize Power Flow

    ID: 53709 Type: Default 1000ms 256MiB

Stabilize Power Flow

Stabilize Power Flow

In this problem, you are given one or more test cases. In each test case, you will receive a list of integers representing power values. Your task is to rearrange the list so that all the positive numbers (called (\textbf{Glorps})) appear at the beginning and all the negative numbers (called (\textbf{Floops})) appear at the end. The internal order among the positive numbers must be preserved, as must the internal order among the negative numbers.

For example, given the list: [3, -4, 2, -2, 1], the output should be: [3, 2, 1, -4, -2].

Make sure to read the input from standard input (stdin) and output the results to standard output (stdout).

inputFormat

The input begins with an integer (T) denoting the number of test cases. Each test case consists of two lines. The first line contains an integer (N), the number of power values, and the second line contains (N) space-separated integers representing the power values.

outputFormat

For each test case, output a single line containing the rearranged list of power values. The positive numbers ((>0)) should be printed first in their original order, followed by the negative numbers ((<0)) also in their original order. Separate the numbers with a single space.## sample

3
5
3 -4 2 -2 1
4
-1 -3 5 6
3
7 -8 9
3 2 1 -4 -2

5 6 -1 -3 7 9 -8

</p>