#include <bits/stdc++.h>
using namespace std;
const long long LINF = ~(((long long)0x1) << 63) / 2;
const int INF = 0X3F3F3F3F;
const double eps = 1e-7;
string ans1, ans2, re1, re2;
int a[10], b[10];
int na[10], nb[10];
int main() {
  string n;
  cin >> n;
  int i, j, k;
  for (i = 0; i < n.size(); i++) a[n[i] - '0']++, b[n[i] - '0']++;
  int c, d;
  ans1 = "";
  ans2 = "";
  int res = 0, v;
  for (c = 1; c <= 9; c++) {
    int now = 0;
    for (j = 0; j < 10; j++) na[j] = nb[j] = a[j];
    if (a[c] && a[10 - c]) {
      ans1 = ans2 = "";
      na[c]--;
      nb[10 - c]--;
      ans1.push_back(c + '0');
      ans2.push_back(10 - c + '0');
      now++;
      for (j = 9; j >= 0; j--) {
        v = min(na[j], nb[9 - j]);
        na[j] -= v;
        nb[9 - j] -= v;
        now += v;
        for (k = 0; k < v; k++) {
          ans1.push_back(j + '0');
          ans2.push_back(9 - j + '0');
        }
      }
    }
    v = min(na[0], nb[0]);
    reverse(ans1.begin(), ans1.end());
    reverse(ans2.begin(), ans2.end());
    for (j = 0; j < v; j++) ans1.push_back('0');
    for (j = 0; j < v; j++) ans2.push_back('0');
    now += v;
    na[0] -= v;
    nb[0] -= v;
    reverse(ans1.begin(), ans1.end());
    reverse(ans2.begin(), ans2.end());
    for (j = 0; j <= 9; j++)
      for (k = 0; k < na[j]; k++) ans1.push_back(j + '0');
    for (j = 0; j <= 9; j++)
      for (k = 0; k < nb[j]; k++) ans2.push_back(j + '0');
    reverse(ans1.begin(), ans1.end());
    reverse(ans2.begin(), ans2.end());
    if (now > res) {
      res = now, re1 = ans1, re2 = ans2;
    }
  }
  if (re1 == "") re1 = re2 = n;
  cout << re1 << endl;
  cout << re2 << endl;
  return 0;
}
