#include <bits/stdc++.h>
using namespace std;
int get_sums_count(int n, vector<int> c1, vector<int> c2, string& s1,
                   string& s2) {
  int i, j;
  int s = 0;
  for (i = 0, j = n; i <= n; ++i, --j)
    while (c1[i] > 0 && c2[j] > 0) {
      --c1[i];
      --c2[j];
      s1.push_back('0' + i);
      s2.push_back('0' + j);
      ++s;
    }
  return s;
}
int get_sums_count_ref(int n, vector<int>& c1, vector<int>& c2, string& s1,
                       string& s2) {
  int i, j;
  int s = 0;
  for (i = 0, j = n; i <= n; ++i, --j)
    while (c1[i] > 0 && c2[j] > 0) {
      --c1[i];
      --c2[j];
      s1.push_back('0' + i);
      s2.push_back('0' + j);
      ++s;
    }
  return s;
}
int main() {
  string s;
  cin >> s;
  vector<int> c1(10, 0);
  int i;
  for (i = 0; i < (int)s.length(); ++i) ++c1[s[i] - '0'];
  vector<int> c2 = c1;
  string s1, s2;
  int j;
  int maxx = -1, maxx_i, maxx_j;
  string t1, t2;
  for (i = 1, j = 9; i < 10; ++i, --j)
    if (c1[i] > 0 && c2[j] > 0) {
      --c1[i];
      --c2[j];
      int m1 = get_sums_count(9, c1, c2, t1, t2);
      if (m1 > maxx) {
        maxx = m1;
        maxx_i = i;
        maxx_j = j;
      }
      ++c1[i];
      ++c2[j];
    }
  if (maxx != -1) {
    --c1[maxx_i];
    --c2[maxx_j];
    s1.push_back('0' + maxx_i);
    s2.push_back('0' + maxx_j);
    get_sums_count_ref(9, c1, c2, s1, s2);
  }
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  for (; c1[0] > 0 && c2[0] > 0; --c1[0], --c2[0]) {
    s1.push_back('0');
    s2.push_back('0');
  }
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  for (i = 0; i < 10; ++i) {
    while (c1[i] > 0) {
      --c1[i];
      s1.push_back('0' + i);
    }
    while (c2[i] > 0) {
      --c2[i];
      s2.push_back('0' + i);
    }
  }
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  cout << s1 << endl << s2 << endl;
  return 0;
}
