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

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author pttrung
 */
public class B {

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        String val = in.next();
        int[] countA = new int[10];
        int[] countB = new int[10];
        for (int i = 0; i < val.length(); i++) {
            int index = val.charAt(i) - '0';
            countA[index]++;
            countB[index]++;
        }
        StringBuilder a = new StringBuilder();
        StringBuilder b = new StringBuilder();
        int left = -1;
        int right = -1;
        int test = 0;
        for (int i = 1; i < 9; i++) {
            int other = 10 - i;
            if (countA[i] > 0 && countB[other] > 0) {
                countA[i]--;
                countB[other]--;
                int temp = 0;
                for (int j = 0; j < 10; j++) {
                    if (countA[j] != 0 && countB[9 - j] != 0) {

                        temp += Math.min(countA[j], countB[9 - j]);
                        //break;
                    }
                }
                //     System.out.println(test + " " + i);
                if (temp > test || left == -1) {
                    left = i;
                    right = other;
                    test = temp;
                }

                countA[i]++;
                countB[other]++;
            }

        }

        if (left != -1) {
            countA[left]--;

            countB[right]--;

            a.append(left);
            b.append(right);
            for (int j = 0; j < 10; j++) {
                if (countA[j] != 0 && countB[9 - j] != 0) {

                    int num = Math.min(countA[j], countB[9 - j]);
                    for (int i = 0; i < num; i++) {
                        a.append(j);
                        b.append(9 - j);

                    }
                    countA[j] -= num;
                    countB[9 - j] -= num;
                    //break;
                }
            }



        }


        //   System.out.println(countA[0]+" "+ countB[0]);
        for (int i = 1; i < 10; i++) {
            while (countA[i] > 0) {
                a.append(i);
                countA[i]--;
            }
            while (countB[i] > 0) {
                b.append(i);
                countB[i]--;
            }
        }
        int min = Math.min(countA[0], countB[0]);
        if(countA[0] > min){
            for(int i = 0; i < countA[0] - min ; i++){
                a.append(0);
            }
        }else   if(countB[0] > min){
            for(int i = 0; i < countB[0] - min ; i++){
                b.append(0);
            }
        }
        a = a.reverse();
        b = b.reverse();
        
        for (int i = 0; i < min; i++) {
            a.append(0);
            b.append(0);

        }
      
        out.println(a.toString());
        out.println(b.toString());
        out.close();
    }

    public static double dist(Point a, Point b) {
        double val = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(val);
    }

    public static class Point {

        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public double pow(double a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        double val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}