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.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
public class Main{
    public static void main(String[]args){
        InputStream in = System.in;
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        try{
        }catch (Exception e) {
        }
        new Main().run(in,out);
        out.flush();
    }
    private void debug(Object...os){
        System.err.println(deepToString(os));
    }
    
    private void run(InputStream in,PrintWriter out){
        String s = next(in);
        int[] cnt=new int[10];
        for(char c:s.toCharArray()){
            cnt[c-'0']++;
        }
        int first=1;
        int max=-1;
        for(int i=1;i<10;i++){
            int[] tmp1=cnt.clone();
            int[] tmp2=cnt.clone();
            if(tmp1[i]<1 || tmp2[10-i]<1)continue;
            tmp1[i]--;
            tmp2[10-i]--;
            int val = 0;
            for(int j=0;j<10;j++){
                int use = min(tmp1[j],tmp2[9-j]);
                tmp1[j]-=use;
                tmp2[9-j]-=use;
                val += use;
            }
            val += min(tmp1[0],tmp2[0]);
            if(max<val){
                max=val;
                first=i;
            }
        }
        if(max==-1){
            StringBuilder res = new StringBuilder();
            for(int i=1;i<10;i++){
                for(int j=0;j<cnt[i];j++)res.append(i);
            }
            for(int i=0;i<cnt[0];i++)res.append(0);
            out.println(res);
            out.println(res);
            return;
        }
        
        StringBuilder res1=new StringBuilder();
        StringBuilder res2=new StringBuilder();
        int[] tmp1=cnt.clone();
        int[] tmp2=cnt.clone();
        tmp1[first]--;
        tmp2[10-first]--;
        for(int i=0;i<10;i++){
            int use = min(tmp1[i],tmp2[9-i]);
            tmp1[i]-=use;
            tmp2[9-i]-=use;
            for(int j=0;j<use;j++){
                res1.append(i);
                res2.append(9-i);
            }
        }
        res1.append(first);
        res2.append(10-first);
        for(int i=0;i<min(tmp1[0],tmp2[0]);i++){
            res1.append(0);
            res2.append(0);
        }
        int use = min(tmp1[0],tmp2[0]);
        tmp1[0]-=use;
        tmp2[0]-=use;
        for(int i=0;i<10;i++){
            for(int j=0;j<tmp1[i];j++){
                out.print(i);
            }
        }
        out.println(res1);
        for(int i=0;i<10;i++){
            for(int j=0;j<tmp2[i];j++){
                out.print(i);
            }
        }
        out.println(res2);
    }
    
    private String nextLine(InputStream in) {
        try {
            StringBuilder res = new StringBuilder("");
            int c = in.read();
            if(c==-1)return null;
            while (c=='\n' || c=='\r'){
                c = in.read();
                if(c==-1)return null;
            }
            do {
                res.append((char) c);
                c=in.read();
            } while (c!='\n' && c!='\r');
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }
    
    private String next(InputStream in) {
        try {
            StringBuilder res = new StringBuilder("");
            int c = in.read();
            if(c==-1)return null;
            while (Character.isWhitespace(c)){
                c = in.read();
                if(c==-1)return null;
            }
            do {
                res.append((char) c);
            } while (!Character.isWhitespace(c = in.read()));
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }

    private int nextInt(InputStream in){
        try{
            int c=in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextInt(in);
            int res=0;
            do{
                res*=10;
                res+=c-'0';
                c=in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    private long nextLong(InputStream in){
        try{
            int c=in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextLong(in);
            long res=0;
            do{
                res*=10;
                res+=c-'0';
                c=in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
}