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;
template <class T>
void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
void out(vector<T> A, int n = -1) {
  if (n == -1) n = ((int)A.size());
  if (n > ((int)A.size())) n = ((int)A.size());
  cout << "{";
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << "}" << endl;
}
template <class T>
void out(T A[], int n) {
  cout << "{";
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << "}" << endl;
}
string tostring(int v) {
  ostringstream sout;
  sout << v;
  return sout.str();
}
string tostring(long long v) {
  ostringstream sout;
  sout << v;
  return sout.str();
}
int low(int i) { return i & -i; }
int countbit(int i) { return (i == 0) ? 0 : (1 + countbit(i - low(i))); }
int toint(string s) {
  istringstream sin(s);
  int t;
  sin >> t;
  return t;
}
long long toint64(string s) {
  istringstream sin(s);
  long long t;
  sin >> t;
  return t;
}
const double pi = acos(-1.);
const double eps = 1e-11;
string s;
int a[200005], b[200005], f[200005], g[200005];
int main() {
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) a[(int)(s[i] - '0')]++, b[(int)(s[i] - '0')]++;
  int max = -1, last = 0, haha = 0;
  for (int k = 0; k <= a[0]; k++) {
    a[0] -= k;
    b[0] -= k;
    for (int i = 1; i < 10; i++)
      if (a[i] > 0 && b[10 - i] > 0) {
        a[i]--;
        b[10 - i]--;
        int t = k;
        for (int j = 0; j <= 9; j++) t += min(a[j], b[9 - j]);
        if (t > max) {
          max = t;
          last = i;
          haha = k;
        }
        a[i]++;
        b[10 - i]++;
      }
    a[0] += k;
    b[0] += k;
  }
  if (last == 0) {
    for (int i = 9; i >= 0; i--)
      while (a[i]) printf("%d", i), a[i]--;
    printf("\n");
    for (int i = 9; i >= 0; i--)
      while (b[i]) printf("%d", i), b[i]--;
    printf("\n");
  } else {
    int tot = 0;
    while (a[0]) {
      if (tot == haha) break;
      tot++, f[tot] = 0, g[tot] = 0, a[0]--, b[0]--;
    }
    tot++;
    f[tot] = last;
    g[tot] = 10 - last;
    a[last]--;
    b[10 - last]--;
    for (int j = 0; j <= 9; j++) {
      while (min(a[j], b[9 - j]) > 0) {
        tot++;
        f[tot] = j;
        g[tot] = 9 - j;
        a[j]--;
        b[9 - j]--;
      }
    }
    int t1 = tot, t2 = tot;
    for (int j = 0; j <= 9; j++) {
      while (a[j]) t1++, f[t1] = j, a[j]--;
      while (b[j]) t2++, g[t2] = j, b[j]--;
    }
    for (int i = n; i > 0; i--) printf("%d", f[i]);
    printf("\n");
    for (int i = n; i > 0; i--) printf("%d", g[i]);
    printf("\n");
  }
  return 0;
}