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.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main implements Runnable {

	final String filename = "";

	public void solve() throws Exception {
		String s = readword();
		int[] cnt1 = new int[10], cnt2 = new int[10];
		for (int i=0; i<s.length(); i++)
		{
			cnt1[s.charAt(i)-'0']++;
			cnt2[s.charAt(i)-'0']++;
		}
		int ans = cnt1[0];
		ArrayList<Integer> ans1 = new ArrayList<Integer>();
		ans1.add(0);
		ans1.add(cnt1[0]);
		ArrayList<Integer> ans2 = new ArrayList<Integer>();
		ans2.add(0);
		ans2.add(cnt2[0]);
		for (int i=1; i<=9; i++)
		{
			if (cnt1[i]>0 && cnt2[10-i]>0)
			{
				cnt1[i]--;
				cnt2[10-i]--;
				
				ArrayList<Integer> res1 = new ArrayList<Integer>();
				res1.add(i);
				res1.add(1);
				ArrayList<Integer> res2 = new ArrayList<Integer>();
				res2.add(10-i);
				res2.add(1);
				
				int a0 = 0, b0 = 0;
				
				int res = 1;
				for (int j=0; j<=9; j++)
				{
					int x = Math.min(cnt1[j], cnt2[9-j]);
					if (j==0)
						a0 = cnt1[0] - x;
					if (j==9)
						b0 = cnt2[0] - x;
					if (x==0) continue;
					res+= x;
					res1.add(j);
					res1.add(x);
					res2.add(9-j);
					res2.add(x);
				}
				if (a0>0&&b0>0)
				{
					int x = Math.min(a0, b0);
					res+=x;
					res1.add(0, 0);
					res1.add(1, x);
					res2.add(0, 0);
					res2.add(1, x);
				}
				
				cnt1[i]++;
				cnt2[10-i]++;
				
				if (res>ans)
				{
					ans = res;
					ans1=res1;
					ans2=res2;
				}
			}
		}
		ArrayList<Integer> s1 = new ArrayList<Integer>();
		ArrayList<Integer> s2 = new ArrayList<Integer>();
		
		for (int i=0; i<ans1.size(); i+=2)
		{
			int x = ans1.get(i), c = ans1.get(i+1);
			cnt1[x]-=c;
			for (int j=0;j<c;j++)
				s1.add(x);
		}
		for (int i=0; i<=9; i++)
			for (int j=0; j<cnt1[i]; j++)
				s1.add(i);
		
		for (int i=0; i<ans2.size(); i+=2)
		{
			int x = ans2.get(i), c = ans2.get(i+1);
			cnt2[x]-=c;
			for (int j=0;j<c;j++)
				s2.add(x);
		}
		for (int i=0; i<=9; i++)
			for (int j=0; j<cnt2[i]; j++)
				s2.add(i);
		
		for (int i=s1.size()-1; i>=0; i--)
			out.write((char)('0'+s1.get(i)));
		out.write("\n");
		for (int i=s2.size()-1; i>=0; i--)
			out.write((char)('0'+s2.get(i)));
		out.write("\n");
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			// in = new BufferedReader(new FileReader(filename+".in"));
			// out = new BufferedWriter(new FileWriter(filename+".out"));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int iread() throws Exception {
		return Integer.parseInt(readword());
	}

	public double dread() throws Exception {
		return Double.parseDouble(readword());
	}

	public long lread() throws Exception {
		return Long.parseLong(readword());
	}

	BufferedReader in;

	BufferedWriter out;

	public String readword() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {

		}
		// new Thread(new Main()).start();
		new Thread(null, new Main(), "1", 1 << 25).start();
	}
}