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 B implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    private void solve() {
        char[] s = in.next().toCharArray();
        int n = s.length;
        int[] num1 = new int[10];
        int[] num2 = new int[10];
        for (int i = 0; i < n; ++i) {
            num1[s[i] - '0']++;
            num2[s[i] - '0']++;
        }
        int best0 = -1, first = -1;
        for (int i = 1; i <= 9; ++i) {
            if (num1[i] == 0 || num2[10 - i] == 0) {
                continue;
            }
            int c0 = 1;
            num1[i]--;
            num2[10 - i]--;
            for (int j = 0; j <= 9; ++j) {
                c0 += Math.min(num1[j], num2[9 - j]);
                c0 += Math.min(num1[9 - j], num2[j]);
            }
            c0 += Math.max(0, Math.min(num1[0] - num1[9], num2[0] - num2[9]));
            if (c0 > best0) {
                best0 = c0;
                first = i;
            }
            num1[i]++;
            num2[10 - i]++;
        }
        char[] ans1 = new char[n];
        char[] ans2 = new char[n];
        if (best0 == -1) {
            int pos = n - 1;
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < num1[i]; ++j) {
                    ans1[pos] = (char) (i + '0');
                    ans2[pos] = (char) (i + '0');
                    --pos;
                }
            }
        } else {
            int pos = n - 1;
            num1[first]--;
            num2[10 - first]--;
            while (num1[0] > num1[9] && num2[0] > num2[9]) {
                ans1[pos] = '0';
                ans2[pos] = '0';
                num1[0]--;
                num2[0]--;
                --pos;
            }
            ans1[pos] = (char) (first + '0');
            ans2[pos] = (char) (10 - first + '0');
            --pos;
            for (int j = 0; j <= 9; ++j) {
                while (num1[j] > 0 && num2[9 - j] > 0) {
                    ans1[pos] = (char) (j + '0');
                    num1[j]--;
                    ans2[pos] = (char) (9 - j + '0');
                    num2[9 - j]--;
                    --pos;
                }
                while (num1[9 - j] > 0 && num2[j] > 0) {
                    ans1[pos] = (char) (9 - j + '0');
                    num1[9 - j]--;
                    ans2[pos] = (char) (j + '0');
                    num2[j]--;
                    --pos;
                }
            }
            int p1 = pos;
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < num1[i]; ++j) {
                    ans1[p1] = (char)(i + '0');
                    --p1;
                }
            }
            int p2 = pos;
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < num2[i]; ++j) {
                    ans2[p2] = (char)(i + '0');
                    --p2;
                }
            }
        }
        out.println(new String(ans1));
        out.println(new String(ans2));
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new B().run();
    }

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        private String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            try {
                st = null;
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

        public String next() {
            return nextToken();
        }

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

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

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