#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
int main() {
  ios_base::sync_with_stdio(false);
  int best = -1;
  int t = -1;
  int c0 = 0;
  string s;
  cin >> s;
  int n = s.length();
  vector<int> mask(10, 0);
  for (int i = 0; i < n; ++i) ++mask[s[i] - '0'];
  for (int cnt0 = 0; cnt0 <= mask[0]; ++cnt0) {
    for (int x = 1; x < 10; ++x) {
      vector<int> mask1 = mask;
      vector<int> mask2 = mask;
      mask1[0] -= cnt0;
      mask2[0] -= cnt0;
      int y = (10 - x) % 10;
      if (mask1[x] > 0 && mask2[y] > 0) {
        int cur = 1;
        --mask1[x];
        --mask2[y];
        for (int i = 0; i < 10; ++i) {
          int j = 9 - i;
          int c = min(mask1[i], mask2[j]);
          cur += c;
          mask1[i] -= c;
          mask2[j] -= c;
        }
        if (cur + cnt0 > best) {
          best = cur + cnt0;
          t = x;
          c0 = cnt0;
        }
      }
    }
  }
  string s1(c0, '0');
  string s2(c0, '0');
  mask[0] -= c0;
  auto mask1 = mask;
  auto mask2 = mask;
  if (t >= 0) {
    int y = (10 - t) % 10;
    s1.push_back('0' + t);
    s2.push_back('0' + y);
    --mask1[t];
    --mask2[y];
  }
  for (int i = 0; i < 10; ++i) {
    int j = 9 - i;
    while (mask1[i] && mask2[j]) {
      --mask1[i];
      --mask2[j];
      s1.push_back('0' + i);
      s2.push_back('0' + j);
    }
  }
  for (int i = 0; i < 10; ++i)
    while (mask1[i]) {
      --mask1[i];
      s1.push_back('0' + i);
    }
  for (int i = 0; i < 10; ++i)
    while (mask2[i]) {
      --mask2[i];
      s2.push_back('0' + i);
    }
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  cout << s1 << endl;
  cout << s2 << endl;
}
