#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  string s1, s2;
  for (int i = 1; i <= 5; i++) {
    int dig[10] = {0}, dig2[10] = {0};
    for (size_t j = 0; j < s.size(); j++) {
      dig[s[j] - '0']++;
      dig2[s[j] - '0']++;
    }
    if (i == 1) {
      ans = dig[0];
      s1 = string(ans, '0');
      for (int j = 1; j < 10; j++) {
        s1.append(dig[j], '0' + j);
      }
      reverse(s1.begin(), s1.end());
      s2 = s1;
    }
    if (dig[i] && dig[10 - i]) {
      string ss1, ss2;
      ss1.append(1, '0' + i);
      ss2.append(1, '0' + 10 - i);
      dig[i]--;
      dig2[10 - i]--;
      int sum = 1 + dig[0];
      for (int j = 0; j < 10; j++) {
        int add = min(dig[j], dig2[9 - j]);
        dig[j] -= add;
        dig2[9 - j] -= add;
        sum += add;
        ss1.append(add, '0' + j);
        ss2.append(add, '0' + 9 - j);
      }
      if (sum > ans) {
        int add0 = min(dig[0], dig2[0]);
        dig[0] -= add0;
        dig2[0] -= add0;
        for (int j = 0; j < 10; j++) {
          ss1.append(dig[j], '0' + j);
          ss2.append(dig2[j], '0' + j);
        }
        reverse(ss1.begin(), ss1.end());
        reverse(ss2.begin(), ss2.end());
        ss1.append(add0, '0');
        ss2.append(add0, '0');
        s1 = ss1;
        s2 = ss2;
        ans = sum;
      }
    }
  }
  cout << s1 << endl;
  cout << s2 << endl;
  return 0;
}
