#include <bits/stdc++.h>
using namespace std;
int n, c1[15], c2[15];
char s[200008], s1[200008], s2[200008];
int ans, jl = -1, i1;
int main() {
  scanf("%s", &s[1]);
  n = strlen(&s[1]);
  for (int i = 1; i <= n; i++) c1[s[i] - '0']++, c2[s[i] - '0']++;
  for (int i = 0; i <= c1[0]; i++) {
    c1[0] -= i;
    c2[0] -= i;
    if (i > ans) {
      ans = i;
      i1 = i;
      jl = -1;
    }
    for (int j = 1; j <= 5; j++)
      if (c1[j] && c2[10 - j]) {
        c1[j]--;
        c2[10 - j]--;
        int sum = 1 + i;
        for (int k = 0; k <= 9; k++)
          sum += (c1[k] < c2[9 - k] ? c1[k] : c2[9 - k]);
        if (sum > ans) {
          ans = sum;
          i1 = i, jl = j;
        }
        c1[j]++;
        c2[10 - j]++;
      }
    c1[0] += i;
    c2[0] += i;
  }
  if (!ans)
    puts(&s[1]), puts(&s[1]);
  else {
    for (int i = n; i >= n - i1 + 1; i--) s1[i] = '0', s2[i] = '0';
    c1[0] -= i1;
    c2[0] -= i1;
    n -= i1;
    if (jl != -1) {
      s1[n] = jl + '0';
      s2[n] = 10 - jl + '0';
      c1[jl]--;
      c2[10 - jl]--;
    } else
      n++;
    for (int k = 0; k <= 9; k++) {
      int t = (c1[k] < c2[9 - k] ? c1[k] : c2[9 - k]);
      for (int i = 1; i <= t; i++) {
        n--;
        s1[n] = k + '0';
        s2[n] = 9 - k + '0';
      }
      c1[k] -= t;
      c2[9 - k] -= t;
    }
    int n1 = n, n2 = n;
    for (int k = 0; k <= 9; k++) {
      for (int i = 1; i <= c1[k]; i++) {
        n1--;
        s1[n1] = k + '0';
      }
      for (int i = 1; i <= c2[k]; i++) {
        n2--;
        s2[n2] = k + '0';
      }
    }
    puts(&s1[1]);
    puts(&s2[1]);
  }
  return 0;
}
