#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v(10);
  string n;
  cin >> n;
  for (int(i) = (0); (i) < (n.size()); ++(i)) {
    char c = n[i];
    v[c - '0']++;
  }
  int best = v[0];
  string best1, best2;
  for (int(j) = (0); (j) < (10); ++(j)) {
    best1 += string(v[j], '0' + j);
    best2 += string(v[j], '0' + j);
  }
  for (int(i) = (1); (i) < (10); ++(i)) {
    if (v[i] == 0) continue;
    if (v[10 - i] == 0) continue;
    vector<int> w(v);
    vector<int> z(v);
    w[i]--;
    z[10 - i]--;
    string perm1(1, '0' + i);
    string perm2(1, '0' + 10 - i);
    int ret = 1;
    for (int(j) = (0); (j) < (10); ++(j)) {
      int k = min(w[j], z[9 - j]);
      w[j] -= k;
      z[9 - j] -= k;
      ret += k;
      perm1 += string(k, '0' + j);
      perm2 += string(k, '0' + 9 - j);
    }
    int q = min(w[0], z[0]);
    w[0] -= q;
    z[0] -= q;
    ret += q;
    perm1 = string(q, '0') + perm1;
    perm2 = string(q, '0') + perm2;
    for (int(j) = (0); (j) < (10); ++(j)) {
      perm1 += string(w[j], '0' + j);
      perm2 += string(z[j], '0' + j);
    }
    if (ret > best) {
      best1 = perm1;
      best2 = perm2;
      best = ret;
    }
  }
  reverse(best1.begin(), best1.end());
  reverse(best2.begin(), best2.end());
  cout << best1 << endl << best2 << endl;
}
