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.*;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/29/11
 * Time: 7:56 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskD {

    void run() {        
        int[] have = new int[10];
        for(char x : next().toCharArray()) {
            have[x - '0']++;
        }
                
        int maxMatch = -1;
        int choose = 0;
        for(int firstMatch = 1; firstMatch < 10; firstMatch++) {
            int[] cnt1 = have.clone();
            int[] cnt2 = have.clone();
            int match = 0, carry = 0;

            int need = 10 - firstMatch;
            if(cnt1[firstMatch] > 0 && cnt2[need] > 0) {
                cnt1[firstMatch]--;
                cnt2[need]--;
                carry = 1;
                match++;
            }

            int cur = 0;
            while(cur < 10) {
                if(cnt1[cur] > 0) {
                    if(cur == 0) {
                        need = (carry > 0) ? 9 : 0;
                        if(cnt2[need] > 0) {
                            cnt1[cur]--;
                            cnt2[need]--;
                            match++;
                        }
                        else {
                            cur++;
                        }
                    }
                    else {
                        need = 10 - cur - carry;
                        if(cnt2[need] > 0) {
                            cnt1[cur]--;
                            cnt2[need]--;
                            match++;
                            carry = 1;
                        }
                        else {
                            cur++;
                        }
                    }
                }
                else {
                    cur++;
                }
            }

            while (cnt1[0] > 0 && cnt2[0] > 0) {
                cnt1[0]--;
                cnt2[0]--;
                match++;
            }

            if(match > maxMatch) {
                maxMatch = match;
                choose = firstMatch;
            }
        }                

        int[] cnt1 = have.clone();
        int[] cnt2 = have.clone();
        int carry = 0;

        StringBuilder builder0 = new StringBuilder();
        StringBuilder builder1 = new StringBuilder();
        int need = (10 - choose) % 10;
        if(cnt1[choose] > 0 && cnt2[need] > 0) {
            builder0.append((char) ('0' + choose));
            builder1.append((char) ('0' + need));
            cnt1[choose]--;
            cnt2[need]--;
            if(choose > 0) carry = 1;
        }

        int cur = 0;
        while(cur < 10) {
            if(cnt1[cur] > 0) {
                if(cur == 0) {
                    need = (carry > 0) ? 9 : 0;
                    if(cnt2[need] > 0) {
                        builder0.append((char) ('0' + cur));
                        builder1.append((char) ('0' + need));
                        cnt1[cur]--;
                        cnt2[need]--;
                    }
                    else {
                        cur++;
                    }
                }
                else {
                    need = 10 - cur - carry;
                    if(cnt2[need] > 0) {
                        builder0.append((char) ('0' + cur));
                        builder1.append((char) ('0' + need));
                        cnt1[cur]--;
                        cnt2[need]--;
                        carry = 1;
                    }
                    else {
                        cur++;
                    }
                }
            }
            else {
                cur++;
            }
        }

        builder0.reverse();
        builder1.reverse();
        while (cnt1[0] > 0 && cnt2[0] > 0) {
            builder0.append("0");
            builder1.append("0");
            cnt1[0]--;
            cnt2[0]--;
        }
        
        
        StringBuilder rest0 = new StringBuilder();
        StringBuilder rest1 = new StringBuilder();
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < cnt1[i]; j++) rest0.append((char) ('0' + i));
            for(int j = 0; j < cnt2[i]; j++) rest1.append((char) ('0' + i));
        }

        System.out.println(rest0.reverse().toString() + builder0.toString());
        System.out.println(rest1.reverse().toString() + builder1.toString());
    }

    int nextInt(){
        try{
            int c = System.in.read();
            if(c == -1) return c;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return c;
            }
            if(c == '-') return -nextInt();
            int res = 0;
            do{
                res *= 10;
                res += c - '0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    long nextLong(){
        try{
            int c = System.in.read();
            if(c == -1) return -1;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return -1;
            }
            if(c == '-') return -nextLong();
            long res = 0;
            do{
                res *= 10;
                res += c-'0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }

    String next(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(Character.isWhitespace(c))
                c = System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    String nextLine(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(c == '\r' || c == '\n')
                c = System.in.read();
            do{
                res.append((char)c);
                c = System.in.read();
            }while(c != '\r' && c != '\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    public static void main(String[] args){
        new TaskD().run();
    }
}