Problem: 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

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.*;
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	int count [][];

	public void solve() throws Exception {
		String s = next();
		count = new int [10][2];
		for (int i = 0 ; i < s.length(); i++) {
			count[s.charAt(i)-'0'][0]++;
			count[s.charAt(i)-'0'][1]++;
		}
		int tmp [][] = new int [10][2];

		for (int i = 0; i <= 9; i++) {
			for (int j = 0 ; j < 2 ; j++)
				tmp[i][j] = count [i][j];
		}
		int maxret = -1;
		int bestnum1 = -1;
		int bestnum2 = -1;
		for (int num1 = 1; num1 <= 5; num1++) {
			int num2 = 10 - num1;
			int ret = 0;
			if (count [num1][0] > 0 && count [num2][1] > 0) {
				count [num1][0] --;
				count [num2][1] --;
				ret = 1;
				for (int i = 0; i <= 9; i++) {
					int j = 9 - i;
					int mini = min (count [i][0], count [j][1]);
					ret += mini;
					count [i][0] -= mini;
					count [j][1] -= mini;
				}
				ret += min (count [0][0], count [0][1]);
				if (ret > maxret) {
					maxret = ret;
					bestnum1 = num1;
					bestnum2 = num2;
				}
			}
			for (int i = 0 ; i < 10; i++)
				for (int j = 0 ; j < 2; j ++)
				count [i][j] = tmp[i][j];
		}
		
		if (count[0][0] > maxret) {
			maxret = count [0][0];
			bestnum1 = -1;
		}
		
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();

		if (bestnum1 != -1 && count [bestnum1][0] > 0 && count [bestnum2][1] > 0) {
			count [bestnum1][0] --;
			count [bestnum2][1] --;
			sb1.append(bestnum1);
			sb2.append(bestnum2);
			for (int i = 0; i <= 9; i++) {
				int j = 9 - i;
				int mini = min (count [i][0], count [j][1]);
				count [i][0] -= mini;
				count [j][1] -= mini;
				for (int k = 0 ; k < mini ; k++) {
					sb1.append(i);
					sb2.append(j);
				}
			}
			for (int i = 1; i < 10; i++)
				for (int j = 0 ; j < count [i][0]; j++) {
					sb1.append(i);
				}
			for (int i = 1; i < 10; i++)
				for (int j = 0 ; j < count [i][1]; j++) {
					sb2.append(i);
				}
			int mini = min (count [0][0], count [0][1]);
			count [0][0] -= mini;
			count [0][1] -= mini;
			for (int i = 0; i < count [0][0]; i++)
				sb1.append(0);
			for (int i = 0; i < count [0][1]; i++)
				sb2.append(0);
			
			String s1 = sb1.toString();
			String s2 = sb2.toString();
			for (int i = s1.length()-1 ; i>=0; i--)
				out.print(s1.charAt(i));
			for (int i = 0; i < mini; i++)
				out.print(0);
			out.println();
			for (int i = s2.length()-1 ; i>=0; i--)
				out.print(s2.charAt(i));
			for (int i = 0; i < mini; i++)
				out.print(0);

		} else {
			for (int j = 0 ; j < 10 ; j++)
				for (int i = 0 ; i < count [j][0] ; i++) {
					sb1.append(j);
				}
			for (int j = 0 ; j < 10 ; j++)
				for (int i = 0 ; i < count [j][1] ; i++) {
					sb2.append(j);
				}

			String s1 = sb1.toString();
			String s2 = sb2.toString();
			for (int i = s1.length()-1 ; i>=0; i--)
				out.print(s1.charAt(i));
			out.println();
			for (int i = s2.length()-1 ; i>=0; i--)
				out.print(s2.charAt(i));
			
		}
		
	}
	

	/********************************************************************************************/
	/* THERE IS INPUT */

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	long stime=0;
	
	private String next() throws Exception {
		while (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	private long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}
	
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		new Thread(null, new Solution(), "", 1 << 25).start();
	}

	
}