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 main() {
  string s;
  cin >> s;
  vector<long> mass1(10, 0);
  for (long i = 0; i < s.size(); i++) mass1[s[i] - '0']++;
  vector<long> mass2 = mass1;
  vector<long> s1(s.size(), 0);
  vector<long> s2(s.size(), 0);
  long a = s.size() - 1;
  bool flag = true;
  long kol = 0;
  long num = -1;
  long temp = 0, t1 = 0, t2 = 0;
  bool fl = false;
  for (long i = 1; i < 9; i++)
    if (mass1[i] != 0 && mass2[10 - i] != 0) {
      temp = 1;
      mass1[i]--;
      mass2[10 - i]--;
      t1 = 0;
      t2 = 0;
      for (long j = 0; j <= 9; j++) temp += min(mass1[j], mass2[9 - j]);
      if (mass2[9] < mass1[0]) t1 = mass1[0] - mass2[9];
      if (mass2[0] > mass1[9]) t2 = mass2[0] - mass1[9];
      temp += min(t1, t2);
      mass1[i]++;
      mass2[10 - i]++;
      if (temp > kol) {
        kol = temp;
        num = i;
      }
    }
  for (long i = 1; i < 9; i++)
    if (mass1[i] != 0 && mass2[10 - i] != 0) {
      temp = mass1[0] + 1;
      mass1[i]--;
      mass2[10 - i]--;
      t1 = 0;
      t2 = 0;
      for (long j = 1; j < 9; j++) temp += min(mass1[j], mass2[9 - j]);
      mass1[i]++;
      mass2[10 - i]++;
      if (temp >= kol) {
        kol = temp;
        num = i;
        fl = true;
      }
    }
  if (num != -1) {
    if (fl == false) {
      mass1[num]--;
      mass2[10 - num]--;
      if (mass2[9] < mass1[0]) t1 = mass1[0] - mass2[9];
      if (mass2[0] > mass1[9]) t2 = mass2[0] - mass1[9];
      for (long i = 0; i < min(t1, t2); i++) {
        s1[a] = 0;
        s2[a] = 0;
        a--;
      }
      mass1[0] -= min(t1, t2);
      mass2[0] -= min(t1, t2);
      s1[a] = num;
      s2[a] = 10 - num;
      a--;
      for (long i = 0; i <= 9; i++) {
        for (long j = 0; j < min(mass1[i], mass2[9 - i]); j++) {
          s1[a] = i;
          s2[a] = 9 - i;
          a--;
        }
        long kq = min(mass1[i], mass2[9 - i]);
        mass1[i] -= kq;
        mass2[9 - i] -= kq;
      }
      long b = a;
      for (long i = 0; i < 10; i++) {
        for (long j = 0; j < mass1[i]; j++) {
          s1[a] = i;
          a--;
        }
        for (long j = 0; j < mass2[i]; j++) {
          s2[b] = i;
          b--;
        }
      }
      for (long i = 0; i < s.size(); i++) cout << s1[i];
      cout << "\n";
      for (long i = 0; i < s.size(); i++) cout << s2[i];
    } else {
      mass1[num]--;
      mass2[10 - num]--;
      for (long i = 0; i < mass1[0]; i++) {
        s1[a] = 0;
        s2[a] = 0;
        a--;
      }
      mass1[0] = 0;
      mass2[0] = 0;
      s1[a] = num;
      s2[a] = 10 - num;
      a--;
      for (long i = 1; i < 9; i++) {
        for (long j = 0; j < min(mass1[i], mass2[9 - i]); j++) {
          s1[a] = i;
          s2[a] = 9 - i;
          a--;
        }
        long kq = min(mass1[i], mass2[9 - i]);
        mass1[i] -= kq;
        mass2[9 - i] -= kq;
      }
      long b = a;
      for (long i = 0; i < 10; i++) {
        for (long j = 0; j < mass1[i]; j++) {
          s1[a] = i;
          a--;
        }
        for (long j = 0; j < mass2[i]; j++) {
          s2[b] = i;
          b--;
        }
      }
      for (long i = 0; i < s.size(); i++) cout << s1[i];
      cout << "\n";
      for (long i = 0; i < s.size(); i++) cout << s2[i];
    }
  } else {
    for (long i = 9; i >= 0; i--)
      for (long j = 0; j < mass1[i]; j++) cout << i;
    cout << "\n";
    for (long i = 9; i >= 0; i--)
      for (long j = 0; j < mass1[i]; j++) cout << i;
  }
}