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 s[123456];
int freq[10], a[10], b[10];
int p[10];
vector<pair<int, int> > ans;
int main() {
  int n = 0;
  scanf("%s", s);
  for (n = 0; s[n]; ++n) ++a[s[n] - '0'];
  for (int i = 0; i < 10; ++i) freq[i] = (b[i] = a[i]) << 1;
  for (int i = 0; i < 10; ++i) {
    int m = min(freq[i], freq[9 - i]);
    p[i] = m;
    freq[i] -= m;
    freq[9 - i] -= m;
  }
  while (freq[0]) {
    ans.push_back(make_pair(0, 0));
    freq[0] -= 2;
  }
  bool carry = 0;
  for (int i = 1; i < 10; ++i)
    if (freq[i] && freq[10 - i] > (i == 10 - i)) {
      carry = 1;
      ans.push_back(make_pair(i, 10 - i));
      freq[i]--;
      freq[10 - i]--;
      break;
    }
  if (!carry) {
    for (int i = 1; i < 10; ++i)
      if (freq[i] && p[10 - i]) {
        carry = 1;
        ans.push_back(make_pair(i, 10 - i));
        freq[i]--;
        freq[i - 1]++;
        p[10 - i]--;
        break;
      } else if (freq[10 - i] && p[i]) {
        carry = 1;
        ans.push_back(make_pair(i, 10 - i));
        freq[9 - i]++;
        freq[10 - i]--;
        p[i]--;
        break;
      }
  }
  if (!carry) {
    for (int i = 1; i < 10; ++i)
      if (p[i] && p[i - 1]) {
        carry = 1;
        p[i]--;
        p[i - 1]--;
        freq[9 - i]++;
        freq[i - 1]++;
        ans.push_back(make_pair(i, 10 - i));
        break;
      }
    if (carry)
      for (int i = 0; i < 10; ++i) {
        int m = min(freq[i], freq[9 - i]);
        p[i] += m;
        freq[i] -= m;
        freq[9 - i] -= m;
      }
  }
  if (!carry) {
    freq[9] += p[0];
    while (p[0]) {
      ans.push_back(make_pair(0, 0));
      p[0] -= 2;
    }
    for (int i = 0; i < 10; ++i) {
      freq[i] += p[i];
      freq[9 - i] += p[i];
      p[i] = 0;
    }
  }
  for (int i = 0; i < 10; ++i) {
    while (p[i]) {
      ans.push_back(make_pair(i, 9 - i));
      p[i]--;
    }
  }
  for (int i = 0; i < 10; ++i) {
    while (freq[i] && freq[10 - i] > (i == 10 - i)) {
      ans.push_back(make_pair(i, 10 - i));
      freq[i]--;
      freq[10 - i]--;
    }
  }
  for (int i = 0; i < 10; ++i) {
    while (freq[i] > 1) {
      ans.push_back(make_pair(i, i));
      freq[i] -= 2;
    }
  }
  for (int i = 0; i < 10; ++i)
    if (freq[i])
      for (int j = i + 1; j < 10; ++j)
        if (freq[j]) {
          ans.push_back(make_pair(i, j));
          freq[i]--;
          freq[j]--;
        }
  assert(n == (int)ans.size());
  for (auto &item : ans) {
    if (!a[item.first]) swap(item.first, item.second);
    if (!b[item.second]) swap(item.first, item.second);
    a[item.first]--;
    b[item.second]--;
  }
  while (count(a, a + 10, 0) < 10) {
    for (auto &item : ans) {
      if (item.first == item.second) continue;
      if (a[item.first] < 0 && b[item.first] > 0) {
        a[item.first]++;
        b[item.first]--;
        a[item.second]--;
        b[item.second]++;
        swap(item.first, item.second);
      }
    }
  }
  string p1, p2;
  for (auto item : ans) {
    p1 += char('0' + item.first);
    p2 += char('0' + item.second);
  }
  reverse(p1.begin(), p1.end());
  reverse(p2.begin(), p2.end());
  puts(p1.c_str());
  puts(p2.c_str());
  return 0;
}