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

import static java.lang.Integer.*;
import static java.lang.Math.*;

public class D {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in = br.readLine();
        int[] count1 = new int[10];
        int[] count2 = new int[10];
        for (int i = 0; i < in.length(); ++i) {
            int cur = in.charAt(i) - '0';
            count1[cur]++;
            count2[cur]++;
        }
        char [] ans1 = new char [in.length()];
        char [] ans2 = new char [in.length()];
        int max9 = 0;
        int best = -1;
        for (int i = 1; i < 6; ++i) {
            if (count1[i] == 0 || count2[10 - i] == 0)
                continue;
            count1[i]--;
            count2[10 - i]--;
            int n = 1;
            int[] tcount1 = count1.clone();
            int[] tcount2 = count2.clone();
            for (int j = 0; j <= 9; ++j) {
                int mn = min(tcount1[j], tcount2[9 - j]);
                tcount1[j] -= mn;
                tcount2[9 - j] -= mn;
                n += mn;
            }
            int nn = min(tcount1[0], tcount2[0]);
            n += nn;
            if (n > max9) {
                max9 = n;
                best = i;
            }
            count1[i]++;
            count2[10 - i]++;
        }
        if (best == -1) {
            int cur = in.length() - 1;
            int cur2 = in.length() - 1;
            while (count1[0] > 0 && count2[0] > 0) {
                count1[0]--;
                count2[0]--;
                ans1[cur--] = '0';
                ans2[cur2--] = '0';
            }
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < count1[i]; ++j)
                    ans1[cur--] = (char)(i + '0');
                for (int j = 0; j < count2[i]; ++j)
                    ans2[cur2--] = (char)(i + '0');
            }
            System.out.println(ans1);
            System.out.println(ans2);
        } else {
            int cur = in.length() - 1;
            int cur2 = in.length() - 1;
            ans1[cur--] = (char)(best + '0');
            ans2[cur2--] = (char)((10 - best) + '0');
            count1[best]--;
            count2[10 - best]--;
            for (int i = 0; i <= 9; ++i) {
                int mn = min(count1[i], count2[9 - i]);
                count1[i] -= mn;
                count2[9 - i] -= mn;
                for (int j = 0; j < mn; ++j) {
                    ans1[cur--] = (char)(i + '0');
                    ans2[cur2--] = (char)((9 - i) + '0');
                }
            }
            String end = "";
            while (count1[0] > 0 && count2[0] > 0) {
                count1[0]--;
                count2[0]--;
                end += '0';
            }
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < count1[i]; ++j)
                    ans1[cur--] = (char)(i + '0');
                for (int j = 0; j < count2[i]; ++j)
                    ans2[cur2--] = (char)(i + '0');
            }
            String r1 = new String(ans1) + end;
            String r2 = new String(ans2) + end;
            while(r1.startsWith(""+(char)(0))){
                r1 = r1.substring(1);
            }
            while(r2.startsWith(""+(char)(0)))
                r2 = r2.substring(1);
            System.out.println(r1);
            System.out.println(r2);
        }
    }
}