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;
const int maxn = 1e5 + 10;
char s[maxn];
int a[maxn], b[maxn];
int ans1[maxn], ans2[maxn];
int cnt;
int main() {
  cin >> s;
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    a[s[i] - '0']++;
    b[s[i] - '0']++;
  }
  for (int i = 0; i <= 9; i++) {
    while (a[i] != 0 && b[9 - i] != 0) {
      a[i]--;
      b[9 - i]--;
      ans1[++cnt] = i;
      ans2[cnt] = 9 - i;
    }
  }
  int flag = 0;
  for (int i = 1; i <= 9; i++) {
    if (a[i] != 0 && b[10 - i] != 0) {
      ans1[++cnt] = i;
      ans2[cnt] = 10 - i;
      flag = 1;
      a[i]--;
      b[10 - i]--;
      break;
    }
  }
  if (!flag) {
    int ok = 0;
    for (int i = 1; i <= 9; i++) {
      ok = 0;
      if (a[i] != 0) {
        int x, y;
        for (int j = 1; j <= cnt; j++) {
          if (ans2[j] + i == 10) {
            x = ans1[j], y = ans2[j];
            ans1[j] = -1;
            ans2[j] = -1;
            ok = 1;
            break;
          }
        }
        if (ok == 1) {
          a[i]--;
          a[x]++;
          ans1[++cnt] = i;
          ans2[cnt] = y;
        }
      }
      if (ok == 1) break;
    }
    if (ok == 0) {
      int sx1 = -1, sy1 = -1, sx2 = -1, sy2 = -1;
      for (int i = 1; i <= cnt; i++) {
        int _x = ans1[i], _y = ans2[i];
        for (int j = i + 1; j <= cnt; j++) {
          int __x = ans1[j], __y = ans2[j];
          if (_x + __y == 10) {
            sx1 = _x;
            sy1 = __y;
            sx2 = __x;
            sy2 = _y;
            ans1[i] = ans2[i] = ans1[j] = ans2[j] = -1;
            break;
          } else if (__x + _y == 10) {
            sx1 = __x, sy1 = _y;
            sx2 = _x, sy2 = __y;
            ans1[i] = ans2[i] = ans1[j] = ans2[j] = -1;
            break;
          }
        }
        if (sx1 != -1) break;
      }
      if (sx1 != -1) {
        a[sx2]++, b[sy2]++;
        ans1[++cnt] = sx1;
        ans2[cnt] = sy1;
      }
    }
    if (a[0] != 0 && b[0] != 0) {
      while (a[0] > 0 && b[0] > 0) {
        ans1[++cnt] = 0;
        ans2[cnt] = 0;
        a[0]--;
        b[0]--;
      }
    }
    for (int i = 0; i <= 9; i++) {
      if (a[i] != 0) {
        while (a[i] != 0) printf("%d", i), a[i]--;
      }
    }
    for (int i = 1; i <= cnt; i++) {
      if (ans1[i] != -1) printf("%d", ans1[i]);
    }
    puts("");
    for (int i = 0; i <= 9; i++) {
      if (b[i] != 0) {
        while (b[i] != 0) printf("%d", i), b[i]--;
      }
    }
    for (int i = 1; i <= cnt; i++) {
      if (ans2[i] != -1) printf("%d", ans2[i]);
    }
  } else {
    if (a[0] != 0 && b[0] != 0) {
      while (a[0] > 0 && b[0] > 0) {
        ans1[++cnt] = 0;
        ans2[cnt] = 0;
        a[0]--;
        b[0]--;
      }
    }
    for (int i = 0; i <= 9; i++) {
      if (a[i] != 0) {
        while (a[i] != 0) printf("%d", i), a[i]--;
      }
    }
    for (int i = 1; i <= cnt; i++) {
      if (ans1[i] != -1) printf("%d", ans1[i]);
    }
    puts("");
    for (int i = 0; i <= 9; i++) {
      if (b[i] != 0) {
        while (b[i] != 0) printf("%d", i), b[i]--;
      }
    }
    for (int i = 1; i <= cnt; i++) {
      if (ans2[i] != -1) printf("%d", ans2[i]);
    }
  }
  return 0;
}