#include <bits/stdc++.h>
using namespace std;
int nr1[11], nr2[11], maxi;
string s;
vector<int> s1, s2;
struct date {
  int n0, n1, n2;
} ans;
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++) nr1[s[i] - '0']++, nr2[s[i] - '0']++;
  ans.n1 = ans.n2 = -1;
  for (int nr0 = 0; nr0 <= nr1[0]; nr0++) {
    int sol = nr0;
    nr1[0] -= nr0;
    nr2[0] -= nr0;
    for (int lc1 = 1; lc1 <= 9; lc1++) {
      int lc2 = 10 - lc1;
      if (nr1[lc1] && nr2[lc2]) {
        nr1[lc1]--;
        nr2[lc2]--;
        sol++;
        int sol1 = 0;
        for (int i = 0; i <= 9; i++) sol1 = sol1 + min(nr1[i], nr2[9 - i]);
        if (sol + sol1 > maxi)
          maxi = sol + sol1, ans.n0 = nr0, ans.n1 = lc1, ans.n2 = lc2;
        sol--;
        nr1[lc1]++;
        nr2[lc2]++;
      }
    }
    if (sol > maxi) maxi = sol, ans.n0 = nr0, ans.n1 = -1, ans.n2 = -1;
    nr1[0] += nr0;
    nr2[0] += nr0;
  }
  nr1[0] -= ans.n0;
  nr2[0] -= ans.n0;
  for (int i = 1; i <= ans.n0; i++) {
    s1.push_back(0);
    s2.push_back(0);
  }
  if (ans.n1 > 0 && ans.n2 > 0) {
    nr1[ans.n1]--;
    nr2[ans.n2]--;
    s1.push_back(ans.n1);
    s2.push_back(ans.n2);
  }
  for (int i = 0; i <= 9; i++) {
    int val = min(nr1[i], nr2[9 - i]);
    for (int j = 1; j <= val; j++) {
      nr1[i]--;
      nr2[9 - i]--;
      s1.push_back(i);
      s2.push_back(9 - i);
    }
  }
  for (int i = 0; i <= 9; i++) {
    for (int j = 1; j <= nr1[i]; j++) s1.push_back(i);
    for (int j = 1; j <= nr2[i]; j++) s2.push_back(i);
  }
  for (int i = s1.size() - 1; i >= 0; i--) cout << s1[i];
  cout << '\n';
  for (int i = s2.size() - 1; i >= 0; i--) cout << s2[i];
  cout << '\n';
  return 0;
}
