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;
static const double EPS = 1e-6;
const long double pi = acos(-1.0);
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
    dy[] = {1, 0, -1, 0, 1, -1, 1, -1, 0};
int app[10];
int calc(int n) {
  int tapp[10], sapp[10];
  for (int i = 0; i < (int)(10); ++i) sapp[i] = tapp[i] = app[i];
  int ret = 0;
  int c = 0;
  if (n == 0 && tapp[0] && sapp[0]) {
    ++ret;
    tapp[0] -= 1;
    sapp[0] -= 1;
  } else if (n != 0 && tapp[n] && sapp[10 - n]) {
    ++ret;
    tapp[n]--;
    sapp[10 - n]--;
    ++c;
  } else
    return 0;
  if (c) {
    for (int i = 0; i <= 9; ++i) ret += min(tapp[i], sapp[9 - i]);
    return ret;
  } else {
    int tret = 0;
    for (int i = 0; i <= min(tapp[0], sapp[0]); ++i) {
      tapp[0] -= i;
      sapp[0] -= i;
      for (int j = 1; j < 10; ++j) {
        int tt = i;
        if (tapp[j] && sapp[10 - j]) {
          tapp[j]--;
          sapp[10 - j]--;
          ++tt;
          for (int i = 0; i < (int)(10); ++i) tt += min(tapp[i], sapp[9 - i]);
          tapp[j]++;
          sapp[10 - j]++;
        }
        tret = max(tret, tt);
      }
      tapp[0] += i;
      sapp[0] += i;
    }
    return ret + tret;
  }
}
string in;
void print(int n, int ma) {
  string a, b;
  int tapp[10], sapp[10];
  int c = 0;
  for (int i = 0; i < (int)(10); ++i) sapp[i] = tapp[i] = app[i];
  if (n == 0 && tapp[0]) {
    a += '0';
    b += '0';
    tapp[0]--;
    sapp[0]--;
  } else if (n != 0 && tapp[n] && sapp[10 - n]) {
    a += n + '0';
    b += 10 - n + '0';
    tapp[n]--;
    sapp[10 - n]--;
    ++c;
  } else {
    cout << in << endl;
    cout << in << endl;
    return;
  }
  if (c) {
    for (int i = 0; i <= 9; ++i) {
      int mi = min(tapp[i], sapp[9 - i]);
      tapp[i] -= mi;
      sapp[9 - i] -= mi;
      for (int j = 0; j < (int)(mi); ++j) {
        a += i + '0';
        b += 9 - i + '0';
      }
    }
  } else {
    int tret = 0;
    for (int i = 0; i <= min(tapp[0], sapp[0]); ++i) {
      tapp[0] -= i;
      sapp[0] -= i;
      bool ok = false;
      for (int j = 1; j < 10; ++j) {
        int tt = i;
        if (tapp[j] && sapp[10 - j]) {
          tapp[j]--;
          sapp[10 - j]--;
          ++tt;
          for (int i = 0; i < (int)(10); ++i) tt += min(tapp[i], sapp[9 - i]);
          tapp[j]++;
          sapp[10 - j]++;
        }
        tret = max(tret, tt);
        if (tret + 1 == ma) {
          ok = true;
          for (int k = 0; k < (int)(i); ++k) {
            a += '0';
            b += '0';
          }
          if (tapp[j] && sapp[10 - j]) {
            tapp[j]--;
            sapp[10 - j]--;
            a += j + '0';
            b += 10 - j + '0';
            for (int k = 0; k < (int)(10); ++k) {
              int mi = min(tapp[k], sapp[9 - k]);
              tapp[k] -= mi;
              sapp[9 - k] -= mi;
              for (int j = 0; j < (int)(mi); ++j) {
                a += k + '0';
                b += 9 - k + '0';
              }
            }
          }
          break;
        }
      }
      if (ok) break;
      tapp[0] += i;
      sapp[0] += i;
    }
  }
  for (int i = 0; i < (int)(10); ++i) {
    for (int j = 0; j < (int)(tapp[i]); ++j) a += i + '0';
    for (int j = 0; j < (int)(sapp[i]); ++j) b += i + '0';
  }
  reverse((a).begin(), (a).end());
  reverse((b).begin(), (b).end());
  cout << a << endl;
  cout << b << endl;
}
int main() {
  cin >> in;
  for (__typeof((in).begin()) it = (in).begin(); it != (in).end(); ++it)
    ++app[*it - '0'];
  vector<pair<int, int> > num;
  for (int i = 0; i < (int)(10); ++i) num.push_back(make_pair(calc(i), i));
  sort((num).begin(), (num).end());
  reverse((num).begin(), (num).end());
  print(num[0].second, num[0].first);
}