#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
char n[100005];
int cnt[2][15], back[2][15];
int len;
int sum[2][15];
string ans, ans2;
int main() {
  scanf("%s", n);
  len = strlen(n);
  for (int i = 0; i < len; ++i) cnt[0][n[i] - '0']++, ++cnt[1][n[i] - '0'];
  memcpy(back, cnt, sizeof(cnt));
  int res = -1;
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      if (i + j == 10 && cnt[0][i] > 0 && cnt[1][j] > 0) {
        --cnt[0][i];
        --cnt[1][j];
        int tmp = (i + j == 10);
        for (int k = 1; k < 10; ++k) {
          tmp += min(cnt[0][k], cnt[1][9 - k]);
          cnt[1][9 - k] -= min(cnt[1][9 - k], cnt[0][k]);
        }
        tmp += min(cnt[0][0], cnt[1][9] + cnt[1][0]);
        res = max(res, tmp);
        memcpy(cnt, back, sizeof(cnt));
      }
  if (res < cnt[0][0]) {
    sort(n, n + len, greater<char>());
    cout << n << '\n' << n << endl;
    return 0;
  }
  cerr << "res"
       << " = " << (res) << endl;
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      if (i + j == 10 && cnt[0][i] > 0 && cnt[1][j] > 0) {
        --cnt[0][i];
        --cnt[1][j];
        int tmp = (i + j == 10);
        for (int k = 1; k < 10; ++k) {
          tmp += min(cnt[0][k], cnt[1][9 - k]);
          cnt[1][9 - k] -= min(cnt[1][9 - k], cnt[0][k]);
        }
        tmp += min(cnt[0][0], cnt[1][9] + cnt[1][0]);
        if (res == tmp) {
          memcpy(cnt, back, sizeof(cnt));
          --cnt[0][i];
          --cnt[1][j];
          ans += i + '0';
          ans2 += j + '0';
          int t;
          for (int k = 1; k < 10; ++k) {
            t = min(cnt[0][k], cnt[1][9 - k]);
            for (int hoge = 0; hoge < t; ++hoge)
              ans += k + '0', ans2 += (9 - k + '0');
            cnt[1][9 - k] -= t;
            cnt[0][k] -= t;
          }
          t = min(cnt[0][0], cnt[1][9] + cnt[1][0]);
          int prev = cnt[1][0];
          for (int hoge = 0; hoge < t; ++hoge) {
            --cnt[0][0];
            if (hoge < prev) {
              ans2 = '0' + ans2;
              ans = '0' + ans;
              --cnt[1][0];
            } else {
              --cnt[1][9];
              ans += '0';
              ans2 += '9';
            }
          }
          cerr << "ans"
               << " = " << (ans) << endl;
          cerr << "ans2"
               << " = " << (ans2) << endl;
          for (int k = 0; k < 10; ++k) {
            for (int hoge = 0; hoge < cnt[0][k]; ++hoge) ans += k + '0';
            for (int hoge = 0; hoge < cnt[1][k]; ++hoge) ans2 += k + '0';
          }
          reverse((ans2).begin(), (ans2).end());
          reverse((ans).begin(), (ans).end());
          cout << ans << '\n' << ans2 << endl;
          return 0;
        }
        memcpy(cnt, back, sizeof(cnt));
      }
  return 0;
}
