#include <bits/stdc++.h>
using namespace std;
int main() {
  string number;
  cin >> number;
  vector<int> freq(10, 0);
  for (int i = 0; i < (int)number.size(); i++) {
    freq[number[i] - '0']++;
  }
  int max_count = 0;
  string max_s1 = number, max_s2 = number;
  for (int i = 1; i <= 9; i++) {
    vector<int> f1 = freq, f2 = freq;
    string s1, s2;
    int count = 0;
    if (f1[i] > 0 && f2[10 - i] > 0) {
      s1 += '0' + i;
      s2 += '0' + 10 - i;
      f1[i]--;
      f2[10 - i]--;
      count++;
      for (int i = 0; i <= 9; i++) {
        if (f1[i] > 0 && f2[9 - i] > 0) {
          int appears = min(f1[i], f2[9 - i]);
          s1 = string(appears, '0' + i) + s1;
          s2 = string(appears, '0' + 9 - i) + s2;
          f1[i] -= appears;
          f2[9 - i] -= appears;
          count += appears;
        }
      }
      int nr_0 = min(f1[0], f2[0]);
      if (nr_0 > 0) {
        f1[0] -= nr_0;
        f2[0] -= nr_0;
        s1 += string(nr_0, '0');
        s2 += string(nr_0, '0');
        count += nr_0;
      }
      if (count > max_count) {
        max_count = count;
        for (int i = 0; i <= 9; i++) {
          s1 = string(f1[i], '0' + i) + s1;
          s2 = string(f2[i], '0' + i) + s2;
        }
        max_s1 = s1;
        max_s2 = s2;
      }
    }
  }
  int nr_0 = freq[0];
  if (nr_0 > max_count) {
    string s1;
    for (int i = 9; i >= 0; i--) {
      s1 += string(freq[i], '0' + i);
    }
    max_s1 = s1;
    max_s2 = s1;
  }
  cout << max_s1 << " \n" << max_s2 << "\n";
  return 0;
}
