#include <bits/stdc++.h>
using namespace std;
long long int cnt[2][10];
string s0, s1;
long long int recur(long long int num0, long long int num1) {
  if (num0 == 10) return 0;
  long long int mini = min(cnt[0][num0], cnt[1][num1]);
  cnt[0][num0] -= mini;
  cnt[1][num1] -= mini;
  s0 += string(mini, '0' + num0);
  s1 += string(mini, '0' + num1);
  return recur(num0 + 1, num1 - 1) + mini;
}
int main() {
  string a;
  cin >> a;
  sort((a).begin(), (a).end());
  reverse((a).begin(), (a).end());
  long long int best = 0;
  pair<string, string> res = make_pair(a, a);
  for (long long int num0 = 1; num0 <= 5; num0++) {
    long long int num1 = 10 - num0;
    for (int i = 0; i < ((int)(10)); ++i)
      cnt[0][i] = cnt[1][i] = count((a).begin(), (a).end(), '0' + i);
    cnt[0][num0]--;
    cnt[1][num1]--;
    if (0 <= cnt[0][num0] && 0 <= cnt[1][num1]) {
      s0 = string(1, '0' + num0);
      s1 = string(1, '0' + num1);
      long long int t = recur(0, 9);
      long long int mini = min(cnt[0][0], cnt[1][0]);
      t += mini + 1;
      s0 = string(mini, '0') + s0;
      s1 = string(mini, '0') + s1;
      cnt[0][0] -= mini;
      cnt[1][0] -= mini;
      for (int i = 0; i < ((int)(10)); ++i) s0 += string(cnt[0][i], '0' + i);
      for (int i = 0; i < ((int)(10)); ++i) s1 += string(cnt[1][i], '0' + i);
      if (best < t) {
        best = t;
        reverse((s0).begin(), (s0).end());
        reverse((s1).begin(), (s1).end());
        res = make_pair(s0, s1);
      }
    }
    cnt[0][num0]++;
    cnt[1][num1]++;
  }
  cout << res.first << endl << res.second << endl;
}
