#include <bits/stdc++.h>
using namespace std;
int a[11], b[11], c[11], ans, pos = -1;
string second, p, q;
int main() {
  cin >> second;
  for (int i = 0; i < second.size(); i++) {
    a[second[i] - '0']++;
  }
  int t = 0, cnt = a[0];
  while (a[0] >= 0) {
    if (t > ans) {
      ans = t;
      cnt = t;
      pos = -1;
    }
    for (int i = 1; i < 10; i++)
      if (a[i] && a[(10 - i) % 10]) {
        for (int j = 0; j < 10; j++) {
          b[j] = a[j];
          c[j] = a[j];
        }
        b[i]--;
        c[(10 - i) % 10]--;
        int k = t + 1;
        for (int j = 0; j < 10; j++) {
          k += min(b[j], c[9 - j]);
        }
        if (k > ans) {
          ans = k;
          pos = i;
          cnt = t;
        }
      }
    t++;
    a[0]--;
  }
  a[0] = t - 1;
  if (pos == -1) {
    for (int i = 9; i >= 0; i--) {
      while (a[i] > 0) {
        p += char(i + '0');
        a[i]--;
      }
    }
    cout << p << endl << p;
    return 0;
  }
  for (int i = 0; i < 10; i++) {
    b[i] = a[i];
    c[i] = a[i];
  }
  for (int i = 1; i <= cnt; i++) {
    p += '0';
    q += '0';
  }
  b[0] -= cnt;
  c[0] -= cnt;
  p += char(pos + '0');
  q += char((10 - pos) % 10 + '0');
  b[pos]--;
  c[(10 - pos) % 10]--;
  int i = 0;
  while (i < 10) {
    if (b[i] > 0 && c[(9 - i) % 10] > 0) {
      b[i]--;
      c[(9 - i) % 10]--;
      p += char(i + '0');
      q += char((9 - i) % 10 + '0');
    } else {
      i++;
    }
  }
  for (int j = 0; j < 10; j++) {
    while (b[j] > 0) {
      p += char(j + '0');
      b[j]--;
    }
    while (c[j] > 0) {
      q += char(j + '0');
      c[j]--;
    }
  }
  reverse(p.begin(), p.end());
  reverse(q.begin(), q.end());
  cout << p << endl;
  cout << q;
  return 0;
}
