#include <bits/stdc++.h>
using namespace std;
int a[10] = {}, b[10] = {}, org[10] = {};
char res1[200000] = {}, res2[200000] = {};
int main() {
  char c;
  while (cin >> c) ++a[c - '0'];
  int l = 0;
  for (int i = 0; i < 10; ++i) b[i] = a[i], l += a[i], org[i] = a[i];
  int m_first, m_zeros, MAX = 0;
  ++a[0], ++b[0];
  for (int z = 0; a[0] >= 0; ++z) {
    --a[0];
    --b[0];
    for (int i = 5; i < 10; ++i) {
      --a[i], --b[10 - i];
      int cur = 1;
      if (a[i] >= 0 && b[10 - i] >= 0) {
        cur += min(a[9], b[0]);
        cur += min(a[8], b[1]);
        cur += min(a[7], b[2]);
        cur += min(a[6], b[3]);
        cur += min(a[5], b[4]);
        cur += min(a[4], b[5]);
        cur += min(a[3], b[6]);
        cur += min(a[2], b[7]);
        cur += min(a[1], b[8]);
        cur += min(a[0], b[9]);
        if (cur + z > MAX) {
          MAX = cur + z;
          m_first = i;
          m_zeros = z;
        }
      }
      ++a[i], ++b[10 - i];
    }
  }
  if (MAX == 0 && org[0] > 0) {
    for (int i = 1; i < 10; ++i)
      for (int j = 0; j < a[i]; ++j) cout << char(i + '0');
    for (int j = 0; j < org[0]; ++j) cout << '0';
    cout << endl;
    for (int i = 1; i < 10; ++i)
      for (int j = 0; j < a[i]; ++j) cout << char(i + '0');
    for (int j = 0; j < org[0]; ++j) cout << '0';
    return 0;
  }
  if (MAX == 0) {
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < a[i]; ++j) cout << char(i + '0');
    cout << endl;
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < a[i]; ++j) cout << char(i + '0');
    return 0;
  }
  for (int i = 0; i < 10; ++i) a[i] = org[i];
  for (int i = 0; i < 10; ++i) b[i] = org[i];
  for (int i = 0; i < m_zeros; ++i) {
    res1[l - i - 1] = '0';
    res2[l - i - 1] = '0';
    --a[0], --b[0];
  }
  res1[l - m_zeros - 1] = m_first + '0';
  res2[l - m_zeros - 1] = 10 - m_first + '0';
  --a[m_first], --b[10 - m_first];
  int cur_pos = l - m_zeros - 1;
  for (int i = 0; i < 10; ++i)
    for (int j = 0; min(a[i], b[9 - i]) > 0; ++j)
      --cur_pos, res1[cur_pos] = i + '0', res2[cur_pos] = 9 - i + '0', --a[i],
                 --b[9 - i];
  int n1 = 0, n2 = 0;
  for (int i = 0; i < cur_pos; ++i) {
    while (a[n1] <= 0) ++n1;
    while (b[n2] <= 0) ++n2;
    res1[i] = n1 + '0';
    res2[i] = n2 + '0';
    --a[n1];
    --b[n2];
  }
  cout << res1 << endl << res2;
  return 0;
}
