#include <bits/stdc++.h>
using namespace std;
int a[10], b[10], k[10];
int main() {
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  string s;
  getline(cin, s);
  int len = s.size(), ans = 0;
  for (int i = 0; i < len; i++) a[int(s[i]) - 48]++, b[int(s[i]) - 48]++;
  int maxzero = 0, maxlen = -1, maxfirst = -1;
  for (int zero = 0; zero <= min(a[0], b[0]); zero++) {
    a[0] -= zero;
    b[0] -= zero;
    if (zero > maxlen) {
      maxlen = zero;
      maxzero = zero;
      maxfirst = -1;
    }
    for (int one = 1; one <= 9; one++)
      if (a[one] > 0 && b[10 - one] > 0) {
        a[one]--;
        b[10 - one]--;
        ans = zero + 1;
        for (int j = 0; j <= 9; j++) ans += min(a[j], b[9 - j]);
        if (ans > maxlen) {
          maxlen = ans;
          maxfirst = one;
          maxzero = zero;
          for (int j = 0; j <= 9; j++) k[j] = min(a[j], b[9 - j]);
        }
        b[10 - one]++;
        a[one]++;
      }
    a[0] += zero;
    b[0] += zero;
  }
  string tmp(maxzero, '0');
  a[0] -= maxzero;
  b[0] -= maxzero;
  string bestans1 = tmp, bestans2 = tmp;
  if (maxfirst != -1) {
    bestans1 = char(maxfirst + 48) + bestans1;
    bestans2 = char(10 - maxfirst + 48) + bestans2;
    a[maxfirst]--;
    b[10 - maxfirst]--;
  }
  for (int j = 0; j <= 9; j++)
    if (k[j]) {
      string tmp1(k[j], char(j + 48));
      string tmp2(k[j], char(9 - j + 48));
      a[j] -= k[j];
      b[9 - j] -= k[j];
      bestans1 = tmp1 + bestans1;
      bestans2 = tmp2 + bestans2;
    }
  for (int j = 9; j >= 0; j--)
    if (a[j]) {
      string tmp1(a[j], char(48 + j));
      bestans1 = tmp1 + bestans1;
    }
  for (int j = 9; j >= 0; j--)
    if (b[j]) {
      string tmp(b[j], char(j + 48));
      bestans2 = tmp + bestans2;
    }
  cout << bestans1 << endl;
  cout << bestans2 << endl;
  return 0;
}
