#include <bits/stdc++.h>
using ll = long long;
ll cnt[10], cnt1[10], cnt2[10];
int main() {
  std::string s;
  std::cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    cnt[s[i] - '0']++;
    cnt1[s[i] - '0']++;
    cnt2[s[i] - '0']++;
  }
  std::stack<std::pair<int, int>> ans1, ans2;
  ll ma = -1;
  for (int m = 0; m <= cnt[0]; m++) {
    std::stack<std::pair<int, int>> a, b;
    a.emplace(0, m);
    b.emplace(0, m);
    cnt1[0] -= m;
    cnt2[0] -= m;
    ll t = m;
    for (int i = 1; i <= 5; i++) {
      int cnt11[10], cnt22[10];
      for (int k = 0; k < 10; k++) {
        cnt11[k] = cnt[k];
        cnt22[k] = cnt[k];
      }
      cnt11[0] -= m;
      cnt22[0] -= m;
      ll tt = m;
      std::stack<std::pair<int, int>> aa, bb;
      aa.emplace(0, m), bb.emplace(0, m);
      int j = 10 - i;
      if (cnt11[i] == 0 || cnt22[j] == 0) continue;
      aa.emplace(i, 1);
      bb.emplace(j, 1);
      cnt11[i]--;
      cnt22[j]--;
      tt++;
      for (int k = 0; k < 10; k++) {
        int l = 9 - k;
        int mi = std::min(cnt11[k], cnt22[l]);
        if (mi == 0) continue;
        tt += mi;
        aa.emplace(k, mi);
        bb.emplace(l, mi);
        cnt11[k] -= mi;
        cnt22[l] -= mi;
      }
      if (tt > t) {
        t = tt;
        a = aa;
        b = bb;
        for (int k = 0; k < 10; k++) {
          cnt1[k] = cnt11[k];
          cnt2[k] = cnt22[k];
        }
      }
    }
    for (int k = 0; k < 10; k++) {
      if (cnt1[k] != 0) {
        a.emplace(k, cnt1[k]);
      }
    }
    for (int k = 0; k < 10; k++) {
      if (cnt2[k] != 0) {
        b.emplace(k, cnt2[k]);
      }
    }
    if (t > ma) {
      ma = t;
      ans1 = a;
      ans2 = b;
    }
    for (int k = 0; k < 10; k++) {
      cnt1[k] = cnt[k];
      cnt2[k] = cnt[k];
    }
  }
  if (ma == -1) {
    std::cout << s << " " << s << std::endl;
    return 0;
  }
  while (!ans1.empty()) {
    auto p = ans1.top();
    std::cout << std::string(p.second, (char)('0' + p.first));
    ans1.pop();
  }
  std::cout << "\n";
  while (!ans2.empty()) {
    auto p = ans2.top();
    std::cout << std::string(p.second, (char)('0' + p.first));
    ans2.pop();
  }
  std::cout << "\n";
  return 0;
}
