#include <bits/stdc++.h>
const int Inf = 1e9;
long long LINF = (long long)4e18;
using namespace std;
long long mod = 1e9 + 7;
string s;
vector<int> cnt1(10, 0), cnt2(10, 0);
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  for (int(i) = 0; (i) < s.length(); (i)++) cnt1[s[i] - '0']++;
  cnt2 = cnt1;
  int n = s.length();
  int ost = 0;
  string ans1 = "", ans2 = "";
  int MX = -1, d1, cntz, D1;
  for (int(k) = 0; (k) < cnt1[0] + 1; (k)++) {
    cnt1[0] -= k;
    cnt2[0] -= k;
    int mx = -1;
    for (int(i) = 1; (i) < 10; (i)++) {
      if (min(cnt1[i], cnt2[10 - i]) > 0) {
        cnt1[i]--;
        cnt2[10 - i]--;
        int sum = k;
        for (int(j) = 0; (j) < 10; (j)++) {
          sum += min(cnt1[j], cnt2[9 - j]);
        }
        if (sum > mx) {
          mx = sum;
          d1 = i;
        }
        cnt1[i]++;
        cnt2[10 - i]++;
      }
    }
    cnt1[0] += k;
    cnt2[0] += k;
    if (mx > MX) {
      cntz = k;
      MX = mx;
      D1 = d1;
    }
  }
  if (MX == -1) {
    if (cnt1[0]) {
      for (int(i) = 0; (i) < cnt1[0]; (i)++) {
        ans1.push_back('0');
        ans2.push_back('0');
      }
      cnt1[0] = 0;
      cnt2[0] = 0;
      for (int(i) = 0; (i) < 10; (i)++) {
        for (int(j) = 0; (j) < cnt1[i]; (j)++) ans1.push_back('0' + i);
        for (int(j) = 0; (j) < cnt2[i]; (j)++) ans2.push_back('0' + i);
      }
      reverse((ans1).begin(), (ans1).end());
      reverse((ans2).begin(), (ans2).end());
      cout << ans1 << endl << ans2;
    } else
      cout << s << endl << s;
    return 0;
  } else {
    for (int(i) = 0; (i) < cntz; (i)++) {
      ans1.push_back('0');
      ans2.push_back('0');
    }
    cnt1[0] -= cntz;
    cnt2[0] -= cntz;
    ans1.push_back('0' + D1);
    ans2.push_back('0' + (10 - D1));
    cnt1[D1]--;
    cnt2[10 - D1]--;
    for (int(j) = 0; (j) < 10; (j)++) {
      int lol = min(cnt1[j], cnt2[9 - j]);
      for (int(k) = 0; (k) < lol; (k)++) {
        ans1.push_back('0' + j);
        ans2.push_back('0' + (9 - j));
        cnt1[j]--;
        cnt2[9 - j]--;
      }
    }
    for (int(i) = 0; (i) < 10; (i)++) {
      for (int(j) = 0; (j) < cnt1[i]; (j)++) ans1.push_back('0' + i);
      for (int(j) = 0; (j) < cnt2[i]; (j)++) ans2.push_back('0' + i);
    }
  }
  reverse((ans1).begin(), (ans1).end());
  reverse((ans2).begin(), (ans2).end());
  cout << ans1 << endl << ans2;
  return 0;
}
