#include <bits/stdc++.h>
using namespace std;
template <class T>
istream &operator>>(istream &is, vector<T> &a) {
  for (int i = 0; i < a.size(); ++i) is >> a[i];
  return is;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> a) {
  for (auto i : a) os << i << " ";
  return os;
}
int main() {
  string n;
  cin >> n;
  vector<int> cnt1(10, 0), cnt2(10, 0);
  for (char i : n) {
    ++cnt1[i - '0'];
    ++cnt2[i - '0'];
  }
  int ans = 0, ansi = -1, ansz = -1;
  for (int zerocol = 0; zerocol <= cnt1[0]; ++zerocol) {
    for (int i = 1; i < 10; ++i) {
      auto cnt1b = cnt1;
      auto cnt2b = cnt2;
      int cur = zerocol;
      cnt1b[0] -= zerocol;
      cnt2b[0] -= zerocol;
      if (cnt1[i] && cnt2[10 - i]) {
        --cnt1b[i];
        --cnt2b[10 - i];
        ++cur;
        for (int j = 0; j < 10; ++j) {
          int col = min(cnt1b[j], cnt2b[9 - j]);
          cnt1b[j] -= col;
          cnt2b[9 - j] -= col;
          cur += col;
        }
      }
      if (cur >= ans) {
        ans = cur;
        ansi = i;
        ansz = zerocol;
      }
    }
  }
  string ans1, ans2;
  cnt1[0] -= ansz;
  cnt2[0] -= ansz;
  for (int i = 0; i < ansz; ++i) ans1.push_back('0');
  for (int i = 0; i < ansz; ++i) ans2.push_back('0');
  if (cnt1[ansi]) {
    --cnt1[ansi];
    ans1.push_back(ansi + '0');
  }
  if (cnt2[10 - ansi]) {
    --cnt2[10 - ansi];
    ans2.push_back(10 - ansi + '0');
  }
  for (int i = 0; i < 10; ++i) {
    int col = min(cnt1[i], cnt2[9 - i]);
    cnt1[i] -= col;
    cnt2[9 - i] -= col;
    for (int j = 0; j < col; ++j) {
      ans1.push_back(i + '0');
      ans2.push_back(9 - i + '0');
    }
  }
  for (int i = 0; i < 10; ++i)
    while (cnt1[i]) {
      ans1.push_back(i + '0');
      --cnt1[i];
    }
  for (int i = 0; i < 10; ++i)
    while (cnt2[i]) {
      ans2.push_back(i + '0');
      --cnt2[i];
    }
  reverse(ans1.begin(), ans1.end());
  reverse(ans2.begin(), ans2.end());
  cout << ans1 << "\n" << ans2;
}
