#include <bits/stdc++.h>
using namespace std;
int cnt1[10];
int cnt2[10];
int cnt[10];
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) cnt[s[i] - '0']++;
  int ans = cnt[0];
  string a, b;
  sort(s.begin(), s.end());
  a = s;
  b = s;
  for (int i = 1; i < 10; i++) {
    int cur = 0;
    string ta, tb;
    for (int j = 0; j < 10; j++) cnt1[j] = cnt2[j] = cnt[j];
    if (cnt1[i] && cnt2[10 - i]) {
      int d = min(cnt1[0] - cnt2[9], cnt2[0] - cnt1[9]);
      for (int j = 0; j < d; j++) {
        ta.push_back('0');
        tb.push_back('0');
        cnt1[0]--;
        cnt2[0]--;
        cur++;
      }
      cur = 1;
      cnt1[i]--;
      cnt2[10 - i]--;
      ta.push_back('0' + i);
      tb.push_back('0' + 10 - i);
      for (int j = 0; j <= 9; j++) {
        cur += min(cnt1[j], cnt2[9 - j]);
        int d = min(cnt1[j], cnt2[9 - j]);
        for (int k = 0; k < d; k++) {
          ta.push_back('0' + j);
          tb.push_back('0' + 9 - j);
        }
        cnt1[j] -= d;
        cnt2[9 - j] -= d;
      }
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < cnt1[j]; k++) ta.push_back('0' + j);
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < cnt2[j]; k++) tb.push_back('0' + j);
      if (ans < cur) {
        ans = cur;
        a = ta;
        b = tb;
      }
    }
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  cout << a << endl;
  cout << b << endl;
  return 0;
}
