410780: GYM104103 A Homework

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Homeworktime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Lana and Alan are twins, and they study in the same school. One day, they were given homework in which they had to make up a word using given letters. As they didn't want to be considered cheaters, they wanted to make up words that differ at every position.

Given a string of lowercase English letters $$$A$$$, find two words $$$B$$$ and $$$C$$$ that use all these letters (in other words, they both must be an anagram of $$$A$$$), such that $$$B$$$ and $$$C$$$ contain different letters in each place. These words don't have to be actual words of any real-world language.

Input

The input contains a string $$$A$$$, consisting of lowercase English letters. The length of $$$A$$$ is between $$$1$$$ and $$$1000$$$.

Output

If an answer exists, print two lines containing words $$$B$$$ and $$$C$$$. Each word must be an anagram of $$$A$$$ (containing the same letters as $$$A$$$, possibly, in a different order). For each $$$i$$$ from $$$1$$$ to the length of $$$A$$$, $$$B_i$$$ must be different from $$$C_i$$$.

If it's impossible to make up such $$$B$$$ and $$$C$$$, print "IMPOSSIBLE". If there is more than one correct answer, you can print any of them.

Scoring
SubtaskPointsConstraints
130All letters in $$$A$$$ are distinct
230The length of $$$A$$$ does not exceed $$$10$$$
340No additional constraints
ExamplesInput
nala
Output
alan
lana
Input
abacaba
Output
IMPOSSIBLE
Input
innopolisopen
Output
noepsilonnopi
opinionnpoles

加入题单

算法标签: