#include <bits/stdc++.h>
using namespace std;
int n[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int p[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
struct res {
  string s1, s2;
  int ans;
  res() {
    s1 = s2 = "";
    ans = 0;
  }
};
res maxi(vector<int> f1, vector<int> f2) {
  res ans;
  while (1) {
    bool ch = false;
    for (int i = int(0); i <= int(9); i++) {
      if (f1[n[i]] > 0 && f2[p[i]] > 0) {
        ans.s1 += char('0' + n[i]);
        ans.s2 += char('0' + p[i]);
        ans.ans++;
        f1[n[i]]--;
        f2[p[i]]--;
        ch = true;
      }
    }
    if (!ch) {
      for (int i = int(0); i <= int(9); i++) {
        while (f1[i] > 0) {
          ans.s1 += char('0' + i);
          f1[i]--;
        }
        while (f2[i] > 0) {
          ans.s2 += char('0' + i);
          f2[i]--;
        }
      }
      break;
    }
  }
  return ans;
}
int main() {
  string str;
  cin >> str;
  int len = str.length();
  vector<int> fre1, fre2;
  fre1.resize(10), fre2.resize(10);
  for (int i = int(0); i <= int(len - 1); i++) {
    fre1[str[i] - '0']++;
    fre2[str[i] - '0']++;
  }
  bool isans = false;
  struct res fin;
  for (int i = int(0); i <= int(8); i++) {
    vector<int> f1, f2;
    if (fre1[n[i + 1]] > 0 && fre2[p[i]] > 0) {
      struct res tmp;
      f1 = fre1;
      f2 = fre2;
      while (f1[0] > f1[9]) {
        tmp.s1 += '0';
        tmp.s2 += '0';
        f1[0]--;
        f2[0]--;
        tmp.ans++;
      }
      tmp.s1 += char(n[i + 1] + '0');
      tmp.s2 += char(p[i] + '0');
      tmp.ans++;
      f1[n[i + 1]]--;
      f2[p[i]]--;
      struct res k = maxi(f1, f2);
      tmp.s1 += k.s1;
      tmp.s2 += k.s2;
      tmp.ans = tmp.ans + k.ans;
      if (tmp.ans > fin.ans) {
        fin.ans = tmp.ans;
        fin.s1 = tmp.s1;
        fin.s2 = tmp.s2;
      }
    }
  }
  struct res tmp;
  tmp.ans = fre1[0];
  for (int i = int(0); i <= int(9); i++) {
    while (fre1[i] > 0) {
      tmp.s1 += char(i + '0');
      tmp.s2 += char(i + '0');
      fre1[i]--;
    }
  }
  if (tmp.ans >= fin.ans) {
    fin.ans = tmp.ans;
    fin.s1 = tmp.s1;
    fin.s2 = tmp.s2;
  }
  reverse(fin.s1.begin(), fin.s1.end());
  reverse(fin.s2.begin(), fin.s2.end());
  cout << fin.s1 << endl << fin.s2 << endl;
  return 0;
}
