#include <bits/stdc++.h>
using namespace std;
long long int typedef ll;
int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
int main() {
  string s1;
  string s2;
  string s3;
  int mas1[10][11] = {};
  int mas2[10][11] = {};
  int i = 0;
  int j = 0;
  cin >> s1;
  for (int y = 1; y <= 9; y++) {
    for (i = 0; i < s1.length(); i++) {
      mas1[y][s1[i] - '0']++;
      mas2[y][s1[i] - '0']++;
    }
    mas1[y][10] = 0;
    mas2[y][10] = 0;
  }
  int d = 0;
  int maxi = 0;
  int count = 0;
  int ym = 1;
  string ans1, ans2;
  for (int y = 9; y > 0; y--) {
    for (i = y; i >= 0; i--) {
      if (mas1[y][i] > 0) {
        if (mas2[y][10 - i - d] > 0) {
          char a = i + '0';
          char b = 10 - i - d + '0';
          mas1[y][i]--;
          mas2[y][10 - i - d]--;
          ans1 += a;
          ans2 += b;
          d = 1;
          i = 10;
          count++;
        }
      }
    }
    d = 0;
    if (count > maxi) {
      maxi = count;
      s2.clear();
      s2 += ans1;
      s3.clear();
      s3 += ans2;
      ym = y;
    }
    count = 0;
    ans1.clear();
    ans2.clear();
  }
  i = 0;
  int x = min(mas1[ym][0], mas2[ym][0]);
  mas1[ym][0] -= x;
  mas2[ym][0] -= x;
  for (i = 0; i < 10; i++) {
    char a = i + '0';
    while (mas1[ym][i] > 0) {
      s2 += a;
      mas1[ym][i]--;
    }
    while (mas2[ym][i] > 0) {
      s3 += a;
      mas2[ym][i]--;
    }
  }
  reverse(s2.begin(), s2.end());
  reverse(s3.begin(), s3.end());
  while (x > 0) {
    s2 += '0';
    s3 += '0';
    x--;
  }
  cout << s2 << endl;
  cout << s3;
}
