#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  map<int, int> m;
  map<int, int> n;
  for (char i : s) {
    m[i - '0']++;
    n[i - '0']++;
  }
  sort((s).begin(), (s).end());
  string ans1 = s, ans2 = s;
  int curz = 0;
  for (int i = (1); i < (10); i += 1) {
    if (!(m[i] > 0 && n[10 - i] > 0)) continue;
    m[i]--;
    n[10 - i]--;
    int curans = 1 + min(m[0], n[9]) + min(m[1], n[8]) + min(m[2], n[7]) +
                 min(m[3], n[6]) + min(m[4], n[5]) + min(m[5], n[4]) +
                 min(m[6], n[3]) + min(m[7], n[2]) + min(m[8], n[1]) +
                 min(m[9], n[0]) +
                 min(max(0, m[0] - n[9]), max(0, n[0] - m[9]));
    int zeroes = min(max(0, m[0] - n[9]), max(0, n[0] - m[9]));
    cerr << i << " " << curans << '\n';
    if (curans > curz) {
      curz = curans;
      map<int, int> used1;
      map<int, int> used2;
      ans1 = "";
      ans2 = "";
      for (int i = (0); i < (zeroes); i += 1) {
        ans1.push_back('0');
        ans2.push_back('0');
      }
      used1[0] += zeroes;
      used2[0] += zeroes;
      ans1.push_back(i + '0');
      ans2.push_back(10 - i + '0');
      for (int i = (0); i < (10); i += 1) {
        for (int j = (0); j < (min(m[i], n[9 - i])); j += 1) {
          ans1.push_back(i + '0');
          ans2.push_back(9 - i + '0');
          used1[i]++;
          used2[9 - i]++;
        }
      }
      int alpha = 0, beta = 0;
      for (int i = (0); i < (10); i += 1) alpha += m[i] - used1[i];
      for (int i = (0); i < (10); i += 1) beta += n[i] - used2[i];
      for (int kachra = (0); kachra < (10); kachra += 1) {
        for (int gf = (0); gf < (m[kachra] - used1[kachra]); gf += 1)
          ans1.push_back(kachra + '0');
      }
      for (int kachra = (0); kachra < (10); kachra += 1) {
        for (int gf = (0); gf < (n[kachra] - used2[kachra]); gf += 1)
          ans2.push_back(kachra + '0');
      }
    }
    m[i]++;
    n[10 - i]++;
  }
  reverse((ans2).begin(), (ans2).end());
  reverse((ans1).begin(), (ans1).end());
  cout << ans1 << '\n' << ans2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
