#include <bits/stdc++.h>
using namespace std;
int const Max_N = 1e5 + 50;
int n;
vector<int> v1, v2;
char s[Max_N];
int main() {
  int a[11] = {0};
  int b[11] = {0};
  cin >> s;
  int n = strlen(s);
  for (int i = 0; i < (n); ++i) {
    a[s[i] - '0']++;
    b[s[i] - '0']++;
  }
  int cnt[10] = {0};
  int k = 0;
  for (int i = 1; i < (6); ++i) {
    int zero = 0;
    if (a[i] == 0 || b[10 - i] == 0) continue;
    int c[11] = {0}, d[11] = {0};
    for (int j = 0; j < (10); ++j) c[j] = a[j], d[j] = b[j];
    zero = 1;
    c[i]--;
    d[10 - i]--;
    for (int i = 0; i < (10); ++i) zero += min(c[i], d[9 - i]);
    cnt[i] = zero;
    if (cnt[i] > cnt[k]) k = i;
  }
  if (k == 0) {
    for (int i = 1; i < (10); ++i)
      while (a[i]--) cout << i;
    while (a[0]--) cout << 0;
    cout << endl;
    for (int i = 1; i < (10); ++i)
      while (b[i]--) cout << i;
    while (b[0]--) cout << 0;
    cout << endl;
    return 0;
  }
  a[k]--, b[10 - k]--;
  for (int i = 0; i < (10); ++i) {
    int t = min(a[i], b[9 - i]);
    a[i] -= t;
    b[9 - i] -= t;
    while (t--) v1.push_back(i), v2.push_back(9 - i);
  }
  int t = min(a[0], b[0]);
  a[0] -= t;
  b[0] -= t;
  for (int i = 0; i < (10); ++i) {
    while (a[i]--) cout << i;
  }
  for (int i = 0; i < (v1.size()); ++i) cout << v1[i];
  cout << k;
  for (int i = 0; i < (t); ++i) cout << 0;
  cout << endl;
  for (int i = 0; i < (10); ++i) {
    while (b[i]--) cout << i;
  }
  for (int i = 0; i < (v2.size()); ++i) cout << v2[i];
  cout << 10 - k;
  for (int i = 0; i < (t); ++i) cout << 0;
  cout << endl;
  return 0;
}
