#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long double pi = acosl(-1);
const long long inf = 1e15;
const int nmax = 1e5 + 5;
const int MAXLG = log2(nmax) + 1;
int cnt[10];
int cnta[10], cntb[10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, resa, resb;
  cin >> s;
  for (char ch : s) cnt[ch - '0']++;
  int ans = 0;
  for (int j = 1; j <= 9; j++) {
    int curans = 0;
    string sa, sb;
    if (cnt[j] and cnt[10 - j]) {
      for (int i = 0; i < 10; i++) cnta[i] = cntb[i] = cnt[i];
      while (cnta[0] > min(cnta[0], cnta[9])) {
        sa += '0', sb += '0';
        cnta[0]--, cntb[0]--, curans++;
      }
      sa += (j + '0'), sb += (10 - j + '0');
      cnta[j]--, cntb[10 - j]--, curans++;
      for (int i = 0; i <= 9; i++) {
        while (cnta[i] and cntb[9 - i])
          cnta[i]--, cntb[9 - i]--, sa += (i + '0'), sb += (9 - i + '0'),
              curans++;
      }
      if (curans > ans) {
        ans = curans;
        for (int i = 0; i < 10; i++) {
          while (cnta[i]) sa += (i + '0'), cnta[i]--;
          while (cntb[i]) sb += (i + '0'), cntb[i]--;
        }
        resa = sa, resb = sb;
      }
    }
  }
  string sa, sb;
  int curans = 0;
  while (cnt[0]) cnt[0]--, sa += '0', sb += '0', curans++;
  if (curans > ans) {
    ans = curans;
    for (int i = 1; i < 10; i++) {
      while (cnt[i]) sa += (i + '0'), sb += (i + '0'), cnt[i]--;
    }
    resa = sa, resb = sb;
  }
  reverse(resa.begin(), resa.end()), reverse(resb.begin(), resb.end());
  if (ans == 0)
    cout << s << "\n" << s;
  else
    cout << resa << "\n" << resb;
}
