#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(T v) {
  if (v.size()) cout << v[0];
  for (int i = (int)1; i <= (int)v.size() - 1; i++) cout << " " << v[i];
  cout << "\n";
}
void show(int v[], int n) {
  if (n) cout << v[0];
  for (int i = (int)1; i <= (int)n - 1; i++) cout << " " << v[i];
  cout << "\n";
}
int dx[] = {0, -1, 1, 0};
int dy[] = {1, 0, 0, -1};
int du[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dv[] = {1, 1, 1, 0, 0, -1, -1, -1};
long long ncr[100 + 1][100 + 1];
vector<int> v1, v2, v;
int main() {
  string str;
  int m, n, Numof_zero;
  while (getline(cin, str)) {
    v = vector<int>(10, 0);
    for (int i = (int)0; i <= (int)str.size() - 1; i++) v[str[i] - '0']++;
    sort(str.begin(), str.end());
    reverse(str.begin(), str.end());
    pair<int, pair<string, string> > out(v[0], make_pair(str, str));
    for (int i = (int)1; i <= (int)9; i++) {
      if (!v[i] || !v[10 - i]) continue;
      string ret1, ret2;
      Numof_zero = 1;
      v1 = v;
      v2 = v;
      ret1 += i + '0';
      ret2 += (10 - i) + '0';
      v1[i]--;
      v2[10 - i]--;
      for (int j = (int)0; j <= (int)9; j++) {
        m = min(v1[j], v2[9 - j]);
        v1[j] -= m;
        v2[9 - j] -= m;
        Numof_zero += m;
        for (int k = (int)1; k <= (int)m; k++) {
          ret1 += j + '0';
          ret2 += (9 - j) + '0';
        }
      }
      m = min(v1[0], v2[0]);
      v1[0] -= m;
      v2[0] -= m;
      Numof_zero += m;
      for (int j = (int)0; j <= (int)9; j++) {
        for (int k = (int)1; k <= (int)v1[j]; k++) ret1 += j + '0';
        for (int k = (int)1; k <= (int)v2[j]; k++) ret2 += j + '0';
      }
      reverse(ret1.begin(), ret1.end());
      reverse(ret2.begin(), ret2.end());
      for (int j = (int)1; j <= (int)m; j++) {
        ret1 += '0';
        ret2 += '0';
      }
      out = max(out, make_pair(Numof_zero, make_pair(ret1, ret2)));
    }
    cout << out.second.first << "\n" << out.second.second << "\n";
  }
  return 0;
}
