#C1179. Transform Sequence
Transform Sequence
Transform Sequence
You are given a sequence of integers. For each integer in the sequence, perform a transformation based on the following rules:
- If the number is even, replace it with \(\frac{a_i}{2}\).
- If the number is odd, replace it with \(3a_i + 1\).
You need to process multiple test cases. For each test case, output the transformed sequence. The input and output are handled via stdin and stdout respectively.
inputFormat
The first line of input contains a single integer \(T\), the number of test cases. Each test case is described as follows:
- The first line of each test case contains an integer \(n\), the length of the sequence.
- The second line contains \(n\) integers separated by spaces.
All input is read from stdin.
outputFormat
For each test case, output a single line containing the transformed sequence. The numbers should be separated by a single space. All output is written to stdout.
## sample3
3
8 7 4
4
1 2 3 4
2
5 10
4 22 2
4 1 10 2
16 5
</p>