#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
void minn(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void maxx(T &a, T b) {
  if (a < b) a = b;
}
int madd(int &a, int b) {
  a += b;
  if (a >= 1000000009) a -= 1000000009;
  return a;
}
int msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000009;
  return a;
}
int mmult(int &a, int b) { return a = (long long)a * b % 1000000009; }
int mdiv(long long a, long long b, long long m) {
  a = (a % 1000000009 + 1000000009) % 1000000009;
  b = (b % 1000000009 + 1000000009) % 1000000009;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m;
int A[10];
int B[10];
char S[101234];
vector<pair<int, int> > v;
int fnd() {
  int res = 0;
  int i;
  for (i = (0); i < (10); ++i) res += min(A[i], B[9 - i]);
  res += min(A[0] - min(A[0], B[9]), B[0] - min(B[0], A[9]));
  return res;
}
void fndDfs() {
  int i;
  for (i = (0); i < (10); ++i)
    for (; A[i] && B[9 - i]; --A[i], --B[9 - i])
      v.push_back(make_pair(i, 9 - i));
}
void print(int *C) {
  int m = min(A[0], B[0]);
  int i, j;
  for (i = (0); i < (C[0] - m); ++i)
    printf(
        "%"
        "d",
        (0));
  for (i = (1); i < (10); ++i)
    for (j = (0); j < (C[i]); ++j)
      printf(
          "%"
          "d",
          (i));
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  int ts;
  for (ts = 1; scanf("%"
                     "s",
                     &(S)) > 0;
       ++ts) {
    for (i = (0); i < (10); ++i) A[i] = 0;
    n = strlen(S);
    for (i = (0); i < (n); ++i) ++A[S[i] - '0'];
    for (i = (0); i < (10); ++i) B[i] = A[i];
    int res = -1, a, b;
    a = b = -1;
    for (i = (1); i < (6); ++i)
      if (A[i] && B[10 - i]) {
        --A[i];
        --B[10 - i];
        int r = fnd();
        if (r > res) {
          res = r;
          a = i;
          b = 10 - i;
        }
        ++A[i];
        ++B[10 - i];
      }
    v.clear();
    if (res >= 0) {
      --A[a];
      --B[b];
      fndDfs();
    }
    print(A);
    for (i = (0); i < (v.size()); ++i)
      printf(
          "%"
          "d",
          (v[i].first));
    if (res >= 0)
      printf(
          "%"
          "d",
          (a));
    for (i = (0); i < (min(A[0], B[0])); ++i)
      printf(
          "%"
          "d",
          (0));
    printf("\n"), firstout = 1;
    print(B);
    for (i = (0); i < (v.size()); ++i)
      printf(
          "%"
          "d",
          (v[i].second));
    if (res >= 0)
      printf(
          "%"
          "d",
          (b));
    for (i = (0); i < (min(A[0], B[0])); ++i)
      printf(
          "%"
          "d",
          (0));
    printf("\n"), firstout = 1;
  }
  return 0;
}
