#include <bits/stdc++.h>
using namespace std;
string s;
int cnt1[11], cnt2[11], res1[100005], res2[100005];
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    ++cnt1[s[i] - '0'];
    ++cnt2[s[i] - '0'];
  }
  int res = 0, cntZero = 0, t1 = -1, t2 = -1;
  for (int x = 0; x <= cnt1[0]; ++x) {
    cnt1[0] -= x;
    cnt2[0] -= x;
    for (int i = 1; i <= 5; ++i) {
      int j = 10 - i;
      if (cnt1[i] && cnt2[j]) {
        --cnt1[i];
        --cnt2[j];
        int numZeroes = x + 1;
        for (int k = 0; k <= 9; ++k) numZeroes += min(cnt1[k], cnt2[9 - k]);
        if (numZeroes > res) {
          res = numZeroes;
          cntZero = x;
          t1 = i;
          t2 = j;
        }
        ++cnt1[i];
        ++cnt2[j];
      }
    }
    cnt1[0] += x;
    cnt2[0] += x;
  }
  if (t1 == -1 && t2 == -1) {
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    cout << s << endl;
    cout << s << endl;
    return 0;
  }
  for (int i = 0; i < cntZero; ++i) res1[i] = res2[i] = 0;
  cnt1[0] -= cntZero;
  cnt2[0] -= cntZero;
  --cnt1[t1];
  --cnt2[t2];
  res1[cntZero] = t1;
  res2[cntZero] = t2;
  for (int i = cntZero + 1; i < s.size(); ++i) {
    bool ok = false;
    for (int j = 0; j <= 9; ++j) {
      if (cnt1[j] && cnt2[9 - j]) {
        --cnt1[j];
        --cnt2[9 - j];
        ok = true;
        res1[i] = j;
        res2[i] = 9 - j;
        break;
      }
    }
    if (!ok) {
      for (int j = 0; j <= 9; ++j) {
        if (cnt1[j]) {
          res1[i] = j;
          --cnt1[j];
          break;
        }
      }
      for (int j = 0; j <= 9; ++j) {
        if (cnt2[j]) {
          res2[i] = j;
          --cnt2[j];
          break;
        }
      }
    }
  }
  for (int i = s.size() - 1; i >= 0; --i) printf("%d", res1[i]);
  printf("\n");
  for (int i = s.size() - 1; i >= 0; --i) printf("%d", res2[i]);
  printf("\n");
  return 0;
}
