#include <bits/stdc++.h>
using namespace std;
char buf[100005];
int cnt[10];
int cnt2[10];
int main() {
  scanf("%s", buf);
  int N = strlen(buf);
  for (int i = 0; i < (N); ++i) cnt[buf[i] - '0']++;
  for (int i = 0; i < (10); ++i) cnt2[i] = cnt[i];
  int best = 0, bestres = cnt[0];
  for (int d = 1; d <= 9; ++d) {
    if (!cnt[d] || !cnt2[10 - d]) continue;
    cnt[d]--;
    cnt2[10 - d]--;
    int temp = 1;
    for (int i = 0; i < (10); ++i) temp += min(cnt[i], cnt2[9 - i]);
    temp += max(0, min(cnt[0] - cnt2[9], cnt2[0] - cnt[9]));
    cnt[d]++;
    cnt2[10 - d]++;
    if (temp > bestres) {
      bestres = temp;
      best = d;
    }
  }
  if (best == 0) {
    for (int i = 0; i < (2); ++i) {
      for (int j = 9; j >= 0; j--)
        for (int k = 0; k < (cnt[j]); ++k) printf("%d", j);
      printf("\n");
    }
  } else {
    cnt[best]--;
    cnt2[10 - best]--;
    int ilezer = max(0, min(cnt[0] - cnt2[9], cnt2[0] - cnt[9]));
    for (int j = 0; j < (10); ++j) {
      int ile = cnt[j] - min(cnt[j], cnt2[9 - j]);
      if (j == 0) ile -= ilezer;
      for (int k = 0; k < (ile); ++k) printf("%d", j);
    }
    for (int j = 0; j < (10); ++j) {
      for (int k = 0; k < (min(cnt[j], cnt2[9 - j])); ++k) printf("%d", j);
    }
    printf("%d", best);
    for (int k = 0; k < (ilezer); ++k) printf("0");
    printf("\n");
    for (int j = 0; j < (10); ++j) {
      int ile = cnt2[j] - min(cnt2[j], cnt[9 - j]);
      if (j == 0) ile -= ilezer;
      for (int k = 0; k < (ile); ++k) printf("%d", j);
    }
    for (int j = 9; j >= 0; j--) {
      for (int k = 0; k < (min(cnt2[j], cnt[9 - j])); ++k) printf("%d", j);
    }
    printf("%d", 10 - best);
    for (int k = 0; k < (ilezer); ++k) printf("0");
    printf("\n");
  }
}
