#C2161. Organize the Bookshelf
Organize the Bookshelf
Organize the Bookshelf
You are given a bookshelf represented by a string consisting only of the characters F
, N
, and R
. These characters represent three different genres of books. Your task is to rearrange the books such that all the F
books come first, followed by all the N
books, and finally the R
books.
The input starts with an integer T representing the number of test cases. Each subsequent line corresponds to a test case containing a string. For each test case, you should output the rearranged bookshelf string on a new line.
Note: Make sure to process the input from stdin
and output the result to stdout
.
inputFormat
The input is read from stdin
and is formatted as follows:
- An integer
T
representing the number of test cases. T
lines follow, each containing a string composed only of the charactersF
,N
, andR
.
outputFormat
For each test case, output a single line containing the rearranged string: all the F
characters first, followed by all the N
characters, and then all the R
characters.
1
FNRRFN
FFNNRR
</p>