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.util.*;
import java.math.*;
public class codeforces {

                 
         public static void main(String[] args)
        {
                Scanner sc=new Scanner(System.in);
                String data=sc.next();
                int mem[]=new int[10];
                Arrays.fill(mem, 0);
                for(char x:data.toCharArray())
                {
                	int t=x-'0';
                	mem[t]++;
                }
                int num=-1;
                int last=-1;
                for(int i=1;i<=5;i++)
                {
                	if(mem[i]==0||mem[10-i]==0)
                		continue;
                	int temp[]=new int[10];
                	for(int j=0;j<10;j++)
                	{
                		temp[j]=mem[j];
                	}
                	int tt=1;
                	temp[i]--;
                	temp[10-i]--;
                	for(int j=0;j<=4;j++)
                	{
                		int k=Math.min(temp[j], temp[9-j]);
                		k=Math.max(0, k);
                		temp[j]-=k;
                		temp[9-j]-=k;
                		tt+=2*k;
                	}
                    int mem1[]=new int[10];
                    int mem2[]=new int[10];
                    for(int j=0;j<10;j++)
                    {
                    	mem1[j]=temp[j];
                    	mem2[j]=temp[j];
                    }
                    mem1[10-i]++;
                    mem2[i]++;
                    if(mem1[9-i]>0)
                    {
                    	mem1[9-i]--;
                    	mem2[i]--;
                    	tt++;
                    	
                    }
                    if(mem2[i-1]>0)
                    {
  
                    	mem1[10-i]--;
                    	mem2[i-1]--;
                    	tt++;
                    
                    }
                	tt+=Math.min(mem1[0], mem2[0]);
                	if(tt>num)
                	{
                		num=tt;
                		last=i;
                	}
                }
             //   System.out.println(last);
              //  System.out.println(num);
                if(last==-1)
                {
                	for(int i=0;i<2;i++)
                	{
                		for(int j=9;j>=0;j--)
                		{
                			for(int k=0;k<mem[j];k++)
                			{
                				System.out.print(j);
                			}
                		}
                		System.out.println("");
                	}
                	return;
                }
                int len=data.length();
                char num1[]=new char[len];
                char num2[]=new char[len];
                int index=len-1;
                int zero=Math.max(0, mem[0]-mem[9]);
                mem[0]-=zero;
                for(int i=0;i<zero;i++,index--)
                {
                	num1[index]='0';
                	num2[index]='0';
                }
                mem[last]--;
                mem[10-last]--;
                num1[index]=(char)(last+'0');
                num2[index]=(char)(10-last+'0');
                index--;
                for(int i=0;i<=4;i++)
                {
                	int k=Math.min(mem[i], mem[9-i]);
                	k=Math.max(0, k);
                	for(int j=0;j<k;j++)
                	{
                		num1[index]=(char)('0'+i);
                		num2[index]=(char)('0'+9-i);
                		index--;
                		num1[index]=(char)('0'+9-i);
                		num2[index]=(char)('0'+i);
                		index--;
                	}
                	mem[i]-=k;
                	mem[9-i]-=k;
                }
                int mem1[]=new int[10];
                int mem2[]=new int[10];
                for(int i=0;i<10;i++)
                {
                	mem1[i]=mem[i];
                	mem2[i]=mem[i];
                }
                mem1[10-last]++;
                mem2[last]++;
                if(mem1[9-last]>0)
                {
                	num1[index]=(char)('0'+9-last);
                	num2[index]=(char)('0'+last);
                	index--;
                	mem1[9-last]--;
                	mem2[last]--;
                	
                }
                if(mem2[last-1]>0)
                {
                	num1[index]=(char)('0'+10-last);
                	num2[index]=(char)('0'+last-1);
                	mem1[10-last]--;
                	mem2[last-1]--;
                	index--;
                }
            	int index1=index;
            	int index2=index;
                for(int i=0;i<10;i++)
                {

                	for(int j=0;j<mem1[i];j++)
                	{
                		num1[index1]=(char)('0'+i);
                		index1--;
                	}
                	for(int j=0;j<mem2[i];j++)
                	{
                		num2[index2]=(char)('0'+i);
                		index2--;
                	}
                }
                System.out.println(new String(num1));
                System.out.println(new String(num2));
                return;
        }

}