#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100005, MaxD = 10, NA = -1, MaxC = 0x3F3F3F3F;
int a[MaxD], b[MaxD], c[MaxD];
char s[MaxN];
char u[MaxN << 1], v[MaxN << 1];
int p, q, res, su, sv, tu, tv;
int n;
int solve(int p) {
  int cur, i, res;
  memmove(b, a, sizeof(b));
  memmove(c, a, sizeof(c));
  b[p]--;
  c[MaxD - p]--;
  res = 1;
  for (i = 0; i < MaxD; i++) {
    cur = min(b[i], c[MaxD - i - 1]);
    res += cur;
    b[i] -= cur;
    c[MaxD - i - 1] -= cur;
  }
  res += min(b[0], c[0]);
  return res;
}
void go(int p) {
  int cur, i, j;
  memmove(b, a, sizeof(b));
  memmove(c, a, sizeof(c));
  su = tu = MaxN;
  sv = tv = MaxN;
  u[--su] = p + '0';
  b[p]--;
  v[--sv] = MaxD - p + '0';
  c[MaxD - p]--;
  for (i = 0; i < MaxD; i++) {
    cur = min(b[i], c[MaxD - i - 1]);
    for (j = 0; j < cur; j++) {
      u[--su] = i + '0';
      v[--sv] = MaxD - i - 1 + '0';
    }
    b[i] -= cur;
    c[MaxD - i - 1] -= cur;
  }
  cur = min(b[0], c[0]);
  for (j = 0; j < cur; j++) {
    u[tu++] = '0';
    v[tv++] = '0';
  }
  b[0] -= cur;
  c[0] -= cur;
  for (i = 0; i < MaxD; i++) {
    for (j = 0; j < b[i]; j++) u[--su] = i + '0';
    for (j = 0; j < c[i]; j++) v[--sv] = i + '0';
  }
  u[tu] = '\0';
  v[tv] = '\0';
}
int main(void) {
  int cur, i, j;
  while (scanf(" %s", s) != EOF) {
    n = strlen(s);
    memset(a, 0, sizeof(a));
    for (i = 0; i < n; i++) a[s[i] - '0']++;
    res = a[0];
    p = 0;
    for (i = 1; i < MaxD; i++)
      if (a[i] > 0 && a[MaxD - i] > 0) {
        cur = solve(i);
        if (res < cur) {
          res = cur;
          p = i;
        }
      }
    if (p == 0) {
      for (i = MaxD - 1; i >= 0; i--)
        for (j = 0; j < a[i]; j++) printf("%d", i);
      printf("\n");
      for (i = MaxD - 1; i >= 0; i--)
        for (j = 0; j < a[i]; j++) printf("%d", i);
      printf("\n");
    } else {
      go(p);
      printf("%s\n", u + su);
      printf("%s\n", v + sv);
    }
  }
  return 0;
}
