#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 100005;
char str[N];
int a[10], c[10], d[10];
string s1, s2;
void gao(int A, int B) {
  if (A == -1) return;
  for (int j = 0; j < 10; j++) c[j] = d[j] = a[j];
  c[0] -= A;
  d[0] -= A;
  s1 = s2 = "";
  for (int j = 0; j < A; j++) s1 += '0', s2 += '0';
  s1 += ((char)('0' + B));
  s2 += ((char)('0' + (10 - B) % 10));
  c[B]--;
  d[(10 - B) % 10]--;
  for (int j = 0; j < 10; j++) {
    if (c[j] && d[9 - j]) {
      int t = min(c[j], d[9 - j]);
      c[j] -= t;
      d[9 - j] -= t;
      for (int k = 0; k < t; k++) {
        s1 += ((char)(j + '0'));
        s2 += ((char)(9 - j + '0'));
      }
    }
  }
  for (int j = 0; j < 10; j++) {
    for (int k = 0; k < c[j]; k++) s1 += ((char)(j + '0'));
  }
  for (int j = 0; j < 10; j++) {
    for (int k = 0; k < d[j]; k++) s2 += ((char)(j + '0'));
  }
}
int main() {
  scanf("%s", str);
  int n = strlen(str);
  for (int i = 0; i < n; i++) a[str[i] - '0']++;
  int ans = a[0], A = -1, B = -1;
  sort(str, str + n);
  s1 = string(str);
  s2 = string(str);
  for (int r = 0; r <= a[0]; r++) {
    for (int i = 1; i < 10; i++) {
      for (int j = 0; j < 10; j++) c[j] = d[j] = a[j];
      c[0] -= r;
      d[0] -= r;
      if (c[i] && d[(10 - i) % 10]) {
        c[i]--;
        d[(10 - i) % 10]--;
        int cnt = 1;
        for (int j = 0; j < 10; j++) {
          if (c[j] && d[9 - j]) {
            int t = min(c[j], d[9 - j]);
            ;
            cnt += t;
            c[j] -= t;
            d[9 - j] -= t;
          }
        }
        for (int j = 0; j < 10; j++) c[j] = d[j] = a[j];
        c[0] -= r;
        d[0] -= r;
        cnt += r;
        if (cnt > ans) {
          A = r;
          B = i;
          ans = cnt;
        }
      }
    }
  }
  gao(A, B);
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  cout << s1 << endl << s2 << endl;
  return 0;
}
