#include <bits/stdc++.h>
using namespace std;
char n1[100005];
char n2[100005];
int num[2][10];
int cnt(int x) {
  int n[2][10];
  int i, j, k;
  int re = 0;
  if (num[0][x] == 0 or num[0][10 - x] == 0) return -1;
  for (i = 0; i < 10; i++) {
    n[0][i] = num[0][i];
    n[1][i] = num[1][i];
  }
  n[0][x]--;
  n[1][10 - x]--;
  for (i = 0; i < 10; i++) {
    j = min(n[0][i], n[1][9 - i]);
    n[0][i] -= j;
    n[1][9 - i] -= j;
    re += j;
  }
  re += min(n[0][0], n[1][0]);
  return re;
}
int f(int x) {
  int nn[2][10];
  int i, j, k;
  int re;
  int n, m;
  strcpy(n1, "");
  n = 0;
  strcpy(n2, "");
  m = 0;
  for (i = 0; i < 10; i++) {
    nn[0][i] = num[0][i];
    nn[1][i] = num[1][i];
  }
  if (x != -1) {
    nn[0][x]--;
    nn[1][10 - x]--;
  }
  if (x != -1) {
    n1[n++] = x + 48;
    n2[m++] = (10 - x) + 48;
  }
  for (i = 0; i < 10; i++) {
    re = min(nn[0][i], nn[1][9 - i]);
    for (j = 0; j < re; j++) {
      n1[n++] = i + 48;
      n2[m++] = (9 - i) + 48;
    }
    nn[0][i] -= re;
    nn[1][9 - i] -= re;
  }
  re = min(nn[0][0], nn[1][0]);
  nn[0][0] -= re;
  nn[1][0] -= re;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < nn[0][i]; j++) printf("%d", i);
  }
  for (i = n - 1; i >= 0; i--) printf("%c", n1[i]);
  for (i = 0; i < re; i++) printf("0");
  printf("\n");
  for (i = 0; i < 10; i++) {
    for (j = 0; j < nn[1][i]; j++) printf("%d", i);
  }
  for (i = m - 1; i >= 0; i--) printf("%c", n2[i]);
  for (i = 0; i < re; i++) printf("0");
  printf("\n");
  return 0;
}
int main() {
  int i, j, k, l;
  int m, im;
  for (i = 0; i < 10; i++) num[0][i] = num[1][i] = 0;
  scanf("%s", n1);
  for (i = 0; n1[i] != '\0'; i++) {
    num[0][n1[i] - '0']++;
    num[1][n1[i] - '0']++;
  }
  for (i = 1, m = -1, im = -1; i < 10; i++) {
    j = cnt(i);
    if (j > m) {
      m = j;
      im = i;
    }
  }
  f(im);
  return 0;
}
