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.

Examples

Input

198


Output

981
819


Input

500


Output

500
500

Difficulty: HARD
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import itertools

def countZeroes(s):
	ret = 0
	for i in s:
		if i != '0':
			break
		ret += 1
	return ret

def stupid(n):
	ansMax = 0
	bn1 = n
	bn2 = n
	for n1 in itertools.permutations(n):
		for n2 in itertools.permutations(n):
			val = str(int(''.join(n1)) + int(''.join(n2)))[::-1]
			cnt = countZeroes(val)
			if cnt > ansMax:
				ansMax = cnt
				bn1 = ''.join(n1)
				bn2 = ''.join(n2)
	return (bn1, bn2)

def solution(n):
	ansMax = n.count('0')
	bestN1 = n.replace('0', '') + ansMax * '0'
	bestN2 = n.replace('0', '') + ansMax * '0'
	for i in range(1, 10):
		cnt1 = [n.count(str(j)) for j in range(10)]
		cnt2 = [n.count(str(j)) for j in range(10)]
		if cnt1[i] == 0 or cnt2[10 - i] == 0:
			continue
		cnt1[i] -= 1
		cnt2[10 - i] -= 1
		curN1 = str(i)
		curN2 = str(10 - i)
		ansCur = 1
		for j in range(10):
			addend = min(cnt1[j], cnt2[9 - j])
			ansCur += addend
			cnt1[j] -= addend
			cnt2[9 - j] -= addend
			curN1 += str(j) * addend
			curN2 += str(9 - j) * addend
		if cnt1[0] > 0 and cnt2[0] > 0:
			addend = min(cnt1[0], cnt2[0])
			ansCur += addend
			cnt1[0] -= addend
			cnt2[0] -= addend
			curN1 = '0' * addend + curN1
			curN2 = '0' * addend + curN2
		if ansCur > ansMax:
			ansMax = ansCur
			f = lambda x: str(x[0]) * x[1]
			bestN1 = ''.join(map(f, enumerate(cnt1))) + curN1[::-1]
			bestN2 = ''.join(map(f, enumerate(cnt2))) + curN2[::-1]
	return (bestN1, bestN2)
n = input()
print('\n'.join(solution(n)))


n = input()
digits = [0 for x in range(10)]
for x in n:
	digits[int(x)] += 1
best = -1
b1 = ''
b2 = ''
types = [(1, 9), (2, 8), (3, 7), (4, 6), (5, 5)]
best = -1
b1 = ''
b2 = ''
for (a, b) in types:
	if digits[a] and digits[b]:
		d1 = digits[:]
		d2 = digits[:]
		d1[a] -= 1
		d2[b] -= 1
		s1 = str(a)
		s2 = str(b)
		for (i, x) in enumerate(d1):
			num = min(x, d2[9 - i])
			s1 += str(i) * num
			s2 += str(9 - i) * num
			d1[i] -= num
			d2[9 - i] -= num
		num = min(d1[0], d2[0])
		s1 = '0' * num + s1
		s2 = '0' * num + s2
		d1[0] -= num
		d2[0] -= num
		if len(s1) > best:
			best = len(s1)
			for (i, x) in enumerate(d1):
				s1 += str(i) * x
			for (i, x) in enumerate(d2):
				s2 += str(i) * x
			b1 = s1
			b2 = s2
if best == -1:
	for x in range(10):
		b1 += str(x) * digits[x]
		b2 += str(x) * digits[x]
print(b1[::-1])
print(b2[::-1])