#include <bits/stdc++.h>
using namespace std;
char buf[100001];
int a[10] = {0}, b[10] = {0};
int res = -1;
string num1, num2;
void update(int end) {
  int aa[10], bb[10];
  for (int i = 0; i < 10; i++) {
    aa[i] = a[i];
    bb[i] = b[i];
  }
  string n1("");
  string n2("");
  int cres = 0;
  if (!bb[10 - end]) {
    cres = a[0];
    if (cres >= res) {
      for (int i = 9; i >= 0; i--) n1 += string(aa[i], '0' + i);
      num1 = n1;
      num2 = n1;
    }
  } else {
    aa[end]--;
    bb[10 - end]--;
    n1 = '0' + end;
    n2 = '0' + (10 - end);
    cres++;
    for (int i = 0; i < 10; i++) {
      int t = min(aa[i], bb[9 - i]);
      n1 = string(t, '0' + i) + n1;
      n2 = string(t, '0' + (9 - i)) + n2;
      cres += t;
      aa[i] -= t;
      bb[9 - i] -= t;
    }
    int t = min(aa[0], bb[0]);
    cres += t;
    n1 += string(t, '0');
    n2 += string(t, '0');
    aa[0] -= t;
    bb[0] -= t;
    if (cres > res) {
      for (int i = 9; i >= 0; i--) {
        n1 = string(aa[i], '0' + i) + n1;
        n2 = string(bb[i], '0' + i) + n2;
      }
      num1 = n1;
      num2 = n2;
      res = cres;
    }
  }
}
int main() {
  scanf("%s", buf);
  for (int i = 0; buf[i]; i++) {
    a[buf[i] - '0']++;
    b[buf[i] - '0']++;
  }
  for (int i = 1; i <= 9; i++)
    if (a[i]) update(i);
  printf("%s\n%s\n", num1.c_str(), num2.c_str());
  return 0;
}
