#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<long> mass1(10, 0);
  for (long i = 0; i < s.size(); i++) mass1[s[i] - '0']++;
  vector<long> mass2 = mass1;
  vector<long> s1(s.size(), 0);
  vector<long> s2(s.size(), 0);
  long a = s.size() - 1;
  bool flag = true;
  long kol = 0;
  long num = -1;
  long temp = 0, t1 = 0, t2 = 0;
  bool fl = false;
  for (long i = 1; i < 9; i++)
    if (mass1[i] != 0 && mass2[10 - i] != 0) {
      temp = 1;
      mass1[i]--;
      mass2[10 - i]--;
      t1 = 0;
      t2 = 0;
      for (long j = 0; j <= 9; j++) temp += min(mass1[j], mass2[9 - j]);
      if (mass2[9] < mass1[0]) t1 = mass1[0] - mass2[9];
      if (mass2[0] > mass1[9]) t2 = mass2[0] - mass1[9];
      temp += min(t1, t2);
      mass1[i]++;
      mass2[10 - i]++;
      if (temp > kol) {
        kol = temp;
        num = i;
      }
    }
  for (long i = 1; i < 9; i++)
    if (mass1[i] != 0 && mass2[10 - i] != 0) {
      temp = mass1[0] + 1;
      mass1[i]--;
      mass2[10 - i]--;
      t1 = 0;
      t2 = 0;
      for (long j = 1; j < 9; j++) temp += min(mass1[j], mass2[9 - j]);
      mass1[i]++;
      mass2[10 - i]++;
      if (temp >= kol) {
        kol = temp;
        num = i;
        fl = true;
      }
    }
  if (num != -1) {
    if (fl == false) {
      mass1[num]--;
      mass2[10 - num]--;
      if (mass2[9] < mass1[0]) t1 = mass1[0] - mass2[9];
      if (mass2[0] > mass1[9]) t2 = mass2[0] - mass1[9];
      for (long i = 0; i < min(t1, t2); i++) {
        s1[a] = 0;
        s2[a] = 0;
        a--;
      }
      mass1[0] -= min(t1, t2);
      mass2[0] -= min(t1, t2);
      s1[a] = num;
      s2[a] = 10 - num;
      a--;
      for (long i = 0; i <= 9; i++) {
        for (long j = 0; j < min(mass1[i], mass2[9 - i]); j++) {
          s1[a] = i;
          s2[a] = 9 - i;
          a--;
        }
        long kq = min(mass1[i], mass2[9 - i]);
        mass1[i] -= kq;
        mass2[9 - i] -= kq;
      }
      long b = a;
      for (long i = 0; i < 10; i++) {
        for (long j = 0; j < mass1[i]; j++) {
          s1[a] = i;
          a--;
        }
        for (long j = 0; j < mass2[i]; j++) {
          s2[b] = i;
          b--;
        }
      }
      for (long i = 0; i < s.size(); i++) cout << s1[i];
      cout << "\n";
      for (long i = 0; i < s.size(); i++) cout << s2[i];
    } else {
      mass1[num]--;
      mass2[10 - num]--;
      for (long i = 0; i < mass1[0]; i++) {
        s1[a] = 0;
        s2[a] = 0;
        a--;
      }
      mass1[0] = 0;
      mass2[0] = 0;
      s1[a] = num;
      s2[a] = 10 - num;
      a--;
      for (long i = 1; i < 9; i++) {
        for (long j = 0; j < min(mass1[i], mass2[9 - i]); j++) {
          s1[a] = i;
          s2[a] = 9 - i;
          a--;
        }
        long kq = min(mass1[i], mass2[9 - i]);
        mass1[i] -= kq;
        mass2[9 - i] -= kq;
      }
      long b = a;
      for (long i = 0; i < 10; i++) {
        for (long j = 0; j < mass1[i]; j++) {
          s1[a] = i;
          a--;
        }
        for (long j = 0; j < mass2[i]; j++) {
          s2[b] = i;
          b--;
        }
      }
      for (long i = 0; i < s.size(); i++) cout << s1[i];
      cout << "\n";
      for (long i = 0; i < s.size(); i++) cout << s2[i];
    }
  } else {
    for (long i = 9; i >= 0; i--)
      for (long j = 0; j < mass1[i]; j++) cout << i;
    cout << "\n";
    for (long i = 9; i >= 0; i--)
      for (long j = 0; j < mass1[i]; j++) cout << i;
  }
}
