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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Artem Gilmudinov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            String s = in.rl();
            int n = s.length();
            int[] sym = new int[n];
            int[] cnt = new int[10];
            for (int i = 0; i < n; i++) {
                sym[i] = s.charAt(i) - '0';
                cnt[sym[i]]++;
            }
            int[] first_cnt = new int[10];
            int[] second_cnt = new int[10];
            int[] max = new int[10];
            int cntWithoutNull = -1;
            int whatOnRight = -1;
            for (int i = 1; i <= 9; i++) {
                int j = 10 - i;
                if (cnt[i] == 0 || cnt[j] == 0) {
                    continue;
                }
                for (int z = 0; z < 10; z++) {
                    first_cnt[z] = second_cnt[z] = cnt[z];
                }
                --first_cnt[i];
                --second_cnt[j];
                for (int z = 0; z <= 9; z++) {
                    max[z] = Math.min(first_cnt[z], second_cnt[9 - z]);
                }
                int sum = 0;
                for (int z = 0; z < 10; z++) {
                    sum += max[z];
                }
                if (sum + 1 > cntWithoutNull) {
                    cntWithoutNull = sum + 1;
                    whatOnRight = i;
                }
            }

            int cntWithNull = cnt[0];
            int cntOfNulls = cnt[0];
            int lastDigit = -1;
            for (int i = 1; i <= cnt[0]; i++) {
                for (int j = 1; j <= 9; j++) {
                    int a = j;
                    int b = 10 - a;
                    if (cnt[a] == 0 || cnt[b] == 0) {
                        continue;
                    }
                    for (int z = 0; z < 10; z++) {
                        first_cnt[z] = second_cnt[z] = cnt[z];
                    }
                    --first_cnt[a];
                    --second_cnt[b];
                    first_cnt[0] -= i;
                    second_cnt[0] -= i;

                    for (int z = 0; z <= 9; z++) {
                        max[z] = Math.min(first_cnt[z], second_cnt[9 - z]);
                    }
                    int sum = 0;
                    for (int z = 0; z < 10; z++) {
                        sum += max[z];
                    }
                    if (sum + 1 + i > cntWithNull) {
                        cntOfNulls = i;
                        cntWithNull = sum + 1 + i;
                        lastDigit = j;
                    }
                }
            }
            if (cntWithoutNull == -1 && cntWithNull == -1) {
                out.println(s);
                out.println(s);
            } else {
                int ind = n - 1;
                char[] first_ans = new char[n];
                char[] second_ans = new char[n];
                for (int j = 0; j < 10; j++) {
                    first_cnt[j] = second_cnt[j] = cnt[j];
                }
                if (cntWithoutNull < cntWithNull) {
                    for (int i = 0; i < cntOfNulls; i++) {
                        first_ans[n - i - 1] = '0';
                        second_ans[n - i - 1] = '0';
                    }
                    first_cnt[0] -= cntOfNulls;
                    second_cnt[0] -= cntOfNulls;
                    ind = n - cntOfNulls - 1;
                    if (lastDigit != -1) {
                        first_ans[ind] = (char) ('0' + lastDigit);
                        second_ans[ind] = (char) ('0' + (10 - lastDigit));
                        --first_cnt[lastDigit];
                        --second_cnt[10 - lastDigit];
                        --ind;
                    }

                } else {
                    ind = n - 1;
                    first_ans[ind] = (char) ('0' + whatOnRight);
                    second_ans[ind] = (char) ('0' + (10 - whatOnRight));
                    --ind;
                    --first_cnt[whatOnRight];
                    --second_cnt[10 - whatOnRight];
                }

                for (int i = 0; i < 10; i++) {
                    max[i] = Math.min(first_cnt[i], second_cnt[9 - i]);
                }
                for (int i = 0; i < 10; i++) {
                    for (int j = 0; j < max[i]; j++, ind--) {
                        first_ans[ind] = (char) ('0' + i);
                        second_ans[ind] = (char) ('0' + (9 - i));
                    }
                }
                for (int i = 0; i < 10; i++) {
                    first_cnt[i] -= max[i];
                    second_cnt[9 - i] -= max[i];
                }
                for (int i = 0, pos = 0; i < 10; i++) {
                    while (first_cnt[i] != 0) {
                        for (int j = 0; j < 10; j++) {
                            if (first_cnt[i] != 0 && second_cnt[j] != 0) {
                                first_ans[pos] = (char) ('0' + i);
                                second_ans[pos] = (char) ('0' + j);
                                --first_cnt[i];
                                --second_cnt[j];
                                ++pos;
                            }
                        }
                    }
                }
                out.println(new String(first_ans));
                out.println(new String(second_ans));
            }
        }

    }

    static class Reader {
        private BufferedReader in;

        public Reader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

        public String rl() {
            try {
                return in.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }
}