Preparando MOJI

Digits Permutations

1000ms 262144K

Description:

Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.

Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers.

Given number n, can you find the two digit permutations that have this property?

Input:

The first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.

Output:

Print two permutations of digits of number n, such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.

Sample Input:

198

Sample Output:

981
819

Sample Input:

500

Sample Output:

500
500

Informação

Codeforces

Provedor Codeforces

Código CF138B

Tags

greedy

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:33:59

Relacionados

Nada ainda