#include <bits/stdc++.h>
using namespace std;
int main() {
  int v1[11] = {0}, v2[11] = {0}, v[11] = {0};
  string s;
  cin >> s;
  int len = s.size();
  int flag = 0;
  int mx = 0;
  for (int i = 0; i < len; i++)
    v[s[i] - '0']++, v1[s[i] - '0']++, v2[s[i] - '0']++;
  for (int i = 1; i <= 5; i++) {
    int cnt = 0;
    if (v1[i] && v2[10 - i]) {
      flag = 1;
      v1[i]--;
      v2[10 - i]--;
      cnt++;
      for (int j = 0; j <= 9; j++) {
        cnt += min(v1[j], v2[9 - j]);
      }
      cnt += v[0] - min(v[0], v[9]);
    }
    mx = max(mx, cnt);
    for (int k = 0; k <= 9; k++) v1[k] = v[k], v2[k] = v[k];
  }
  if (!flag) {
    for (int i = 9; i >= 0; i--)
      while (v1[i]--) cout << i;
    cout << endl;
    for (int i = 9; i >= 0; i--)
      while (v2[i]--) cout << i;
    cout << endl;
    return 0;
  }
  vector<int> a, b;
  for (int i = 1; i <= 5; i++) {
    int cnt = 0;
    if (v1[i] && v2[10 - i]) {
      flag = 1;
      v1[i]--;
      v2[10 - i]--;
      a.push_back(i);
      b.push_back(10 - i);
      cnt++;
      for (int j = 0; j <= 9; j++) {
        cnt += min(v1[j], v2[9 - j]);
        int kk = min(v1[j], v2[9 - j]);
        v1[j] -= kk;
        v2[9 - j] -= kk;
        while (kk--) {
          a.push_back(j);
          b.push_back(9 - j);
        }
      }
      cnt += v[0] - min(v[0], v[9]);
    }
    if (cnt == mx) {
      int k = min(v1[0], v2[0]);
      int k1 = k, k2 = k;
      v1[0] -= k;
      v2[0] -= k;
      for (int i = 0; i <= 9; i++)
        while (v1[i]--) cout << i;
      for (int i = a.size() - 1; i >= 0; i--) cout << a[i];
      while (k1--) cout << "0";
      cout << endl;
      for (int i = 0; i <= 9; i++)
        while (v2[i]--) cout << i;
      for (int i = b.size() - 1; i >= 0; i--) cout << b[i];
      while (k2--) cout << "0";
      cout << endl;
      break;
    } else
      a.clear(), b.clear();
    for (int k = 0; k <= 9; k++) v1[k] = v[k], v2[k] = v[k];
  }
  return 0;
}
