#include <bits/stdc++.h>
int c[10];
char s[100010];
char a[2][100010];
int d[2][10];
void debug(int f[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    printf("%d ", f[i]);
  }
  printf("\n");
}
void solve() {
  int len, i, j, k, t, mins, count, ans, num, zeros;
  len = strlen(s);
  memset(c, 0, sizeof(c));
  for (i = 0; i < len; i++) {
    c[s[i] - '0']++;
  }
  ans = 0;
  zeros = num = -1;
  for (i = 1; i <= 5; i++) {
    memcpy(d[0], c, sizeof(c));
    memcpy(d[1], c, sizeof(c));
    if (d[0][i] > 0 && d[1][10 - i] > 0) {
      count = 1;
      d[0][i]--;
      d[1][10 - i]--;
      for (j = 0; j <= 9; j++) {
        mins = ((d[0][j]) < (d[1][9 - j]) ? (d[0][j]) : (d[1][9 - j]));
        d[0][j] -= mins;
        d[1][9 - j] -= mins;
        count += mins;
      }
      mins = ((d[0][0]) < (d[1][0]) ? (d[0][0]) : (d[1][0]));
      count += mins;
      if (count > ans) {
        zeros = mins;
        ans = count;
        num = i;
      }
    }
  }
  a[0][len] = a[1][len] = '\0';
  for (i = len - 1, j = 0; i >= 0 && j < zeros; i--, j++) {
    a[0][i] = a[1][i] = '0';
  }
  if (i >= 0) {
    memcpy(d[0], c, sizeof(c));
    memcpy(d[1], c, sizeof(c));
    if (num != -1) {
      d[0][0] -= zeros;
      d[1][0] -= zeros;
      a[0][i] = num + '0';
      a[1][i] = 10 - num + '0';
      d[0][num]--;
      d[1][10 - num]--;
      i--;
      for (j = 0; i >= 0 && j <= 9; j++) {
        mins = ((d[0][j]) < (d[1][9 - j]) ? (d[0][j]) : (d[1][9 - j]));
        d[0][j] -= mins;
        d[1][9 - j] -= mins;
        for (k = 0; i >= 0 && k < mins; k++) {
          a[0][i] = j + '0';
          a[1][i] = 9 - j + '0';
          i--;
        }
      }
    }
    k = t = i;
    for (j = 0; (k >= 0 || t >= 0) && j <= 9; j++) {
      while (k >= 0 && d[0][j] != 0) {
        a[0][k--] = j + '0';
        d[0][j]--;
      }
      while (t >= 0 && d[1][j] != 0) {
        a[1][t--] = j + '0';
        d[1][j]--;
      }
    }
  }
  printf("%s\n%s\n", a[0], a[1]);
}
int main() {
  while (scanf("%s", s) == 1) {
    solve();
  }
  return 0;
}
