#include <bits/stdc++.h>
using namespace std;
string s;
const int maxn = 20;
int d[maxn], p[maxn], f[maxn];
int best = -1, bestd = -1;
int cur;
string a = "", b = "";
int main() {
  getline(cin, s);
  for (int i = 0; i < (int)(s.size()); i++) {
    d[s[i] - '0']++;
  }
  for (int i = 1; i <= 5; i++) {
    for (int j = 0; j < 20; j++) p[j] = 2 * d[j];
    if (i != 5) {
      if (!p[i] || !p[10 - i]) continue;
    } else {
      if (p[i] < 2) continue;
    }
    cur = 1;
    p[i]--;
    p[10 - i]--;
    for (int j = 0; j <= 4; j++) {
      while (p[j] && p[9 - j]) {
        cur++;
        p[j]--;
        p[9 - j]--;
      }
    }
    while (p[0] >= 2) {
      p[0] -= 2;
      cur++;
    }
    if (cur > best) {
      best = cur, bestd = i;
    }
  }
  if (bestd == -1) {
    for (int i = 0; i < (int)(20); i++) p[i] = 2 * d[i];
    if (p[0] == 0) {
      printf("%s\n%s\n", s.c_str(), s.c_str());
      return 0;
    }
    bestd = 0;
  }
  for (int i = 0; i < (int)(20); i++) p[i] = 2 * d[i];
  list<pair<int, int> > res;
  res.push_front(make_pair(bestd, (10 - bestd) % 10));
  p[bestd]--;
  p[(10 - bestd) % 10]--;
  for (int j = 0; j <= 4; j++) {
    while (p[j] && p[9 - j]) {
      p[j]--;
      p[9 - j]--;
      res.push_front(make_pair(j, 9 - j));
    }
  }
  while (p[0] >= 2) {
    res.push_back(make_pair(0, 0));
    p[0] -= 2;
  }
  for (int i = 0; i < (int)(20); i++) p[i] = d[i];
  for (int i = 0; i < (int)(20); i++) f[i] = d[i];
  while (!res.empty()) {
    pair<int, int> q = res.front();
    if (!p[q.first] || !f[q.second]) swap(q.first, q.second);
    a += q.first + '0';
    b += q.second + '0';
    p[q.first]--;
    f[q.second]--;
    assert(p[q.first] >= 0);
    assert(f[q.second] >= 0);
    res.pop_front();
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < (int)(20); i++) {
    while (p[i]) {
      a += i + '0';
      p[i]--;
    }
    while (f[i]) {
      b += i + '0';
      f[i]--;
    }
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  printf("%s\n%s\n", a.c_str(), b.c_str());
}
