#K95047. Dragon and Unicorn Separation
Dragon and Unicorn Separation
Dragon and Unicorn Separation
In a mystical realm, two types of magical creatures exist: Dragons and Unicorns. Dragons are denoted by \(0\) and Unicorns by \(1\). Under a royal decree, the King has requested a magical separation of these creatures into two distinct groups. Your task is to help the King by writing a program that processes several test cases. For each test case, you are given an integer \(N\) and a list of \(N\) numbers (each either \(0\) or \(1\)). The program should separate the list into two groups: one containing all the Dragons (\(0\)'s) and the other all the Unicorns (\(1\)'s).
Input Format:
- The first line contains an integer \(T\), the number of test cases.
- For each test case, the first line contains an integer \(N\), the number of magical creatures.
- The second line contains \(N\) space-separated integers, each being either \(0\) or \(1\).
Output Format:
- For each test case, output two lines:
- The first line should list all the Dragons (\(0\)'s) separated by a space. If there are no Dragons, output an empty line.
- The second line should list all the Unicorns (\(1\)'s) separated by a space. If there are no Unicorns, output an empty line.
Example:
Input: 1 3 0 1 0</p>Output: 0 0 1
inputFormat
The input begins with an integer \(T\) (the number of test cases). For each test case, the first line contains an integer \(N\) (the size of the array), followed by a second line containing \(N\) space-separated integers (each either 0 or 1).
outputFormat
For each test case, print two lines. The first line contains all Dragon elements (0's) separated by a space, and the second line contains all Unicorn elements (1's) separated by a space. If a group is empty, print an empty line.
## sample1
3
0 1 0
0 0
1
</p>