#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  int cnt[2][10] = {};
  int ans[10][10] = {};
  string s;
  cin >> s;
  for (char c : s) {
    cnt[0][c - '0']++;
    cnt[1][c - '0']++;
  }
  for (int i = 0; i <= 9; ++i)
    while (cnt[0][i] && cnt[1][9 - i]) {
      ++ans[i][9 - i];
      --cnt[0][i];
      --cnt[1][9 - i];
    }
  while (cnt[0][0] && cnt[1][0]) {
    --cnt[0][0];
    --cnt[1][0];
    ++ans[0][0];
  }
  bool found = false;
  for (int i = 1; i <= 9; ++i)
    if (cnt[0][i] && cnt[1][10 - i]) {
      ++ans[i][10 - i];
      --cnt[0][i];
      --cnt[1][10 - i];
      found = true;
    }
  for (int a = 0; a <= 9; ++a)
    for (int b = 0; b <= 9; ++b)
      for (int c = 0; c <= 9; ++c)
        for (int d = 0; d <= 9; ++d)
          if (!found && ans[a][b] > 0 && c + d == 10 && (c == a || cnt[0][c]) &&
              (d == b || cnt[1][d])) {
            ++cnt[0][a];
            ++cnt[1][b];
            --ans[a][b];
            --cnt[0][c];
            --cnt[1][d];
            ++ans[c][d];
            found = true;
          }
  while (cnt[0][0] && cnt[1][0]) {
    --cnt[0][0];
    --cnt[1][0];
    ++ans[0][0];
  }
  for (int a = 0; a <= 9; ++a)
    for (int b = 0; b <= 9; ++b)
      while (cnt[0][a] > 0 && cnt[1][b] > 0) {
        cnt[0][a]--;
        cnt[1][b]--;
        ++ans[a][b];
      }
  string a, b;
  while (ans[0][0] > 0) {
    --ans[0][0];
    a += "0";
    b += "0";
  }
  for (int i = 1; i <= 9; ++i)
    if (ans[i][10 - i] > 0) {
      --ans[i][10 - i];
      a.push_back(i + '0');
      b.push_back(10 - i + '0');
      break;
    }
  for (int i = 0; i <= 9; ++i)
    while (ans[i][9 - i] > 0) {
      --ans[i][9 - i];
      a.push_back(i + '0');
      b.push_back(9 - i + '0');
    }
  for (int i = 0; i <= 9; ++i)
    for (int j = 0; j <= 9; ++j)
      while (ans[i][j] > 0) {
        --ans[i][j];
        a.push_back(i + '0');
        b.push_back(j + '0');
      }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  cout << a << '\n';
  cout << b << '\n';
}
