#include <bits/stdc++.h>
using namespace std;
int C1[10];
int C2[10];
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) C1[s[i] - '0']++;
  memcpy(C2, C1, sizeof(C1));
  pair<int, int> best(0, 0);
  for (int i = 1, j = 9, MAX = -1; i <= 5; i++, j--) {
    if (C1[i] == 0 || C1[j] == 0) continue;
    C1[i]--;
    C2[j]--;
    int cnt = 0;
    for (int i = 0, j = 9; i <= 9; i++, j--) cnt += min(C1[i], C2[j]);
    if (MAX < cnt) {
      MAX = cnt;
      best = make_pair(i, 10 - i);
    }
    C1[i]++;
    C2[j]++;
  }
  string res1;
  string res2;
  if (best == make_pair(0, 0)) goto last;
  res1.push_back(best.first + '0');
  res2.push_back(best.second + '0');
  C1[best.first]--;
  C2[best.second]--;
  for (int i = 0, j = 9; i <= 9; i++, j--)
    while (C1[i] > 0 && C2[j] > 0) {
      res1.push_back(i + '0');
      res2.push_back(j + '0');
      C1[i]--;
      C2[j]--;
    }
last:
  int tmp = min(C1[0], C2[0]);
  res1.insert(0, string(tmp, '0'));
  res2.insert(0, string(tmp, '0'));
  C1[0] -= tmp;
  C2[0] -= tmp;
  for (int i = 0; i <= 9; i++) {
    while (C1[i] > 0) {
      res1.push_back(i + '0');
      C1[i]--;
    }
    while (C2[i] > 0) {
      res2.push_back(i + '0');
      C2[i]--;
    }
  }
  reverse(res1.begin(), res1.end());
  reverse(res2.begin(), res2.end());
  cout << res1 << endl << res2;
exit:
  return (0);
}
