#include <bits/stdc++.h>
int main() {
  static char cc[100001], s[100001], t[100001];
  static int kk[10], kk_[10];
  int n, ns, nt;
  int h, i, d, d_, k, k_, k0;
  int max, kmax, dmax;
  scanf("%s", cc);
  n = strlen(cc);
  k0 = 0;
  for (i = 0; i < n; i++) {
    kk[cc[i] - '0']++;
    if (cc[i] == '0') k0++;
  }
  max = kmax = dmax = -1, k = 0;
  while (kk[0] >= 0) {
    for (d = 0; d <= 9; d++) kk_[d] = kk[d];
    if (max < k) {
      max = kmax = k;
      dmax = -1;
    }
    for (d = 1; d <= 9; d++)
      if (kk[d] > 0 && kk_[10 - d] > 0) {
        kk[d]--, kk_[10 - d]--;
        k_ = 0;
        for (d_ = 0; d_ <= 9; d_++)
          k_ += kk[d_] < kk_[9 - d_] ? kk[d_] : kk_[9 - d_];
        kk[d]++, kk_[10 - d]++;
        if (max < k + 1 + k_) {
          max = k + 1 + k_;
          kmax = k;
          dmax = d;
        }
      }
    kk[0]--;
    k++;
  }
  ns = nt = 0;
  kk[0] = kk_[0] = k0 - kmax;
  if (dmax >= 0) {
    kk[dmax]--, kk_[10 - dmax]--;
    for (d_ = 0; d_ <= 9; d_++) {
      for (h = kk[d_]; h < kk_[9 - d_]; h++) t[nt++] = 9 - d_ + '0';
      for (h = kk_[9 - d_]; h < kk[d_]; h++) s[ns++] = d_ + '0';
    }
    for (d_ = 0; d_ <= 9; d_++)
      for (h = 0; h < kk[d_] && h < kk_[9 - d_]; h++) {
        s[ns++] = d_ + '0';
        t[nt++] = 9 - d_ + '0';
      }
    s[ns++] = dmax + '0';
    t[nt++] = 10 - dmax + '0';
  } else
    for (d_ = 0; d_ <= 9; d_++) {
      for (h = 0; h < kk[d_]; h++) s[ns++] = d_ + '0';
      for (h = 0; h < kk_[d_]; h++) t[nt++] = d_ + '0';
    }
  for (h = 0; h < kmax; h++) s[ns++] = t[nt++] = '0';
  printf("%s\n", s);
  printf("%s\n", t);
  return 0;
}
