#include <bits/stdc++.h>
using namespace std;
deque<int> a, b;
int main() {
  string num;
  int i, j, k, f = 1, m;
  int v1[10] = {0}, v2[10] = {0};
  cin >> num;
  for (i = 0; i < num.length(); i++) {
    v1[num[i] - '0']++;
    v2[num[i] - '0']++;
  }
  for (i = 9, j = 0; i >= 0 && j <= 9;) {
    if (v1[i] && v2[j]) {
      v1[i]--;
      v2[j]--;
      a.push_back(i);
      b.push_back(j);
    } else {
      i--;
      j++;
    }
  }
  for (i = 9, j = 1; i >= 1 && j <= 9;) {
    if (v1[i] && v2[j]) {
      v1[i]--;
      v2[j]--;
      a.push_back(i);
      b.push_back(j);
      f = 0;
      break;
    } else {
      i--;
      j++;
    }
  }
  m = min(v1[0], v2[0]);
  v1[0] -= m;
  v2[0] -= m;
  for (i = 9; i >= 0;)
    if (v1[i]) {
      a.push_front(i);
      v1[i]--;
    } else
      i--;
  for (i = 9; i >= 0;)
    if (v2[i]) {
      b.push_front(i);
      v2[i]--;
    } else
      i--;
  if (f) {
    int l1, l2, r1, r2;
    int q1[10] = {0}, q2[10] = {0};
    for (i = 0, j = a.size() - 1; i < a.size(); i++, j--) {
      if (!q1[a[i]]) q1[a[i]] = i + 1;
      if (!q2[b[j]]) q2[b[j]] = j + 1;
    }
    for (i = 1, j = 9; i <= 9; i++, j--)
      if (q1[i] && q2[j] && q1[i] < q2[j]) {
        i = q1[i] - 1;
        j = q2[j] - 1;
        if (i < j) {
          l1 = a[i];
          r1 = b[j];
          l2 = a[j];
          r2 = b[i];
        } else {
          l1 = a[j];
          r1 = b[i];
          l2 = a[i];
          r2 = b[j];
        }
        a[i] = -1;
        a[j] = -1;
        b[i] = -1;
        b[j] = -1;
        a.push_front(l2);
        a.push_back(l1);
        b.push_front(r2);
        b.push_back(r1);
        break;
      }
  }
  a.resize(a.size() + m);
  b.resize(b.size() + m);
  for (i = 0; i < a.size(); i++)
    if (a[i] != -1) cout << a[i];
  cout << endl;
  for (i = 0; i < b.size(); i++)
    if (b[i] != -1) cout << b[i];
  cout << endl;
  return 0;
}
