#include <bits/stdc++.h>
using namespace std;
char s[1 << 20];
char s1[1 << 20], s2[1 << 20];
int num[10];
int tnum1[10], tnum2[10];
int main() {
  int n;
  int ans = 0, tans, ansi;
  int i, j;
  int cnt;
  scanf("%s", s);
  n = strlen(s);
  memset(num, 0, sizeof 0);
  for (i = 0; i < n; i++) num[s[i] - '0']++;
  for (i = 1; i <= 5; i++) {
    for (j = 0; j < 10; j++) tnum1[j] = tnum2[j] = num[j];
    if (tnum1[i] == 0 || tnum2[10 - i] == 0) continue;
    tnum1[i]--;
    tnum2[10 - i]--;
    tans = 1;
    for (j = 0; j <= 9; j++) {
      int t = min(tnum1[j], tnum2[9 - j]);
      tans += t;
      tnum1[j] -= t;
      tnum2[9 - j] -= t;
    }
    tans += min(tnum1[0], tnum2[0]);
    if (tans > ans) {
      ans = tans;
      ansi = i;
    }
  }
  cnt = n - 1;
  if (ans == 0) {
    sort(s, s + n, greater<char>());
    printf("%s\n%s\n", s, s);
    return 0;
  }
  i = ansi;
  for (j = 0; j < 10; j++) tnum1[j] = tnum2[j] = num[j];
  tnum1[i]--;
  tnum2[10 - i]--;
  while (tnum1[0] > tnum2[9] && tnum2[0] > tnum1[9]) {
    s1[cnt] = '0';
    s2[cnt] = '0';
    cnt--;
    tnum1[0]--;
    tnum2[0]--;
  }
  s1[cnt] = i + '0';
  s2[cnt] = 10 - i + '0';
  cnt--;
  for (j = 0; j <= 9; j++) {
    while (tnum1[j] && tnum2[9 - j]) {
      s1[cnt] = j + '0';
      s2[cnt] = 9 - j + '0';
      cnt--;
      tnum1[j]--;
      tnum2[9 - j]--;
    }
  }
  i = cnt;
  for (j = 0; j < 10; j++)
    while (tnum1[j]) {
      s1[cnt--] = j + '0';
      tnum1[j]--;
    }
  cnt = i;
  for (j = 0; j < 10; j++)
    while (tnum2[j]) {
      s2[cnt--] = j + '0';
      tnum2[j]--;
    }
  s1[n] = s2[n] = '\0';
  printf("%s\n%s\n", s1, s2);
  return 0;
}
