#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
char s[N];
int cnt[2][2][10];
int main() {
  while (~scanf("%s", s)) {
    memset(cnt, 0, sizeof(cnt));
    int lens = strlen(s);
    for (int i = (0); i < (lens); ++i)
      for (int j = (0); j < (2); ++j)
        for (int k = (0); k < (2); ++k) ++cnt[j][k][s[i] - '0'];
    int Max = 0, p = -1;
    for (int i = (1); i < (10); ++i) {
      for (int a = (0); a < (10); ++a)
        for (int b = (0); b < (2); ++b) cnt[1][b][a] = cnt[0][b][a];
      if (cnt[1][0][i] == 0 || cnt[1][1][10 - i] == 0) continue;
      int res = 1;
      --cnt[1][0][i];
      --cnt[1][1][10 - i];
      for (int j = (0); j < (10); ++j) {
        int t = min(cnt[1][0][j], cnt[1][1][9 - j]);
        res += t;
        cnt[1][0][j] -= t;
        cnt[1][1][9 - j] -= t;
      }
      res += min(cnt[1][0][0], cnt[1][1][0]);
      if (res > Max) {
        Max = res;
        p = i;
      }
    }
    if (p == -1) {
      int t = min(cnt[0][0][0], cnt[0][1][0]);
      cnt[0][0][0] -= t;
      cnt[0][1][0] -= t;
      string ans1 = "", ans2 = "";
      while (t--) {
        ans1 = ans1 + string(1, '0');
        ans2 = ans2 + string(1, '0');
      }
      for (int j = (0); j < (10); ++j) {
        while (cnt[0][0][j]--) {
          ans1 = string(1, j + '0') + ans1;
        }
      }
      for (int j = (0); j < (10); ++j) {
        while (cnt[0][1][j]--) {
          ans2 = string(1, j + '0') + ans2;
        }
      }
      cout << ans1 << endl << ans2 << endl;
      continue;
    }
    char c1 = p + '0', c2 = 10 - p + '0';
    string ans1 = "" + string(1, c1), ans2 = "" + string(1, c2);
    int i = p;
    for (int a = (0); a < (10); ++a)
      for (int b = (0); b < (2); ++b) cnt[1][b][a] = cnt[0][b][a];
    --cnt[1][0][i];
    --cnt[1][1][10 - i];
    for (int j = (0); j < (10); ++j) {
      int t = min(cnt[1][0][j], cnt[1][1][9 - j]);
      cnt[1][0][j] -= t;
      cnt[1][1][9 - j] -= t;
      while (t--) {
        ans1 = string(1, j + '0') + ans1;
        ans2 = string(1, 9 - j + '0') + ans2;
      }
    }
    int t = min(cnt[1][0][0], cnt[1][1][0]);
    cnt[1][0][0] -= t;
    cnt[1][1][0] -= t;
    while (t--) {
      ans1 = ans1 + string(1, '0');
      ans2 = ans2 + string(1, '0');
    }
    for (int j = (0); j < (10); ++j) {
      while (cnt[1][0][j]--) {
        ans1 = string(1, j + '0') + ans1;
      }
    }
    for (int j = (0); j < (10); ++j) {
      while (cnt[1][1][j]--) {
        ans2 = string(1, j + '0') + ans2;
      }
    }
    cout << ans1 << endl << ans2 << endl;
  }
  return 0;
}
