#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
const int N = 2e5 + 5;
const long long int mod = 1e9 + 7;
const long long int Mod = 998244353;
const long double Pi = acos(-1);
const long long int Inf = 4e18;
int dx[9] = {0, 1, -1, 0, 0, 1, 1, -1, -1};
int dy[9] = {0, 0, 0, 1, -1, 1, -1, 1, -1};
using namespace std;
void TestCase() {
  string s;
  deque<char> a, b;
  cin >> s;
  vector<int> da(10, 0), db(10, 0);
  for (int i = 0; i < (int)s.size(); i++) da[s[i] - '0']++;
  db = da;
  int len = 0, id = 0;
  for (int x = 1; x <= 8; x++) {
    int cur = 0;
    vector<int> aa, bb;
    aa = da, bb = db;
    if (aa[x] * bb[10 - x] > 0) {
      aa[x]--;
      bb[10 - x]--;
      cur++;
      for (int y = 0, z; y <= 9; y++) {
        z = min(aa[y], bb[9 - y]);
        aa[y] -= z;
        bb[9 - y] -= z;
        cur += z;
      }
      if (cur > len) {
        id = x;
        len = cur;
      }
    }
  }
  if (id) {
    a.push_back(id + '0');
    b.push_back(10 - id + '0');
    da[id]--;
    db[10 - id]--;
    for (int y = 0, z; y <= 9; y++) {
      z = min(da[y], db[9 - y]);
      da[y] -= z;
      db[9 - y] -= z;
      for (int i = 0; i < z; i++) {
        a.push_back(y + '0');
        b.push_back(9 - y + '0');
      }
    }
    for (int i = 0; i < min(da[0], db[0]); i++) {
      a.push_front('0');
      b.push_front('0');
    }
    int z = min(da[0], db[0]);
    da[0] -= z;
    db[0] -= z;
  }
  for (int i = 0; i < 10; i++) {
    while (da[i]) {
      a.push_back(i + '0');
      da[i]--;
    }
    while (db[i]) {
      b.push_back(i + '0');
      db[i]--;
    }
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < (int)s.size(); i++) cout << a[i];
  cout << "\n";
  for (int i = 0; i < (int)s.size(); i++) cout << b[i];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int T = 1;
  while (T--) {
    TestCase();
    cout << "\n";
  }
  return 0;
}
