题库练习 Equidistant Letters
← 上一题 下一题 →

A14819 | Equidistant Letters

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given a string $s$ , consisting of lowercase Latin letters. Every letter appears in it no more than twice.

Your task is to rearrange the letters in the string in such a way that for each pair of letters that appear exactly twice, the distance between the letters in the pair is the same. You are not allowed to add or remove letters.

It can be shown that the answer always exists. If there are multiple answers, print any of them.

输入格式

The first line contains a single integer $t$ ( $1 \le t \le 10^3$ ) — the number of testcases.

Each testcase consists of a non-empty string $s$ , consisting of lowercase Latin letters. Every letter appears in the string no more than twice. The length of the string doesn't exceed $52$ .

输出格式

For each testcase, print a single string. Every letter should appear in it the same number of times as it appears in string $s$ . For each pair of letters that appear exactly twice, the distance between the letters in the pair should be the same.

If there are multiple answers, print any of them.

输入输出样例

输入 #1
3
oelhl
abcdcba
ac
输出 #1
hello
ababcdc
ac
C++ 编辑器
输入
输出