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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
    static int[] c1, c2;
    static char[] a1, a2;
    static int best = -1;
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        
        char[] a = r.readLine().toCharArray();
        a1 = new char[a.length];
        a2 = new char[a.length];
        
        int size = a.length;
        
        int[] c = new int[10];
        for(int i = 0; i < size; i++)
            c[a[i] - '0']++;
        
        boolean done = false;
        for(int i = 1; i <= 9; i++){
            int j = 10 - i;
            if(c[i] == 0 || c[j] == 0)continue;
            done = true;
            c1 = c.clone();
            c2 = c.clone();
            
            go(i, j);
        }
        
//      System.out.println(done);
        if(!done){
            a1 = new char[a.length];
            a2 = new char[a.length];
            c1 = c.clone();
            c2 = c.clone();
            
            int p1 = a.length - 1;
            int p2 = a.length - 1;
            
            int zeros = Math.min(c1[0], c2[0]);
            
            c1[0] -= zeros;
            c2[0] -= zeros;
            
            for(int itr = 0; itr < zeros; itr++){
                a1[p1--] = '0';
                a2[p2--] = '0';
            }
            
            for(int i = 0; i <= 9; i++)
                while(c1[i]-- > 0)
                    a1[p1--] = (char) (i + '0');
            for(int i = 0; i <= 9; i++)
                while(c2[i]-- > 0)
                    a2[p2--] = (char) (i + '0');
                
        }
        
//      System.out.println((int)a1[0]);
        System.out.println(new String(a1));
        System.out.println(new String(a2));
            
    }
    private static void go(int i1, int j1) {
        char[] a1t = new char[a1.length];
        char[] a2t = new char[a2.length];
        int p1 = a1.length - 1;
        int p2 = a2.length - 1;
        
        c1[i1]--; c2[j1]--;
        
        int all = 0;
        int nonZero = 0;
        for(int i = 0; i <= 9; i++){
            int j = 9 - i;
            
            if(c1[i] == 0 || c2[j] == 0)continue;
            
            int curr = Math.min(c1[i], c2[j]); 
            all += curr;
            
            c1[i] -= curr;
            c2[j] -= curr;
            
            for(int itr = 0; itr < curr; itr++){
                a1t[p1--] = (char) (i + '0');
                a2t[p2--] = (char) (j + '0');
            }
        }
        nonZero = all;
        int zeros = Math.min(c1[0], c2[0]);
        
        c1[0] -= zeros;
        c2[0] -= zeros;
        all += Math.min(c1[0], c2[0]);
        
        if(all > best){
            best = all;
            
            char[] ans1 = new char[a1.length];
            char[] ans2 = new char[a2.length];
            int p1a = a1.length-1;
            int p2a = a2.length-1;
            
            
            for(int itr = 0; itr < zeros; itr++){
//              System.out.print('0');
                ans1[p1a--] = '0';
                ans2[p2a--] = '0';
            }
            
            ans1[p1a--] = (char) (i1 + '0');
            ans2[p2a--] = (char) (j1 + '0');
            
            int p11a = a1.length-1;
            int p22a = a2.length-1;
            for(int itr = 0; itr < nonZero; itr++){
                ans1[p1a--] = a1t[p11a--];
                ans2[p2a--] = a2t[p22a--];
            }
            for(int i = 0; i <= 9; i++)
                while(c1[i]-- > 0){
                    ans1[p1a--] = (char) (i + '0');
                }
            
            for(int i = 0; i <= 9; i++)
                while(c2[i]-- > 0)
                    ans2[p2a--] = (char) (i + '0');
            
            a1 = ans1;
            a2 = ans2;
        }
    }
}