#include <bits/stdc++.h>
using namespace std;
int read(int &n) { return scanf("%d", &n); }
int read(unsigned int &n) { return scanf("%u", &n); }
int read(long long &n) { return scanf("%lld", &n); }
int read(unsigned long long &n) { return scanf("%llu", &n); }
int read(double &n) { return scanf("%lf", &n); }
int read(long double &n) { return scanf("%Lf", &n); }
int read(char *c) { return scanf("%s", c); }
const int N = 100010;
char c[N];
int d[10], ans[10];
int d1[10], e1[10];
int main() {
  memset((d), 0, sizeof(d));
  memset((ans), 0, sizeof(ans));
  read(c);
  int n = strlen(c);
  for (int i = 0; i < (int)(n); ++i) d[c[i] - '0']++;
  int maxi = -1;
  deque<char> t1, t2;
  for (int i = 0; i <= 5; i++) {
    deque<char> s1, s2;
    for (int j = 0; j < (int)(10); ++j) d1[j] = e1[j] = d[j];
    int ct = 0;
    if (i > 0) {
      if (d[i] == 0 or d[10 - i] == 0) continue;
      ct++;
      d1[i]--;
      e1[10 - i]--;
      s1.push_front('0' + i);
      s2.push_front('0' + 10 - i);
      for (int j = 0; j < (int)(10); ++j) {
        int m = min(d1[j], e1[9 - j]);
        ct += m;
        d1[j] -= m;
        e1[9 - j] -= m;
        for (int k = 0; k < (int)(m); ++k) s1.push_front('0' + j);
        for (int k = 0; k < (int)(m); ++k) s2.push_front('0' + 9 - j);
      }
    } else {
    }
    int m = min(d1[0], e1[0]);
    ct += m;
    d1[0] -= m;
    e1[0] -= m;
    for (int k = 0; k < (int)(m); ++k) s1.push_back('0');
    for (int k = 0; k < (int)(m); ++k) s2.push_back('0');
    for (int k = 0; k < (int)(10); ++k)
      for (int l = 0; l < (int)(d1[k]); ++l) s1.push_front('0' + k);
    for (int k = 0; k < (int)(10); ++k)
      for (int l = 0; l < (int)(e1[k]); ++l) s2.push_front('0' + k);
    if (ct > maxi) {
      maxi = ct;
      t1 = s1;
      t2 = s2;
    }
  }
  for (int i = 0; i < (int)(t1.size()); ++i) putchar(t1[i]);
  cout << endl;
  for (int i = 0; i < (int)(t2.size()); ++i) putchar(t2[i]);
  cout << endl;
}
