#include <bits/stdc++.h>
const int maxN = 101234;
char s[maxN];
int tot_a[20], tot_b[20];
int solve() {
  int tot = 1;
  int v[30];
  memset(v, 0, sizeof v);
  for (int i = 0; i < 10; i++) {
    v[i] = tot_a[i];
    if (v[i] > tot_b[9 - i]) v[i] = tot_b[9 - i];
    tot += v[i];
  }
  int extra = tot_a[0] - v[0];
  if (extra > tot_b[0] - v[9]) extra = tot_b[0] - v[9];
  return tot + extra;
}
int main() {
  scanf("%s", s);
  int l = strlen(s);
  memset(tot_a, 0, sizeof tot_a);
  memset(tot_b, 0, sizeof tot_b);
  for (int i = 0; i < l; i++) {
    tot_a[s[i] - '0']++;
    tot_b[s[i] - '0']++;
  }
  int ans = 0, val = -1;
  for (int i = 1; i <= 5; i++) {
    if (!tot_a[i] || !tot_b[10 - i]) continue;
    tot_a[i]--;
    tot_b[10 - i]--;
    int t = solve();
    if (t > val) {
      val = t;
      ans = i;
    }
    tot_a[i]++;
    tot_b[10 - i]++;
  }
  if (!ans) {
    for (int i = 1; i <= 9; i++)
      if (tot_a[i]) ans = i;
  }
  if (val >= 0) {
    tot_a[ans]--;
    tot_b[10 - ans]--;
  }
  int v[100];
  memset(v, 0, sizeof v);
  for (int i = 0; i <= 9; i++) {
    v[i] = tot_a[i];
    if (v[i] > tot_b[9 - i]) v[i] = tot_b[9 - i];
  }
  int extra = tot_a[0] - v[0];
  if (tot_b[0] - v[9] < extra) extra = tot_b[0] - v[9];
  tot_a[0] -= extra;
  tot_b[0] -= extra;
  int p = 0;
  for (int i = 0; i < extra; i++) s[p++] = '0';
  if (val >= 0) s[p++] = ans + '0';
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < v[i]; j++) {
      s[p++] = i + '0';
      tot_a[i]--;
    }
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < tot_a[i]; j++) s[p++] = i + '0';
  for (int i = p - 1; i >= 0; i--) printf("%c", s[i]);
  printf("\n");
  p = 0;
  for (int i = 0; i < extra; i++) s[p++] = '0';
  if (val >= 0) s[p++] = 10 - ans + '0';
  for (int i = 9; i >= 0; i--)
    for (int j = 0; j < v[9 - i]; j++) {
      s[p++] = i + '0';
      tot_b[i]--;
    }
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j < tot_b[i]; j++) s[p++] = i + '0';
  for (int i = p - 1; i >= 0; i--) printf("%c", s[i]);
  printf("\n");
  return 0;
}
