#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> count(string &inp) {
  unordered_map<int, int> ret;
  for (auto x : inp) ret[x - '0']++;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  string inp;
  cin >> inp;
  auto cc = count(inp);
  int maxi = -1, idx = -1;
  string ansa, ansb;
  int mini = min(cc[0], cc[9]);
  while (cc[0] > mini) ansa += '0', ansb += '0', cc[0]--;
  for (auto i = 0; i < (10); i++) {
    int j = 10 - i;
    auto aa = cc;
    auto bb = cc;
    if (!aa[i] || !bb[j]) continue;
    aa[i]--;
    bb[j]--;
    int total = 1;
    for (auto k = 0; k < (10); k++) {
      int tk = 9 - k;
      int temp = min(aa[k], bb[tk]);
      total += temp;
      aa[k] -= temp;
      bb[tk] -= temp;
    }
    if (maxi < total) maxi = total, idx = i;
  }
  auto cc2 = cc;
  if (idx != -1) {
    ansa += char(idx + '0');
    ansb += char(10 - idx + '0');
    cc[idx]--;
    cc2[10 - idx]--;
    for (auto k = 0; k < (10); k++) {
      int tk = 9 - k;
      int temp = min(cc[k], cc2[tk]);
      cc[k] -= temp;
      cc2[tk] -= temp;
      while (temp--) {
        ansa += char(k + '0');
        ansb += char(tk + '0');
      }
    }
  }
  for (auto x : cc)
    while (x.second--) ansa += char(x.first + '0');
  for (auto x : cc2)
    while (x.second--) ansb += char(x.first + '0');
  reverse(ansa.begin(), ansa.end());
  reverse(ansb.begin(), ansb.end());
  cout << ansa << endl << ansb << endl;
  return 0;
}
