#C6226. Rearrange Balls
Rearrange Balls
Rearrange Balls
You are given a series of test cases. For each test case, you are provided with a positive integer \(N\) and a string \(S\) of length \(N\) that consists only of the characters 'R' and 'W'. The goal is to rearrange the characters in \(S\) such that all 'R's come before all 'W's, while preserving the relative order of the 'R's among themselves and of the 'W's among themselves.
Task: For each test case, output the rearranged string on a new line.
Example:
Input: 1 5 WRRWW</p>Output: RRWWW
Note: The rearrangement is not a sorting of characters, but rather a reordering that maintains the original order among the same type of balls.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(T\), the number of test cases.
- For each test case:
- The first line contains an integer \(N\) representing the length of the string.
- The second line contains the string \(S\) consisting only of the characters 'R' and 'W'.
outputFormat
For each test case, output the rearranged string on a new line. The output is printed to standard output (stdout).
## sample3
5
WRRWW
4
RRWW
7
RWRWRRW
RRWWW
RRWW
RRRRWWW
</p>