#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
char str[N];
int cnt[10];
int c1[10], c2[10];
deque<int> a, b;
int solve(int d) {
  memcpy(c1, cnt, sizeof(c1));
  memcpy(c2, cnt, sizeof(c2));
  a.clear();
  b.clear();
  int res = 0;
  if (d == 0) {
    while (c1[0] > 0 && c2[0] > 0) {
      c1[0]--;
      c2[0]--;
      a.push_back(0);
      b.push_back(0);
      res++;
    }
  } else {
    if (c1[d] <= 0 || c2[10 - d] <= 0) return -1;
    a.push_back(d);
    b.push_back(10 - d);
    c1[d]--;
    c2[10 - d]--;
    res = 1;
    for (int i = 0; i < 10; i++) {
      while (c1[i] > 0 && c2[9 - i] > 0) {
        a.push_back(i);
        b.push_back(9 - i);
        c1[i]--;
        c2[9 - i]--;
        res++;
      }
    }
    while (c1[0] > 0 && c2[0] > 0) {
      a.push_front(0);
      b.push_front(0);
      c1[0]--;
      c2[0]--;
      res++;
    }
  }
  for (int i = 0; i < 10; i++) {
    while (c1[i] > 0) {
      a.push_back(i);
      c1[i]--;
    }
    while (c2[i] > 0) {
      b.push_back(i);
      c2[i]--;
    }
  }
  return res;
}
int main() {
  cin >> str;
  int n = strlen(str);
  for (int i = 0; i < n; i++) cnt[str[i] - 48]++;
  int p = 0;
  int ans = solve(0);
  for (int i = 1; i < 10; i++) {
    int tmp = solve(i);
    if (tmp > ans) {
      ans = tmp;
      p = i;
    }
  }
  solve(p);
  reverse(a.begin(), a.end());
  for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
    printf("%d", *it);
  puts("");
  reverse(b.begin(), b.end());
  for (__typeof((b).begin()) it = (b).begin(); it != (b).end(); it++)
    printf("%d", *it);
  puts("");
  return 0;
}
