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.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class A implements Runnable{
    
    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");
    
    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }
    
    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }
    
    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }
    
    long readLong() throws IOException{
        return Long.parseLong(readString());
    }
    
    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }
    
    public static void main(String[] args){
        new Thread(null, new A(), "", 256 * (1L << 20)).start();
    }
    
    public void run(){
        try{
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
    
    void solve() throws IOException{
        char[] c = in.readLine().toCharArray();
        long[] count1 = new long[10];
        long[] count2 = new long[10];
        for (int i = 0; i < c.length; i++){
            count1[c[i]-'0']++;
            count2[c[i]-'0']++;
        }
        long max = 0;
        int ans = -1;
        for (int first = 1; first < 6; first++){
            int second = 10 - first;
            if (count1[first] == 0 || count2[second] == 0){
                continue;
            }
            long res = 0;
            count1[first]--;
            res = max(count1[0] - count2[9], 0) + 1;            
            count2[second]--;
            for (int j = 1; j < 10; j++){
                long x = count1[j];
                long y = count2[9-j];
                res += min(x, y);
            }
            if (max <= res){
                max = res;
                ans = first;
            }
            count1[first]++;
            count2[second]++;
        }
        if (max == 0){
            for (int i = 9; i >= 0; i--){
                for (int j = 0; j < count1[i]; j++){
                    out.print(i);
                }
            }
            out.println();
            for (int i = 9; i >= 0; i--){
                for (int j = 0; j < count1[i]; j++){
                    out.print(i);
                }
            }
            return;
        }
        ArrayList<Integer> list = new ArrayList<Integer>();
        ArrayList<Integer> list2 = new ArrayList<Integer>();
        count1[ans]--;
        count2[10-ans]--;
        long res = max(count1[0] - count2[9], 0);
        for (int i = 0; i < res; i++){
            list.add(0);
            count1[0]--;
            list2.add(0);
            count2[0]--;
        }
        list.add(ans);
        list2.add(10 - ans);
        for (int i = 0; i < 10; i++){
            while (count1[i] > 0 && count2[9-i] > 0){
                list.add(i);
                count1[i]--;
                list2.add(9 - i);
                count2[9-i]--;
            }
        }
        for (int i = 0; i < 10; i++){
            for (int j = 0; j < count1[i]; j++){
                list.add(i);
            }
        }
        for (int i = 0; i < 10; i++){
            for (int j = 0; j < count2[i]; j++){
                list2.add(i);
            }
        }
        Collections.reverse(list);
        Collections.reverse(list2);
        for (int i: list){
            out.print(i);
        }
        out.println();
        for (int i: list2){
            out.print(i);
        }
//      char[] c = in.readLine().toCharArray();
//      int count = 1;
//      int ans = 0;
//      for (int i = 1; i < c.length; i++){
//          if (c[i] == c[i-1]) count++;
//          else{
//              ans += (count - 1) / 5 + 1;
//              count = 1;
//          }
//      }
//      ans += (count - 1) / 5 + 1;
//      out.print(ans);
    }
}