Codeforces Round 751 (Div. 2)
A
Two Subsequences
Codeforces
800
原题
←B →
翻译中…

You are given a string $s$. You need to find two non-empty strings $a$ and $b$ such that the following conditions are satisfied:

翻译中…
  1. Strings $a$ and $b$ are both subsequences of $s$.
  2. For each index $i$, character $s_i$ of string $s$ must belong to exactly one of strings $a$ or $b$.
  3. String $a$ is lexicographically minimum possible; string $b$ may be any possible string.
翻译中…

Given string $s$, print any valid $a$ and $b$.

翻译中…

Reminder:

翻译中…

A string $a$ ($b$) is a subsequence of a string $s$ if $a$ ($b$) can be obtained from $s$ by deletion of several (possibly, zero) elements. For example, "dores", "cf", and "for" are subsequences of "codeforces", while "decor" and "fork" are not.

翻译中…

A string $x$ is lexicographically smaller than a string $y$ if and only if one of the following holds:

翻译中…
  • $x$ is a prefix of $y$, but $x \ne y$;
  • in the first position where $x$ and $y$ differ, the string $x$ has a letter that appears earlier in the alphabet than the corresponding letter in $y$.
翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). Description of the test cases follows.

翻译中…

The first and only line of each test case contains one string $s$ ($2 \le |s| \le 100$ where $|s|$ means the length of $s$). String $s$ consists of lowercase Latin letters.

翻译中…

Output

翻译中…

For each test case, print the strings $a$ and $b$ that satisfy the given conditions. If there are multiple answers, print any.

翻译中…

Note

翻译中…

In the first test case, there are only two choices: either $a =$ f and $b = $ c or $a = $ c and $b = $ f. And $a = $c is lexicographically smaller than $a = $ f.

翻译中…

In the second test case, a is the only character in the string.

翻译中…

In the third test case, it can be proven that b is the lexicographically smallest subsequence of $s$. The second string can be of two variants; one of them is given here.

翻译中…

样例

Input #1
3
fc
aaaa
thebrightboiler
Output #1
c f
a aaa
b therightboiler
InputCopy OutputCopy
题目信息
题号
1602A
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。