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;
char a[100010];
char b[100010];
int na[10], nb[10];
int L, res;
map<vector<int>, int> memo;
int rec(int i, int c) {
  vector<int> k;
  k.push_back(c);
  for (int j = 0, _n = (10); j < _n; j++)
    k.push_back(na[j]), k.push_back(nb[j]);
  if (memo.count(k)) return memo[k];
  int ret = 0;
  if (c) {
    for (int x = 0, _n = (10); x < _n; x++) {
      int y = 9 - x;
      int z = min(na[x], nb[y]);
      if (z) {
        na[x] -= z;
        nb[y] -= z;
        ret = max(ret, z + rec(i - z, 1));
        na[x] += z;
        nb[y] += z;
      }
    }
  } else {
    for (int x = 1; x <= 9; x++) {
      int y = 10 - x;
      if (na[x] && nb[y]) {
        na[x]--;
        nb[y]--;
        ret = max(ret, 1 + rec(i - 1, 1));
        na[x]++;
        nb[y]++;
      }
    }
  }
  return memo[k] = ret;
}
void print(int i, int c) {
  vector<int> k;
  k.push_back(c);
  for (int j = 0, _n = (10); j < _n; j++)
    k.push_back(na[j]), k.push_back(nb[j]);
  int ret = memo[k];
  if (c) {
    for (int x = 0, _n = (10); x < _n; x++) {
      int y = 9 - x;
      int z = min(na[x], nb[y]);
      if (z) {
        int ok = 0;
        na[x] -= z;
        nb[y] -= z;
        if (ret == z + rec(i - z, 1)) {
          for (int j = 0, _n = (z); j < _n; j++) {
            a[i - j] = '0' + x;
            b[i - j] = '0' + y;
          }
          ok = 1;
          print(i - z, 1);
        }
        na[x] += z;
        nb[y] += z;
        if (ok) return;
      }
    }
  } else {
    for (int x = 1; x <= 9; x++) {
      int y = 10 - x;
      if (na[x] && nb[y]) {
        int ok = 0;
        na[x]--;
        nb[y]--;
        if (ret == 1 + rec(i - 1, 1)) {
          a[i] = '0' + x;
          b[i] = '0' + y;
          ok = 1;
          print(i - 1, 1);
        }
        na[x]++;
        nb[y]++;
        if (ok) return;
      }
    }
  }
  int z = min(na[0], nb[0]);
  for (int j = i; j < L; j++) {
    a[j - z] = a[j];
    b[j - z] = b[j];
  }
  for (int j = 0, _n = (z); j < _n; j++) a[L - 1 - j] = b[L - 1 - j] = '0';
  na[0] -= z;
  nb[0] -= z;
  res += z;
  int x = i - z, y = i - z;
  for (int j = 0, _n = (10); j < _n; j++) {
    for (; na[j]; na[j]--, x--) assert(x >= 0), a[x] = '0' + j;
    for (; nb[j]; nb[j]--, y--) assert(y >= 0), b[y] = '0' + j;
    assert(!na[j]);
    assert(!nb[j]);
  }
  assert(x == -1);
  assert(y == -1);
}
int main() {
  while (scanf("%s", a) != EOF) {
    L = strlen(a);
    for (int i = 0, _n = (10); i < _n; i++) na[i] = 0;
    for (int i = 0, _n = (L); i < _n; i++) na[a[i] - '0']++;
    for (int i = 0, _n = (10); i < _n; i++) nb[i] = na[i];
    b[L] = '\0';
    memo.clear();
    res = rec(L - 1, 0);
    print(L - 1, 0);
    puts(a);
    puts(b);
  }
}