#include <bits/stdc++.h>
using namespace std;
char s[100005];
int cnt1[10], cnt2[10];
int arr[100005], alen;
int brr[100005], blen;
int main() {
  scanf("%s", s);
  int len = strlen(s);
  int i, j;
  for (i = 0; i < len; i++) cnt1[s[i] - '0']++;
  for (i = 0; i < 10; i++) cnt2[i] = cnt1[i];
  for (i = 0; i < 10; i++) {
    if (cnt1[i] <= cnt1[9 - i]) continue;
    for (j = 0; j < 10; j++) {
      if (cnt1[j] <= cnt1[9 - j]) continue;
      if (i + j == 10) {
        cnt1[i]--;
        arr[alen++] = i;
        cnt2[j]--;
        brr[blen++] = j;
        break;
      }
    }
    if (j < 10) break;
  }
  if (i == 10) {
    for (i = 0; i < 10; i++) {
      if (cnt1[i] && cnt2[10 - i]) {
        cnt1[i]--;
        arr[alen++] = i;
        cnt2[10 - i]--;
        brr[blen++] = 10 - i;
        break;
      }
    }
    if (i == 10) {
      for (i = 9; i >= 0; i--) {
        for (j = 0; j < cnt1[i]; j++) printf("%d", i);
      }
      puts("");
      for (i = 9; i >= 0; i--) {
        for (j = 0; j < cnt2[i]; j++) printf("%d", i);
      }
      puts("");
      return 0;
    }
  }
  for (i = 0; i < 10; i++) {
    int mi = min(cnt1[i], cnt2[9 - i]);
    for (j = 0; j < mi; j++) {
      cnt1[i]--;
      arr[alen++] = i;
      cnt2[9 - i]--;
      brr[blen++] = 9 - i;
    }
  }
  int now = min(cnt1[0], cnt2[0]);
  cnt1[0] -= now;
  cnt2[0] -= now;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < cnt1[i]; j++) {
      arr[alen++] = i;
    }
    for (j = 0; j < cnt2[i]; j++) {
      brr[blen++] = i;
    }
  }
  for (i = alen - 1; i >= 0; i--) {
    printf("%d", arr[i]);
  }
  for (i = 0; i < now; i++) printf("0");
  puts("");
  for (i = blen - 1; i >= 0; i--) {
    printf("%d", brr[i]);
  }
  for (i = 0; i < now; i++) printf("0");
  puts("");
  return 0;
}
