#include <bits/stdc++.h>
using namespace std;
int frc[2][11];
int init[11];
void test() {
  string s;
  cin >> s;
  for (auto i : s) init[i - '0']++;
  sort(s.rbegin(), s.rend());
  int n = 0;
  while (s[s.size() - n - 1] == '0') n++;
  pair<int, pair<string, string>> ans = {n, {s, s}};
  for (int i = 1; i <= 9; i++) {
    for (int i = 0; i <= 10; i++) frc[0][i] = frc[1][i] = init[i];
    if (frc[0][i] && frc[1][10 - i]) {
      string ansa, ansb;
      int nr = 1;
      ansa += i + '0', ansb += 10 - i + '0', frc[0][i]--, frc[1][10 - i]--;
      for (int i = 0; i <= 9; i++)
        while (frc[0][i] && frc[1][9 - i])
          ansa += i + '0', ansb += 9 - i + '0', frc[0][i]--, frc[1][9 - i]--,
              nr++;
      int nr0 = min(frc[0][0], frc[1][0]);
      frc[0][0] -= nr0, frc[1][0] -= nr0;
      nr += nr0;
      string zr;
      while (nr0--) zr += "0";
      for (int i = 0; i <= 9; i++) {
        while (frc[0][i]) ansa += i + '0', frc[0][i]--;
        while (frc[1][i]) ansb += i + '0', frc[1][i]--;
      }
      reverse(ansa.begin(), ansa.end());
      reverse(ansb.begin(), ansb.end());
      ans = max(ans, {nr, {ansa + zr, ansb + zr}});
    }
  }
  cout << ans.second.first << ' ' << ans.second.second << '\n';
}
int main() {
  test();
  return 0;
}
