#include <bits/stdc++.h>
using namespace std;
int cnt[100], cnt1[100], cnt2[100], c[100];
vector<int> ans1, ans2;
int ansv;
int c1[100], c2[100];
int main() {
  string str;
  int s, bst, ans;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    cnt[str[i] - 48]++;
  }
  ansv = -1;
  ans = cnt[0];
  bst = ans;
  for (int zeros = 0; zeros <= cnt[0]; zeros++) {
    for (int pp = 0; pp <= 9; pp++) {
      for (int i = 0; i <= 9; i++) c1[i] = c2[i] = cnt[i];
      c1[0] -= zeros;
      s = zeros;
      if (c1[pp] == 0 || c2[10 - pp] == 0) continue;
      c1[pp]--;
      c2[10 - pp]--;
      for (int i = 0; i <= 9; i++) s += min(c1[i], c2[9 - i]);
      s++;
      if (s > bst) {
        bst = s;
        ans = zeros;
        ansv = pp;
      }
    }
  }
  for (int i = 0; i <= 9; i++) cnt1[i] = cnt2[i] = cnt[i];
  for (int i = 0; i < ans; i++) {
    ans1.push_back(0);
    ans2.push_back(0);
    --cnt1[0];
    --cnt2[0];
  }
  if (ansv != -1) {
    ans1.push_back(ansv);
    --cnt1[ansv];
    ans2.push_back(10 - ansv);
    --cnt2[10 - ansv];
  }
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j < min(cnt1[i], cnt2[9 - i]); j++) {
      ans1.push_back(i);
      ans2.push_back(9 - i);
    }
    int q = min(cnt1[i], cnt2[9 - i]);
    for (int j = 0; j < q; j++) {
      --cnt1[i];
      --cnt2[9 - i];
    }
  }
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < cnt1[i]; j++) ans1.push_back(i);
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < cnt2[i]; j++) ans2.push_back(i);
  reverse(ans1.begin(), ans1.end());
  reverse(ans2.begin(), ans2.end());
  for (int i = 0; i < ans1.size(); i++) cout << ans1[i];
  cout << endl;
  for (int i = 0; i < ans2.size(); i++) cout << ans2[i];
  cout << endl;
  return 0;
}
