#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string s1 = s, s2 = s, ans1 = s, ans2 = s;
  int maxzeroLen = 0;
  const int N = s.size();
  int cnt[10] = {0};
  for (int _n(N), i(0); i < _n; i++) cnt[s[i] - '0']++;
  int c1[10], c2[10];
  for (int start = 5; start >= 0; --start) {
    if (!(cnt[start] > 0 && cnt[(10 - start) % 10] > 0)) continue;
    for (int _n(10), i(0); i < _n; i++) c1[i] = c2[i] = cnt[i];
    int i = 0;
    {
      s1[i] = '0' + start;
      s2[i] = '0' + (10 - start) % 10;
      c1[start]--, c2[(10 - start) % 10]--;
    }
    ++i;
    for (int k1 = 9; k1 >= 5; --k1) {
      int k2 = 9 - k1;
      for (int _n(2), it(0); it < _n; it++) {
        for (; i < N; ++i) {
          if (c1[k1] > 0 && c2[k2] > 0) {
            c1[k1]--, c2[k2]--;
            s1[i] = '0' + k1;
            s2[i] = '0' + k2;
          } else
            break;
        }
        swap(k1, k2);
      }
    }
    if (i < N) {
      int i1 = i, i2 = i;
      int sh = min(c1[0], c2[0]);
      c1[0] -= sh;
      c2[0] -= sh;
      for (int _n(10), k(0); k < _n; k++) {
        if (c1[k]) {
          while (c1[k]--) s1[i1++] = '0' + k;
        }
        if (c2[k]) {
          while (c2[k]--) s2[i2++] = '0' + k;
        }
      }
      if (sh > 0) {
        s1 = string(sh, '0') + s1.substr(0, N - sh);
        s2 = string(sh, '0') + s2.substr(0, N - sh);
      }
      i += sh;
    }
    if (maxzeroLen < i + 1) {
      maxzeroLen = i + 1;
      ans1 = s1;
      ans2 = s2;
    }
  }
  reverse((ans1).begin(), (ans1).end());
  reverse((ans2).begin(), (ans2).end());
  cout << ans1 << endl << ans2 << endl;
  return 0;
}
