#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
char A[100100];
int len;
int O[13], T1[13], T2[13];
char S1[100100], S2[100100];
int main() {
  int cur, resd, add, res = -1000000000, resz;
  cin.getline(A, 100100, '\n');
  len = strlen(A);
  for (int i = 0; i < len; i++) O[(int)A[i] - 48]++;
  for (int sz = 0; sz <= O[0]; sz++) {
    for (int d = 0; d <= 9; d++) {
      for (int i = 0; i <= 9; i++) T1[i] = T2[i] = O[i];
      T1[0] = T2[0] = O[0] - sz;
      cur = sz;
      if (T1[d] && T2[10 - d]) {
        cur++;
        T1[d]--;
        T2[10 - d]--;
        for (int i = 0; i <= 9; i++) {
          add = min(T1[i], T2[9 - i]);
          cur += add;
          T1[i] -= add;
          T2[9 - i] -= add;
        }
      }
      if (cur > res) {
        res = cur;
        resd = d;
        resz = sz;
      }
    }
  }
  for (int i = 0; i <= 9; i++) T1[i] = T2[i] = O[i];
  T1[0] = T2[0] = O[0] - resz;
  int sidx = len - 1;
  S1[len] = S2[len] = '\0';
  for (int i = 1; i <= resz; i++) {
    S1[sidx] = S2[sidx] = '0';
    sidx--;
  }
  if (T1[resd] && T2[10 - resd]) {
    T1[resd]--;
    T2[10 - resd]--;
    S1[sidx] = (char)(resd + 48);
    S2[sidx--] = (char)(10 - resd + 48);
    for (int i = 0; i <= 9; i++) {
      add = min(T1[i], T2[9 - i]);
      T1[i] -= add;
      T2[9 - i] -= add;
      for (int j = 1; j <= add; j++) {
        S1[sidx] = (char)(i + 48);
        S2[sidx--] = (char)(9 - i + 48);
      }
    }
  }
  int i1, i2;
  i1 = i2 = sidx;
  for (int i = 0; i <= 9; i++) {
    if (T1[i]) {
      for (int j = 1; j <= T1[i]; j++) S1[i1--] = (char)(i + 48);
    }
    if (T2[i]) {
      for (int j = 1; j <= T2[i]; j++) S2[i2--] = (char)(i + 48);
    }
  }
  cout << S1 << endl << S2 << endl;
  return 0;
}
