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 num1[10][100010], num2[10][100010];
int ansnum1[100010], ansnum2[100010], lastnum1[100010], lastnum2[100010];
string str;
int max_match() {
  int anssum = 0;
  int ansid = -1;
  for (int i = 0; i <= 9; ++i) {
    int maxm = 0;
    if (!num1[i][i] || !num2[i][10 - i]) continue;
    num1[i][i]--;
    num2[i][10 - i]--;
    maxm++;
    for (int j = 0; j <= 9; ++j) {
      if (!num1[i][j] || !num2[i][9 - j]) continue;
      int minn = min(num1[i][j], num2[i][9 - j]);
      num1[i][j] -= minn;
      num2[i][9 - j] -= minn;
      maxm += minn;
    }
    maxm += min(num1[i][0], num2[i][0]);
    if (anssum < maxm) {
      anssum = maxm;
      ansid = i;
    }
  }
  int maxm = min(num1[0][0], num2[0][0]);
  if (anssum < maxm) {
    anssum = maxm;
    ansid = 0;
  }
  return ansid;
}
int main() {
  while (cin >> str) {
    int len = str.length();
    memset(num1, 0, sizeof(num1));
    memset(num2, 0, sizeof(num2));
    memset(ansnum1, 0, sizeof(ansnum1));
    memset(ansnum2, 0, sizeof(ansnum2));
    memset(lastnum1, 0, sizeof(lastnum1));
    memset(lastnum2, 0, sizeof(lastnum2));
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j < len; ++j) {
        int temp = str[j] - '0';
        num1[i][temp]++;
        num2[i][temp]++;
      }
    }
    for (int i = 0; i < len; ++i) {
      int temp = str[i] - '0';
      ansnum1[temp]++;
      ansnum2[temp]++;
      lastnum1[temp]++;
      lastnum2[temp]++;
    }
    int last_num = max_match();
    if (last_num == -1) {
      cout << str << endl << str << endl;
      continue;
    }
    string ans1, ans2;
    ans1.resize(len), ans2.resize(len);
    if (last_num == 0) {
      int cnt = len - 1;
      for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j < ansnum1[i]; j++) {
          ans1[cnt] = i + '0';
          ans2[cnt--] = i + '0';
        }
      }
      cout << ans1 << endl << ans2 << endl;
      continue;
    }
    ansnum1[last_num]--;
    ansnum2[10 - last_num]--;
    for (int i = 0; i <= 9; ++i) {
      if (!ansnum1[i] || !ansnum2[9 - i]) continue;
      int minn = min(ansnum1[i], ansnum2[9 - i]);
      ansnum1[i] -= minn;
      ansnum2[9 - i] -= minn;
    }
    int minn = min(ansnum1[0], ansnum2[0]);
    int cnt = len - 1;
    lastnum1[0] -= minn;
    lastnum2[0] -= minn;
    for (int i = 0; i < minn; ++i) {
      ans1[cnt] = 0 + '0';
      ans2[cnt--] = 0 + '0';
    }
    ans1[cnt] = last_num + '0';
    ans2[cnt--] = 10 - last_num + '0';
    lastnum1[last_num] -= 1;
    lastnum2[10 - last_num] -= 1;
    for (int i = 0; i <= 9; ++i) {
      if (!lastnum1[i] || !lastnum2[9 - i]) continue;
      int minn = min(lastnum1[i], lastnum2[9 - i]);
      for (int j = 0; j < minn; ++j) {
        ans1[cnt] = i + '0';
        ans2[cnt--] = 9 - i + '0';
      }
      lastnum1[i] -= minn;
      lastnum2[9 - i] -= minn;
    }
    int cnt1 = cnt;
    int cnt2 = cnt;
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j < lastnum1[i]; ++j) {
        ans1[cnt1--] = i + '0';
      }
    }
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j < lastnum2[i]; ++j) {
        ans2[cnt2--] = i + '0';
      }
    }
    cout << ans1 << endl << ans2 << endl;
  }
  return 0;
}