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 counter1[11] = {0}, counter2[11] = {0}, temp1[11] = {0}, temp2[11] = {0};
vector<int> a, b;
int main() {
  string temp;
  int bigcounter = 0;
  cin >> temp;
  for (int i = 0; i < temp.size(); i++) {
    counter1[temp[i] - '0']++;
    counter2[temp[i] - '0']++;
    temp1[temp[i] - '0']++;
    temp2[temp[i] - '0']++;
    bigcounter++;
  }
  int maxi = -2147483647, maxind = -1;
  for (int i = 1; i <= 5; i++) {
    int counter = 0;
    if (!temp1[i] || !temp2[10 - i]) continue;
    temp1[i]--, temp2[10 - i]--;
    counter++;
    for (int j = 0; j < 5; j++) {
      int mini = min(temp1[j], temp2[9 - j]);
      temp1[j] -= mini, temp2[9 - j] -= mini;
      counter += mini;
    }
    for (int j = 0; j < 5; j++) {
      int mini = min(temp1[9 - j], temp2[j]);
      temp1[9 - j] -= mini, temp2[j] -= mini;
      counter += mini;
    }
    int minii = 0;
    for (int j = 1; j <= 5; j++) {
      int mini = min(temp1[j], temp2[10 - j]);
      temp1[j] -= mini, temp2[10 - j] -= mini;
      minii += mini;
    }
    for (int j = 1; j <= 5; j++) {
      int mini = min(temp1[10 - j], temp2[j]);
      temp1[10 - j] -= mini, temp2[j] -= mini;
      minii += mini;
    }
    int mini = min(temp1[0], temp2[0]);
    temp1[0] -= mini, temp2[0] -= mini;
    counter += mini;
    int rest = bigcounter - counter - minii;
    counter += min(rest, mini);
    if (counter > maxi) {
      maxi = counter;
      maxind = i;
    }
    for (int i = 0; i < 10; i++) {
      temp1[i] = counter1[i];
      temp2[i] = counter2[i];
    }
  }
  if (maxind == -1) {
    for (int i = 0; i < 10; i++)
      for (int j = 0; j < counter1[i]; j++) a.push_back(i), b.push_back(i);
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    for (int i = 0; i < a.size(); i++) printf("%d", a[i]);
    printf("\n");
    for (int i = 0; i < a.size(); i++) printf("%d", b[i]);
    return 0;
  }
  a.push_back(maxind), b.push_back(10 - maxind);
  counter1[maxind]--, counter2[10 - maxind]--;
  for (int j = 0; j < 10; j++) {
    int mini = min(counter1[j], counter2[9 - j]);
    counter1[j] -= mini, counter2[9 - j] -= mini;
    for (int i = 0; i < mini; i++) a.push_back(j), b.push_back(9 - j);
  }
  vector<int> resta, restb;
  if (counter1[0] > counter2[0]) {
    for (int j = 0; j < counter1[0] - counter2[0]; j++) resta.push_back(0);
    counter1[0] = counter2[0];
  } else if (counter1[0] < counter2[0]) {
    for (int j = 0; j < counter2[0] - counter1[0]; j++) restb.push_back(0);
    counter2[0] = counter1[0];
  }
  for (int i = 1; i < 10; i++) {
    if (counter1[i] > counter2[10 - i]) {
      for (int j = 0; j < counter1[i] - counter2[10 - i]; j++)
        resta.push_back(i);
      counter1[i] = counter2[10 - i];
    }
    if (counter1[10 - i] < counter2[i]) {
      for (int j = 0; j < counter2[i] - counter1[10 - i]; j++)
        restb.push_back(i);
      counter2[i] = counter1[10 - i];
    }
  }
  int n = resta.size();
  vector<int> tensa, tensb;
  for (int i = 1; i < 10; i++)
    for (int j = 0; j < counter1[i]; j++) {
      tensa.push_back(i);
      tensb.push_back(10 - i);
    }
  int m = tensa.size();
  for (int i = 0; i < n; i++) {
    a.push_back(resta[i]), b.push_back(restb[i]);
    if (i < m) a.push_back(tensa[i]), b.push_back(tensb[i]);
  }
  for (int i = n; i < m; i++) a.push_back(tensa[i]), b.push_back(tensb[i]);
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < counter1[0]; i++) a.push_back(0), b.push_back(0);
  for (int i = 0; i < a.size(); i++) printf("%d", a[i]);
  printf("\n");
  for (int i = 0; i < a.size(); i++) printf("%d", b[i]);
  return 0;
}