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 static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		in.close();
		out.close();
	}
	
	void solve() throws IOException{
		String s = nextToken();
		int n = s.length();
		int CNT[] = new int[10];
		for(int i = 0; i < n; i++)
			CNT[s.charAt(i) - '0']++;
		
		StringBuffer sb1 = new StringBuffer(n);
		StringBuffer sb2 = new StringBuffer(n);
		
		int a = - 1, b = -1;
		int best = -1;
		int b0 = -1;
		
		int cnt1[] = Arrays.copyOf(CNT, 10);
		int cnt2[] = Arrays.copyOf(CNT, 10);
		
		for(int i = 1; i < 10; i++){
				int j = 10 - i;
				if(cnt1[i] == 0 || cnt2[j] == 0) continue;
				cnt1[i]--;
				cnt2[j]--;
				int cur = 0;
				for(int k = 0; k < 10; k++)
					cur += min(cnt1[k], cnt2[9 - k]);
				if(cur > best || (cur == best && min(cnt1[0], cnt2[0]) < b0)){
					best = cur;
					a = i;
					b = j;
					b0 = min(cnt1[0], cnt2[0]);
				}
				cnt1[i]++;
				cnt2[j]++;
			}
		
		if(best < 0){
			fillTail(CNT, sb1);
			sb1.reverse();
			sb2 = sb1;
		} else {
			cnt1[a]--;
			cnt2[b]--;
			sb1.append(a);
			sb2.append(b);
			for(int k = 0; k < 10; k++){
				int cur = min(cnt1[k], cnt2[9 - k]);
				cnt1[k] -= cur;
				cnt2[9 - k] -= cur;
				while(cur > 0){
					cur--;
					sb1.append(k);
					sb2.append(9 - k);
				}
			}
			int je = min(cnt1[0], cnt2[0]);
			{
				cnt1[0] -= je;
				fillTail(cnt1, sb1);
				sb1.reverse();
				for(int i = 0; i < je; i++)
					sb1.append(0);
			}
			{
				cnt2[0] -= je;
				fillTail(cnt2, sb2);
				sb2.reverse();
				for(int i = 0; i < je; i++)
					sb2.append(0);
			}
		}
		
		out.println(sb1.toString());
		out.println(sb2.toString());
	}
	
	void fillTail(int cnt[], StringBuffer sb){
		for(int i = 0; i < 10; i++)
			while(cnt[i] != 0) { 
				cnt[i]--;
				sb.append(i);
			}
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}