#include <bits/stdc++.h>
using namespace std;
char s[100010], a1[200010], a2[200010];
int n, sum[10];
void solve() {
  int ml = 0, mi = 0, len;
  int i, j, n1, n2, n3, n4;
  int s1[10], s2[10];
  for (i = 1; i < 10; i++) {
    for (j = 0; j < 10; j++) s1[j] = s2[j] = sum[j];
    len = 0;
    s1[i]--;
    if (s1[i] < 0) continue;
    s2[10 - i]--;
    if (s2[10 - i] < 0) continue;
    len++;
    for (j = 0; j < 10; j++) len += min(s1[j], s2[9 - j]);
    if (s1[0] > s1[9] && s2[0] > s2[9])
      len += min(s1[0] - s1[9], s2[0] - s2[9]);
    if (len >= ml) {
      ml = len;
      mi = i;
    }
  }
  n1 = n2 = n;
  for (j = 0; j < 10; j++) s1[j] = s2[j] = sum[j];
  if (mi > 0) {
    s1[mi]--;
    s2[10 - mi]--;
    n1--;
    a1[n1] = (char)(mi + '0');
    n2--;
    a2[n2] = (char)(10 - mi + '0');
    for (i = 0; i < 10; i++) {
      for (j = 0; j < min(s1[i], s2[9 - i]); j++) {
        n1--;
        a1[n1] = (char)(i + '0');
        n2--;
        a2[n2] = (char)(9 - i + '0');
      }
      if (s1[i] > s2[9 - i]) {
        s1[i] -= s2[9 - i];
        s2[9 - i] = 0;
      } else {
        s2[9 - i] -= s1[i];
        s1[i] = 0;
      }
    }
  }
  n3 = n4 = n;
  for (i = 0; i < min(s1[0], s2[0]); i++) {
    a1[n3] = '0';
    n3++;
    a2[n4] = '0';
    n4++;
  }
  if (s1[0] > s2[0]) {
    s1[0] -= s2[0];
    s2[0] = 0;
  } else {
    s2[0] -= s1[0];
    s1[0] = 0;
  }
  for (i = 0; i < 10; i++)
    for (j = 0; j < s1[i]; j++) {
      n1--;
      a1[n1] = char(i + '0');
    }
  for (i = 0; i < 10; i++)
    for (j = 0; j < s2[i]; j++) {
      n2--;
      a2[n2] = char(i + '0');
    }
  for (i = n1; i < n3; i++) printf("%c", a1[i]);
  printf("\n");
  for (i = n2; i < n4; i++) printf("%c", a2[i]);
  printf("\n");
}
int main() {
  int i;
  scanf("%s", s);
  n = strlen(s);
  for (i = 0; i < n; i++) sum[s[i] - '0']++;
  solve();
  return 0;
}
