#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
const int maxm = 500 * 500 + 10;
const int inf = 1e9;
const long long mod = 1e9 + 7;
int getint() {
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9') && c != '-')
    ;
  int ret = c - '0', sgn = 0;
  if (c == '-') sgn = 1, ret = 0;
  while ((c = getchar()) && c >= '0' && c <= '9') ret = ret * 10 + c - '0';
  if (sgn) ret = -ret;
  return ret;
}
char s[maxn];
int a[maxn];
multiset<int> s1, s2;
vector<int> g, ans1, ans2;
multiset<int>::iterator it1, it2;
int main() {
  scanf("%s", s);
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    a[i] = s[i] - '0';
    s1.insert(a[i]);
    s2.insert(a[i]);
  }
  int x, y;
  int mx = -1;
  for (int d = 1; d <= 10; d++) {
    int flag = 0;
    int len0 = 0;
    g.clear();
    x = -1, y = -1;
    if ((s1.find(d) != s1.end()) && (s2.find(10 - d) != s2.end())) {
      s1.erase(s1.find(d));
      s2.erase(s2.find(10 - d));
      x = d, y = 10 - d;
      flag = 1;
    }
    int temp = 0;
    if (flag) temp++;
    for (int i = 0; i < len; i++) {
      if (s1.find(a[i]) == s1.end()) continue;
      if (s2.find(9 - a[i]) != s2.end()) {
        g.push_back(a[i]);
        s1.erase(s1.find(a[i]));
        s2.erase(s2.find(9 - a[i]));
        if (flag) temp++;
      } else if (a[i] == 0 && s2.find(0) != s2.end()) {
        len0++;
        s1.erase(s1.find(0));
        s2.erase(s2.find(0));
      }
    }
    if (temp > mx) {
      mx = temp;
      ans1.clear(), ans2.clear();
      for (int i = 1; i <= len0; i++) ans1.push_back(0), ans2.push_back(0);
      if (x != -1) ans1.push_back(x), ans2.push_back(10 - x);
      for (int i = 0; i < (g.size()); i++)
        ans1.push_back(g[i]), ans2.push_back(9 - g[i]);
      it1 = s1.begin();
      while (it1 != s1.end()) ans1.push_back((*it1)), it1++;
      it2 = s2.begin();
      while (it2 != s2.end()) ans2.push_back((*it2)), it2++;
    }
    s1.clear();
    s2.clear();
    for (int i = 0; i < len; i++) s1.insert(a[i]), s2.insert(a[i]);
  }
  for (int i = len - 1; i >= 0; i--) {
    cout << ans1[i];
  }
  cout << endl;
  for (int i = len - 1; i >= 0; i--) {
    cout << ans2[i];
  }
  cout << endl;
  return 0;
}
