#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int MAX = 100 + 2, MOD = 100000007;
int cnt[11], cnt1[11], cnt2[11];
int dp[11][11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, ans1, ans2;
  cin >> s;
  for (int i = 0; i < s.size(); i++) cnt[s[i] - '0']++;
  int mx = -1;
  for (int d = 1; d < 10; d++) {
    if (cnt[d] and cnt[10 - d]) {
      for (int i = 0; i < 10; i++) {
        cnt1[i] = cnt[i];
        cnt2[i] = cnt[i];
      }
      cnt1[d]--;
      cnt2[10 - d]--;
      int cur = 1;
      for (int i = 0; i < 10; i++) {
        dp[i][9 - i] = min(cnt1[i], cnt2[9 - i]);
        cur += dp[i][9 - i];
        cnt1[i] -= dp[i][9 - i];
        cnt2[9 - i] -= dp[i][9 - i];
      }
      dp[0][0] = min(cnt1[0], cnt2[0]);
      cur += dp[0][0];
      cnt1[0] -= dp[0][0];
      cnt2[0] -= dp[0][0];
      if (cur > mx) {
        mx = cur;
        ans1 = "";
        ans2 = "";
        for (int i = 0; i < dp[0][0]; i++) {
          ans1 += '0';
          ans2 += '0';
        }
        ans1 += (char)('0' + d);
        ans2 += (char)('0' + 10 - d);
        for (int i = 0; i < 10; i++) {
          for (int j = 0; j < dp[i][9 - i]; j++) {
            ans1 += (char)(i + '0');
            ans2 += (char)(9 - i + '0');
          }
        }
        for (int i = 0; i < 10; i++) {
          for (int j = 0; j < cnt1[i]; j++) ans1 += (char)(i + '0');
          for (int j = 0; j < cnt2[i]; j++) ans2 += (char)(i + '0');
        }
      }
    }
  }
  if (mx == -1) {
    ans1 = "";
    ans2 = "";
    for (int i = 0; i < 10; i++) {
      while (cnt[i]--) {
        ans1 += (char)(i + '0');
        ans2 += (char)(i + '0');
      }
    }
  }
  reverse(ans1.begin(), ans1.end());
  reverse(ans2.begin(), ans2.end());
  cout << ans1 << "\n" << ans2;
  return 0;
}
