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.*;
import java.util.*;

public class R99D1_B {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        int[] nums1 = new int[10];
        int[] nums2 = new int[10];
        for (int i = 0; i < s.length(); i++) {
            nums1[s.charAt(i) - '0']++;
            nums2[s.charAt(i) - '0']++;
        }
        int tot = -1;
        int num1 = 0;
        int num2 = 0;
        int zeroes = 0;
        int zero1 = nums1[0];
        int zero2 = nums2[0];
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                if (i + j == 10) {
                    if (nums1[i] > 0 && nums2[j] > 0) {
                        nums1[i]--;
                        nums2[j]--;
                        int nw = 0;
                        int zero = 0;
                        for (int j2 = 0; j2 <= 9; j2++) {
                            for (int k = 0; k <= 9; k++) {
                                if (j2 + k == 9) {
                                    int d = Math.min(nums1[j2], nums2[k]);
                                    nw += d;
                                    if(j2==0)
                                        nums1[j2] -= d;
                                    else if(k==0)
                                        nums2[k] -= d;
                                }
                            }
                        }
                        int add = Math.min(nums1[0], nums2[0]);
                        nw += add;
                        if (nw > tot) {
                            tot = nw;
                            num1 = i;
                            num2 = j;
                            zeroes = add;
                        }
                        nums1[i]++;
                        nums2[j]++;
                        nums1[0] = zero1;
                        nums2[0] = zero2;
                    }
                }
            }
        }
        char[] res1 = new char[s.length()];
        char[] res2 = new char[s.length()];
        int r1 = res1.length - 1, r2 = res2.length - 1;
        if (tot == -1) {
            for (int j = 0; j < nums1[0]; j++)
                res1[r1--] = '0';
            for (int j = 0; j < nums2[0]; j++)
                res2[r2--] = '0';
            nums1[0] = 0;
            nums2[0] = 0;
        } else {
            for (int j = 0; j < zeroes; j++)
                res1[r1--] = '0';
            for (int j = 0; j < zeroes; j++)
                res2[r2--] = '0';
            nums1[0]-=zeroes;
            nums2[0]-=zeroes;
            res1[res1.length - 1 - zeroes] = (char) ('0' + num1);
            res2[res2.length - 1 - zeroes] = (char) ('0' + num2);
            nums1[num1]--;
            nums2[num2]--;
            r1 = res1.length - 2 - zeroes;
            r2 = res2.length - 2 - zeroes;

            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    if (i + j == 9) {
                        for (int j2 = 0; j2 < Math.min(nums1[i], nums2[j]); j2++) {
                            res1[r1--] = (char) ('0' + i);
                            res2[r2--] = (char) ('0' + j);
                        }
                        int y = Math.min(nums1[i],nums2[j]);
                        nums1[i] -= y;
                        nums2[j] -= y;
                    }
                }
            }
        }
        for (int i = 0; i < nums1.length; i++) {
            for (int j = 0; j < nums1[i]; j++)
                res1[r1--] = (char) ('0' + i);
        }

        for (int i = 0; i < nums2.length; i++) {
            for (int j = 0; j < nums2[i]; j++)
                res2[r2--] = (char) ('0' + i);
        }
        System.out.println(new String(res1));
        System.out.println(new String(res2));
    }
}