CF2125A.Difficult Contest

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Difficult Contest

It is known that a contest can be represented by a string ss, consisting of uppercase Latin letters that denote problems. It is also known that a contest is difficult if it contains "FFT" or "NTT" as a contiguous substring.

Your task is to rearrange the problem in contest ss in such a way that this contest is not difficult. If the initial contest is not difficult, you may leave it as it is.

Input

Each test consists of several test cases. The first line contains a single integer tt (1t1041 \le t \le 10^{4}) — the number of test cases. The description of the test cases follows.

The only line of each test case contains ss (1s21051 \le |s| \le 2 \cdot 10^{5}).

Additional constraints on the input data:

  • the total length of strings across all test cases does not exceed 21052 \cdot 10^{5}.

Output

For each test case, output a string — a non-difficult contest that was obtained from ss by rearranging the letters.

If there are multiple correct answers, you may output any. It can be shown that at least one correct answer always exists.

Samples

5
FFT
ABFBANTTA
FFTNTT
FFTFFTFFTNNTNNT
AFFTBFFNTTFTTZ
FTF
ABFBANATT
NTFTFT
TFFFFFFNTNTNTNT
AFTFBTTFFNFTTZ

在线编程 IDE

建议全屏模式获得最佳体验