#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[100010], q[100010];
int r;
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  while (cin >> s) {
    string res1, res2;
    int maxi = 0;
    int n = s.size();
    vector<int> a(10, 0);
    for (int i = (0); i < ((s.size())); ++i) a[s[i] - '0']++;
    for (int i = (1); i < (10); ++i) {
      int j = 10 - i;
      if (!((i == j && a[i] > 1) || (a[i] && a[j]))) continue;
      vector<int> b(a), c(a);
      int cnt = i + j == 10;
      r = 0;
      b[i]--;
      c[j]--;
      p[r] = make_pair(i, 1);
      q[r++] = make_pair(j, 1);
      for (int k = (0); k < ((10)); ++k)
        if (b[k] && c[9 - k]) {
          int t = min(b[k], c[9 - k]);
          b[k] -= t;
          c[9 - k] -= t;
          p[r] = make_pair(k, t);
          q[r++] = make_pair(9 - k, t);
          cnt += t;
        }
      int z = min(b[0], c[0]);
      cnt += z;
      b[0] -= z;
      c[0] -= z;
      if (maxi < cnt) {
        maxi = cnt;
        ostringstream os1, os2;
        for (int k = (0); k < ((z)); ++k) {
          os1 << 0;
          os2 << 0;
        }
        for (int k = (0); k < ((r)); ++k)
          for (int l = (0); l < ((p[k].second)); ++l) {
            os1 << p[k].first;
            os2 << q[k].first;
          }
        for (int k = (0); k < ((10)); ++k) {
          for (int l = (0); l < ((b[k])); ++l) os1 << k;
          for (int l = (0); l < ((c[k])); ++l) os2 << k;
        }
        res1 = os1.str();
        reverse((res1).begin(), (res1).end());
        res2 = os2.str();
        reverse((res2).begin(), (res2).end());
      }
    }
    if (maxi == 0) {
      sort((s).rbegin(), (s).rend());
      res1 = res2 = s;
    }
    cout << res1 << '\n' << res2 << endl;
  }
  return 0;
}
