#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int n;
int c[2][10];
int t[2][10];
int mx, mxz, mxs[2];
char str[MAX_N];
deque<int> d[2];
int main() {
  cin >> str;
  n = strlen(str);
  for (int i(0); i < (n); i++) {
    c[1][str[i] - '0'] = ++c[0][str[i] - '0'];
  }
  for (int z(0); z < (c[0][0] + 1); z++) {
    c[0][0] -= z, c[1][0] -= z;
    for (int ss(1); ss < (6); ss++) {
      int s = ss, con = z;
      if (c[0][s] and c[1][10 - s]) {
        con++;
        c[0][s]--, c[1][10 - s]--;
        for (int x(0); x < (5); x++) {
          con += min(c[0][x], c[1][9 - x]) + min(c[1][x], c[0][9 - x]);
        }
        c[0][s]++, c[1][10 - s]++;
        if (con >= mx) {
          mx = con;
          mxz = z;
          mxs[0] = s;
          mxs[1] = 10 - s;
        }
      } else {
        if (con >= mx) {
          mx = con;
          mxz = z;
          for (int i(0); i < (10); i++) {
            if (c[0][i]) {
              mxs[0] = i;
              break;
            }
          }
          for (int i(0); i < (10); i++) {
            if (c[1][i]) {
              mxs[1] = i;
              break;
            }
          }
        }
      }
    }
    c[0][0] += z, c[1][0] += z;
  }
  for (int i(0); i < (mxz); i++) {
    d[0].push_back(0);
    d[1].push_back(0);
  }
  c[0][0] -= mxz, c[1][0] -= mxz;
  d[0].push_front(mxs[0]);
  d[1].push_front(mxs[1]);
  c[0][mxs[0]]--, c[1][mxs[1]]--;
  for (int x(0); x < (5); x++) {
    int a = min(c[0][x], c[1][9 - x]);
    int b = min(c[1][x], c[0][9 - x]);
    for (int i(0); i < (a); i++) {
      d[0].push_front(x);
      d[1].push_front(9 - x);
    }
    for (int i(0); i < (b); i++) {
      d[0].push_front(9 - x);
      d[1].push_front(x);
    }
    c[0][x] -= a;
    c[1][9 - x] -= a;
    c[0][9 - x] -= b;
    c[1][x] -= b;
  }
  for (int i(0); i < (10); i++) {
    for (int k(0); k < (2); k++) {
      for (int j(0); j < (c[k][i]); j++) {
        d[k].push_front(i);
      }
    }
  }
  for (int k(0); k < (2); k++) {
    for (int i(0); i < (d[k].size()); i++) {
      cout << d[k][i];
    }
    cout << endl;
  }
}
