#include <bits/stdc++.h>
using namespace std;
int fun() {
  string s;
  int n;
  int s1[10] = {0}, s2[10] = {0};
  string a = "", b = "";
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    s1[s[i] - '0']++;
    s2[s[i] - '0']++;
  }
  int k = -1, f = 1;
  for (int i = 1; i <= 9; i++) {
    if (s1[i] > s2[9 - i] && s2[10 - i] > s1[i - 1]) {
      a += i + '0';
      b += 10 - i + '0';
      --s1[i];
      --s2[10 - i];
      f = 0;
      break;
    } else if (s1[i] > s2[9 - i] && s2[10 - i])
      k = i;
  }
  if (f && k != -1) {
    a += k + '0';
    b += 10 - k + '0';
    --s1[k];
    --s2[10 - k];
  } else if (f && k == -1) {
    for (int i = 1; i <= 9; i++)
      if (s1[i] && s2[10 - i]) {
        a += i + '0';
        b += 10 - i + '0';
        --s1[i];
        --s2[10 - i];
        break;
      }
  }
  for (int i = 0; i <= 9; ++i) {
    for (int j = 0; j < s1[i] && j < s2[9 - i]; ++j) {
      a += i + '0';
      b += 9 - i + '0';
    }
    k = s1[i] > s2[9 - i] ? s2[9 - i] : s1[i];
    s1[i] -= k;
    s2[9 - i] -= k;
  }
  k = s1[0] > s2[0] ? s2[0] : s1[0];
  s1[0] -= k;
  s2[0] -= k;
  for (int i = 0; i <= 9; i++)
    while (s1[i]) {
      s1[i]--;
      a += i + '0';
    }
  for (int i = 0; i <= 9; i++)
    while (s2[i]) {
      s2[i]--;
      b += i + '0';
    }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < k; i++) {
    a += '0';
    b += '0';
  }
  cout << a << '\n' << b << '\n';
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  int size;
  fun();
  return 0;
}
