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

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String s = in.readLine();
        int[] a = new int[s.length()];
        for (int i = 0; i < s.length(); i++)
            a[i] = s.charAt(i) - '0';

        int[] count = new int[10];

        for (int i = 0; i < a.length; i++)
            count[a[i]]++;

        int max = Integer.MIN_VALUE;
        StringBuilder max1 = new StringBuilder();
        StringBuilder max2 = new StringBuilder();
        for (int i = 1; i <= 5; i++) {
            if (count[i] == 0 || count[10 - i] == 0)
                continue;
            int[] tmpCount1 = Arrays.copyOf(count, count.length);
            int[] tmpCount2 = Arrays.copyOf(count, count.length);
            tmpCount1[i]--;
            tmpCount2[10 - i]--;
            Ans ans = getPerms(tmpCount1, tmpCount2);

            if (ans.len > max) {
                max = ans.len;
                max1 = new StringBuilder(ans.s1 + Integer.valueOf(i).toString() + ans.z1);
                max2 = new StringBuilder(ans.s2 + Integer.valueOf(10 - i).toString() + ans.z2);
            }
        }

        if (max == Integer.MIN_VALUE) {
            int[] tmpCount1 = Arrays.copyOf(count, count.length);
            int[] tmpCount2 = Arrays.copyOf(count, count.length);

            StringBuilder tmp1 = new StringBuilder();
            StringBuilder tmp2 = new StringBuilder();
            while (tmpCount1[0] > 0 && tmpCount2[0] > 0) {
                tmp1.append(0);
                tmp2.append(0);
                tmpCount1[0]--;
                tmpCount2[0]--;
            }

            for (int i = 0; i <= 9; i++) {
                while (tmpCount1[i] > 0) {
                    max1.append(i);
                    tmpCount1[i]--;
                }
                while (tmpCount2[i] > 0) {
                    max2.append(i);
                    tmpCount2[i]--;
                }
            }

            max1.append(tmp1);
            max2.append(tmp2);
        }

        out.println(max1);
        out.println(max2);
        out.close();
    }

    static class Ans {
        public StringBuilder s1;
        public StringBuilder s2;
        public StringBuilder z1;
        public StringBuilder z2;
        public int len;

        public Ans() {
            s1 = new StringBuilder();
            s2 = new StringBuilder();
            z1 = new StringBuilder();
            z2 = new StringBuilder();
            len = 0;
        }
    }

    private static Ans getPerms(int[] count1, int[] count2) {
        Ans ans = new Ans();
        StringBuilder tmp1 = new StringBuilder();
        StringBuilder tmp2 = new StringBuilder();
        for (int i = 0; i <= 9; i++)
            while (count1[i] > 0 && count2[10 - i - 1] > 0) {
                tmp1.append(i);
                tmp2.append(10 - i - 1);
                count1[i]--;
                count2[10 - i - 1]--;
            }

        while (count1[0] > 0 && count2[0] > 0) {
            ans.z1.append(0);
            ans.z2.append(0);
            count1[0]--;
            count2[0]--;
        }

        ans.len = tmp1.length() + ans.z1.length();

        for (int i = 0; i <= 9; i++) {
            while (count1[i] > 0) {
                ans.s1.append(i);
                count1[i]--;
            }
            while (count2[i] > 0) {
                ans.s2.append(i);
                count2[i]--;
            }
        }

        ans.s1.append(tmp1);
        ans.s2.append(tmp2);

        return ans;
    }
}