#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const int INF = 1e9 + 7;
const int MAXN = int(2e5 + 7);
int n, a[10], b[10], j, ans;
string second, t1, t2;
int calc() {
  int res = 0;
  for (int i = 0; i < 10; i++) res += min(a[i], b[9 - i]);
  return res;
}
int main() {
  cin >> second;
  n = second.size();
  for (int i = 0; i < n; i++) a[second[i] - '0']++, b[second[i] - '0']++;
  ans = a[0];
  for (int i = 1; i < 10; i++) {
    if (a[i] && b[10 - i]) {
      a[i]--;
      b[10 - i]--;
      int res =
          1 + calc() + min(b[0] - min(b[0], a[9]), a[0] - min(a[0], b[9]));
      if (res > ans) ans = res, j = i;
      a[i]++;
      b[10 - i]++;
    }
  }
  if (ans != a[0]) {
    a[j]--;
    b[10 - j]--;
  }
  int cnt0 = min(b[0] - min(b[0], a[9]), a[0] - min(a[0], b[9]));
  a[0] -= cnt0;
  b[0] -= cnt0;
  for (int i = 0; i < cnt0; i++) {
    t1 += '0';
    t2 += '0';
  }
  if (ans != a[0] + cnt0) {
    t1 = char(j + '0') + t1;
    t2 = char(10 - j + '0') + t2;
  }
  for (int i = 0; i < 10; i++) {
    int cnti = min(a[i], b[9 - i]);
    for (int k = 0; k < cnti; k++) {
      t1 = char(i + '0') + t1;
      t2 = char(9 - i + '0') + t2;
    }
    a[i] -= cnti;
    b[9 - i] -= cnti;
  }
  for (int i = 0; i < 10; i++) {
    for (int k = 0; k < a[i]; k++) t1 = char(i + '0') + t1;
    for (int k = 0; k < b[i]; k++) t2 = char(i + '0') + t2;
  }
  cout << t1 << endl << t2;
  return 0;
}
