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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int cnt[15], f1[15], f2[15], f3[15], ans[15];
char s[100005];
char t1[100005], t2[100005];
int main() {
  while (scanf("%s", s) > 0) {
    int len = strlen(s);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < len; i++) cnt[s[i] - '0']++;
    memset(t1, 0, sizeof(t1));
    memset(t2, 0, sizeof(t2));
    int res = 0;
    int zero = 0, jj = 0;
    for (int i = 0; i <= cnt[0]; i++) {
      for (int j = 1; j <= 9; j++) {
        int tres = i;
        for (int k = 1; k <= 9; k++) {
          f1[k] = cnt[k];
          f2[k] = cnt[k];
        }
        f1[0] = cnt[0] - i;
        f2[0] = cnt[0] - i;
        bool flag = false;
        if (j == 5) {
          if (f1[5] <= 0) flag = true;
          f1[5]--;
          if (f2[5] <= 0) flag = true;
          f2[5]--;
        } else {
          if (f1[j] <= 0 || f2[10 - j] <= 0) flag = true;
          f1[j]--;
          f2[10 - j]--;
        }
        if (flag) {
          if (tres > res) {
            jj = 0;
            zero = i;
            res = tres;
          }
          continue;
        }
        tres++;
        memset(f3, 0, sizeof(f3));
        for (int k = 0; k <= 9; k++) {
          int tt = min(f1[k], f2[9 - k]);
          tres += tt;
          f1[k] -= tt;
          f2[9 - k] -= tt;
        }
        if (tres > res) {
          jj = j;
          zero = i;
          res = tres;
        }
      }
    }
    if (res == 0) {
      puts(s);
      puts(s);
      continue;
    }
    int k1 = len - 1;
    if (zero > 0) {
      int cc = 0;
      for (;;) {
        t1[k1] = '0';
        t2[k1] = '0';
        k1--;
        cc++;
        if (cc >= zero) break;
      }
      f1[0] = f2[0] = cnt[0] - zero;
    } else
      f1[0] = f2[0] = cnt[0];
    for (int i = 1; i <= 9; i++) {
      f1[i] = cnt[i];
      f2[i] = cnt[i];
    }
    if (jj != 0) {
      t1[k1] = jj + '0';
      t2[k1] = (10 - jj) + '0';
      f1[jj]--;
      f2[10 - jj]--;
      k1--;
    }
    for (int j = 0; j <= 9; j++) {
      int tt = min(f1[j], f2[9 - j]);
      int no = 0;
      if (tt == 0) continue;
      while (true) {
        t1[k1] = j + '0';
        t2[k1] = (9 - j) + '0';
        k1--;
        no++;
        if (no == tt) break;
      }
      f1[j] -= tt;
      f2[9 - j] -= tt;
    }
    int kk = k1;
    for (int j = 0; j <= 9; j++) {
      if (f1[j] == 0) continue;
      while (true) {
        t1[kk] = j + '0';
        kk--;
        f1[j]--;
        if (f1[j] <= 0) break;
      }
    }
    kk = k1;
    for (int j = 0; j <= 9; j++) {
      if (f2[j] == 0) continue;
      while (true) {
        t2[kk] = j + '0';
        kk--;
        f2[j]--;
        if (f2[j] <= 0) break;
      }
    }
    puts(t1);
    puts(t2);
  }
}