#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1.0);
void fast_stream() { std::ios_base::sync_with_stdio(0); }
int a[10];
int b[10];
void solve() {
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.size(); i++) {
    a[s[i] - '0']++;
    b[s[i] - '0']++;
  }
  int res = 0;
  int idx1, idx2;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (a[i] == 0 || b[j] == 0 || i + j < 10) continue;
      a[i]--;
      b[j]--;
      int num = 0;
      int ad = (i + j == 10);
      for (int k = 0; k < 10; k++) num += min(a[k], b[9 - k]);
      int t = a[0] - min(a[0], b[9]);
      int t2 = b[0] - min(b[0], a[9]);
      if (res < num + ad + min(t, t2)) {
        res = num + ad + min(t, t2);
        idx1 = i;
        idx2 = j;
      }
      a[i]++;
      b[j]++;
    }
  }
  if (res == 0) {
    sort(s.begin(), s.end(), greater<char>());
    cout << s << endl;
    cout << s << endl;
    return;
  }
  a[idx1]--;
  b[idx2]--;
  string s1, s2;
  s1 += (idx1 + '0');
  s2 += (idx2 + '0');
  for (int k = 0; k < 10; k++) {
    int tmp = min(a[k], b[9 - k]);
    if (tmp != 0) {
      for (int i = 0; i < tmp; i++) {
        s1 += (k + '0');
        s2 += (9 - k + '0');
      }
    }
    a[k] -= tmp;
    b[9 - k] -= tmp;
  }
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  int tmp = min(a[0], b[0]);
  a[0] -= tmp;
  b[0] -= tmp;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < a[i]; j++) cout << i;
  cout << s1;
  for (int i = 0; i < tmp; i++) cout << 0;
  cout << endl;
  for (int i = 1; i < 10; i++)
    for (int j = 0; j < b[i]; j++) cout << i;
  cout << s2;
  for (int i = 0; i < tmp; i++) cout << 0;
  cout << endl;
}
int main() {
  solve();
  return 0;
}
