#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int num1[20], num2[20], num[20];
char s[maxn], s2[maxn];
int Zero, use[20];
int check(int mm) {
  if (num[mm] < 1 || num[10 - mm] < 1) return -1;
  for (int i = 0; i < 10; ++i) num1[i] = num2[i] = num[i];
  --num1[mm];
  --num2[10 - mm];
  int tot = 1;
  for (int i = 0; i < 10; ++i) {
    int tmp = min(num1[i], num2[9 - i]);
    tot += tmp;
    num1[i] -= tmp;
    num2[9 - i] -= tmp;
    use[i] = tmp;
  }
  Zero = 0;
  while (num1[0] > 0 && num2[0] > 0) ++Zero, --num1[0], --num2[0];
  return tot + Zero;
}
int main() {
  for (int i = 0; i < 20; ++i) num[i] = 0;
  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
    ++num[s[i] - '0'];
  }
  int ans = 0, id = -1;
  for (int i = 1; i < 10; ++i) {
    int tmp = check(i);
    if (tmp > ans) {
      ans = tmp;
      id = i;
    }
  }
  if (id == -1) {
    int tot = 0;
    for (int i = 0; i < 10; ++i) {
      while (num[i] > 0) {
        s[tot++] = '0' + i;
        --num[i];
      }
    }
    for (int i = tot - 1; i > -1; --i) printf("%c", s[i]);
    printf("\n");
    for (int i = tot - 1; i > -1; --i) printf("%c", s[i]);
    printf("\n");
  } else {
    int tot = 0;
    check(id);
    for (int i = 0; i < 10; ++i) num1[i] = num2[i] = num[i];
    while (Zero--) {
      --num1[0];
      --num2[0];
      s2[tot] = '0';
      s[tot++] = '0';
    }
    --num1[id];
    --num2[10 - id];
    s2[tot] = '0' + id;
    s[tot++] = '0' + (10 - id);
    for (int i = 0; i < 10; ++i) {
      num1[i] -= use[i];
      num2[9 - i] -= use[i];
      while (use[i]--) {
        s2[tot] = '0' + i;
        s[tot++] = '0' + (9 - i);
      }
    }
    int tot2 = tot;
    for (int i = 0; i < 10; ++i) {
      while (num1[i] > 0) {
        s2[tot2++] = '0' + i;
        --num1[i];
      }
    }
    for (int i = 0; i < 10; ++i) {
      while (num2[i] > 0) {
        s[tot++] = '0' + i;
        --num2[i];
      }
    }
    for (int i = tot - 1; i > -1; --i) printf("%c", s2[i]);
    printf("\n");
    for (int i = tot - 1; i > -1; --i) printf("%c", s[i]);
    printf("\n");
  }
  return 0;
}
