#include <bits/stdc++.h>
using namespace std;
int a[11];
int du[11];
int dv[11];
string str = "";
void reset() {
  for (int i = 0; i < 10; i++) {
    du[i] = dv[i] = a[i];
  }
}
int main() {
  while (cin >> str) {
    for (int i = 0; i < 10; i++) {
      a[i] = 0;
    }
    for (int i = 0; i < str.size(); i++) {
      a[str[i] - '0']++;
    }
    int best = 0;
    string su = str;
    string sv = str;
    for (int u = 9; u >= 1; u--) {
      int v = 10 - u;
      reset();
      int temp = 0;
      string tu = "";
      string tv = "";
      string tt = "";
      string uu = "";
      string vv = "";
      bool flag = (du[u] > 0 && dv[v] > 0);
      bool flag2 = false;
      if (flag) {
        temp += 1;
        tu += '0' + u;
        tv += '0' + v;
        du[u]--;
        dv[v]--;
        uu = "";
        vv = "";
        for (int k = 0; k <= 9; k++) {
          int j = 9 - k;
          while (du[k] > 0 && dv[j] > 0) {
            uu += '0' + k;
            vv += '0' + j;
            du[k]--;
            dv[j]--;
            temp += 2;
            flag2 = true;
          }
        }
        tu = uu + tu;
        tv = vv + tv;
      }
      tt = "";
      while (du[0] > 0 && dv[0] > 0) {
        tt += "0";
        du[0]--;
        dv[0]--;
        temp++;
      }
      {
        tu = tu + tt;
        tv = tv + tt;
      }
      tt = "";
      for (int k = 0; k < 10; k++) {
        while (du[k] > 0) {
          tt += '0' + k;
          du[k]--;
        }
      }
      tu = tt + tu;
      tt = "";
      for (int k = 0; k < 10; k++) {
        while (dv[k] > 0) {
          tt += '0' + k;
          dv[k]--;
        }
      }
      tv = tt + tv;
      if (temp > best) {
        best = temp;
        su = tu;
        sv = tv;
      }
    }
    cout << su << endl;
    cout << sv << endl;
  }
  return 0;
}
