#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100010;
int len;
char str[MAX_N];
char num1[MAX_N], num2[MAX_N];
int cnt[10], cnt2[10];
pair<int, int> FindBestDigit() {
  int best_digit = str[0] - '0', max_zeros = 0, ending_zeros = -1;
  int total_zeros = cnt[0];
  while (cnt[0] >= 0) {
    if (total_zeros - cnt[0] > max_zeros) {
      best_digit = str[0] - '0';
      max_zeros = total_zeros - cnt[0];
      ending_zeros = max_zeros - cnt[0];
    }
    for (int i = 1; i < 10; ++i) {
      int rest = 10 - i;
      if (cnt[i] > 0 && cnt2[rest] > 0) {
        --cnt[i];
        --cnt2[rest];
        int zeros = total_zeros - cnt[0] + 1;
        for (int j = 0; j < 10; ++j) {
          zeros += min(cnt[j], cnt2[9 - j]);
        }
        if (zeros > max_zeros) {
          best_digit = i;
          max_zeros = zeros;
          ending_zeros = total_zeros - cnt[0];
        }
        ++cnt2[rest];
        ++cnt[i];
      }
    }
    --cnt[0];
  }
  cnt[0] = total_zeros;
  return make_pair(best_digit, ending_zeros);
}
void BuildSolution(pair<int, int> best) {
  int best_digit = best.first;
  int zeros = best.second;
  int pos1 = 0, pos2 = 0;
  for (int i = 1; i <= zeros; ++i) {
    ++pos1;
    ++pos2;
    --cnt[0];
    --cnt2[0];
    num1[len - pos1] = '0';
    num2[len - pos2] = '0';
  }
  --cnt[best_digit];
  int rest = 10 - best_digit;
  if (cnt2[rest] == 0) {
    for (int i = 0; i < 10; ++i) {
      if (cnt2[i] > 0) {
        rest = i;
      }
    }
  }
  ++pos1;
  ++pos2;
  --cnt2[rest];
  num1[len - pos1] = '0' + best_digit;
  num2[len - pos2] = '0' + rest;
  for (int i = 0; i < 10; ++i) {
    while (cnt[i] > 0 && cnt2[9 - i] > 0) {
      ++pos1;
      ++pos2;
      --cnt[i];
      --cnt2[9 - i];
      num1[len - pos1] = '0' + i;
      num2[len - pos2] = '0' + 9 - i;
    }
  }
  for (int i = 0; i < 10; ++i) {
    while (cnt[i] > 0) {
      --cnt[i];
      ++pos1;
      num1[len - pos1] = '0' + i;
    }
    while (cnt2[i] > 0) {
      --cnt2[i];
      ++pos2;
      num2[len - pos2] = '0' + i;
    }
  }
}
int main() {
  fgets(str, MAX_N, stdin);
  len = strlen(str) - 1;
  for (int i = 0; i < len; ++i) {
    ++cnt[str[i] - '0'];
    ++cnt2[str[i] - '0'];
  }
  pair<int, int> best = FindBestDigit();
  BuildSolution(best);
  printf("%s\n", num1);
  printf("%s\n", num2);
  return 0;
}
