#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int a1[10], a2[10];
  for (int i = 0; i < 10; i++) {
    a1[i] = 0;
    a2[i] = 0;
  }
  for (int i = 0; i < s.size(); i++) {
    a1[s[i] - '0']++;
    a2[s[i] - '0']++;
  }
  int b[10];
  for (int i = 0; i < 10; i++) b[i] = 0;
  for (int i = 0; i < 10; i++) {
    b[i] = min(a1[i], a2[9 - i]);
    a1[i] -= b[i];
    a2[9 - i] -= b[i];
  }
  int cnt = a1[0];
  a1[0] = 0;
  a2[0] = 0;
  for (int i = 1; i < 10; i++)
    if (a1[i] > 0 && a2[10 - i] > 0) {
      string ans1 = "", ans2 = "";
      for (int j = 0; j < cnt; j++) {
        ans1 += '0';
        ans2 += '0';
      }
      ans1 += (char)(i + '0');
      a1[i]--;
      ans2 += (char)(10 - i + '0');
      a2[10 - i]--;
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < b[j]; k++) {
          ans1 += (char)(j + '0');
          ans2 += (char)(9 - j + '0');
        }
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < a1[j]; k++) ans1 += (char)(j + '0');
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < a2[j]; k++) ans2 += (char)(j + '0');
      reverse(ans1.begin(), ans1.end());
      reverse(ans2.begin(), ans2.end());
      cout << ans1 << endl;
      cout << ans2 << endl;
      return 0;
    }
  for (int i = 1; i < 10; i++)
    if (a1[i] > 0 && b[i - 1] > 0) {
      string ans1 = "", ans2 = "";
      for (int j = 0; j < cnt; j++) {
        ans1 += '0';
        ans2 += '0';
      }
      ans1 += (char)(i + '0');
      a1[i]--;
      ans2 += (char)(10 - i + '0');
      a1[i - 1]++;
      b[i - 1]--;
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < b[j]; k++) {
          ans1 += (char)(j + '0');
          ans2 += (char)(9 - j + '0');
        }
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < a1[j]; k++) ans1 += (char)(j + '0');
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < a2[j]; k++) ans2 += (char)(j + '0');
      reverse(ans1.begin(), ans1.end());
      reverse(ans2.begin(), ans2.end());
      cout << ans1 << endl;
      cout << ans2 << endl;
      return 0;
    }
  for (int i = 1; i < 10; i++)
    if (b[i] > 0 && b[i - 1] > 0) {
      string ans1 = "", ans2 = "";
      for (int j = 0; j < cnt; j++) {
        ans1 += '0';
        ans2 += '0';
      }
      ans1 += (char)(i + '0');
      a1[i - 1]++;
      ans2 += (char)(10 - i + '0');
      a2[9 - i]++;
      b[i]--;
      b[i - 1]--;
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < b[j]; k++) {
          ans1 += (char)(j + '0');
          ans2 += (char)(9 - j + '0');
        }
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < a1[j]; k++) ans1 += (char)(j + '0');
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < a2[j]; k++) ans2 += (char)(j + '0');
      reverse(ans1.begin(), ans1.end());
      reverse(ans2.begin(), ans2.end());
      cout << ans1 << endl;
      cout << ans2 << endl;
      return 0;
    }
  string ans1 = "", ans2 = "";
  for (int i = 0; i < cnt; i++) {
    ans1 += '0';
    ans2 += '0';
  }
  for (int j = 0; j < 10; j++)
    for (int k = 0; k < b[j]; k++) {
      ans1 += (char)(j + '0');
      ans2 += (char)(9 - j + '0');
    }
  for (int j = 0; j < 10; j++)
    for (int k = 0; k < a1[j]; k++) ans1 += (char)(j + '0');
  for (int j = 0; j < 10; j++)
    for (int k = 0; k < a2[j]; k++) ans2 += (char)(j + '0');
  reverse(ans1.begin(), ans1.end());
  reverse(ans2.begin(), ans2.end());
  cout << ans1 << endl;
  cout << ans2 << endl;
  return 0;
}
