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.util.*;

public class Main {

  public static void main(String args[]) {
    (new Main()).solve();
  }

  void solve() {

    Scanner cin = new Scanner(System.in);

    char dig[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

    while( cin.hasNext() ) {

      String s = cin.next();
      int n = s.length();

      int count[] = new int[10];
      int copy[] = new int[10];

      for(int i=0; i<n; ++i) {
        int pos = s.charAt(i) - '0';
        ++count[pos];
        ++copy[pos];
      }

      int max = 0;
      int zero = 0;
      int first = 0;

      // without carry;
      for(int i=0; i<=count[0]; ++i) {
        count[0] -= i;
        copy[0] -= i;
        if( i > max ) {
          max = i;
          zero = i;
          first = 0;
        }
        // with carry;
        for(int j=1; j<10; ++j) {
          if( count[j] == 0 || copy[10 - j] == 0 ) { continue; }
          --count[j];
          --copy[10 - j];
          int ans = i + 1;
          for(int k=0; k<10; ++k) {
            ans += Math.min(count[k], copy[9 - k]);
          }
          if( ans > max ) {
            max = ans;
            zero = i;
            first = j;
          }
          ++count[j];
          ++copy[10 - j];
        }
        count[0] += i;
        copy[0] += i;
      }

      StringBuilder A = new StringBuilder();
      StringBuilder B = new StringBuilder();

      for(int i=0; i<zero; ++i) {
        A.append(dig[0]);
        B.append(dig[0]);
        --count[0];
        --copy[0];
      }

      if( first > 0 ) {
        A.append(dig[first]);
        B.append(dig[10 - first]);
        --count[first];
        --copy[10 - first];
      }

      for(int i=0; i<10; ++i) {
        int e = Math.min(count[i], copy[9 - i]);
        for(int j=0; j<e; ++j) {
          A.append(dig[i]);
          --count[i];
          B.append(dig[9 - i]);
          --copy[9 - i];
        }
      }

      for(int i=0; i<10; ++i) {
        for(int j=0; j<count[i]; ++j) {
          A.append(dig[i]);
        }
        for(int j=0; j<copy[i]; ++j) {
          B.append(dig[i]);
        }
      }

      System.out.println(A.reverse());
      System.out.println(B.reverse());

    }

  }

}