#include <bits/stdc++.h>
using namespace std;
int num1[10][100010], num2[10][100010];
int ansnum1[100010], ansnum2[100010], lastnum1[100010], lastnum2[100010];
string str;
int max_match() {
  int anssum = 0;
  int ansid = -1;
  for (int i = 0; i <= 9; ++i) {
    int maxm = 0;
    if (!num1[i][i] || !num2[i][10 - i]) continue;
    num1[i][i]--;
    num2[i][10 - i]--;
    maxm++;
    for (int j = 0; j <= 9; ++j) {
      if (!num1[i][j] || !num2[i][9 - j]) continue;
      int minn = min(num1[i][j], num2[i][9 - j]);
      num1[i][j] -= minn;
      num2[i][9 - j] -= minn;
      maxm += minn;
    }
    maxm += min(num1[i][0], num2[i][0]);
    if (anssum < maxm) {
      anssum = maxm;
      ansid = i;
    }
  }
  int maxm = min(num1[0][0], num2[0][0]);
  if (anssum < maxm) {
    anssum = maxm;
    ansid = 0;
  }
  return ansid;
}
int main() {
  while (cin >> str) {
    int len = str.length();
    memset(num1, 0, sizeof(num1));
    memset(num2, 0, sizeof(num2));
    memset(ansnum1, 0, sizeof(ansnum1));
    memset(ansnum2, 0, sizeof(ansnum2));
    memset(lastnum1, 0, sizeof(lastnum1));
    memset(lastnum2, 0, sizeof(lastnum2));
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j < len; ++j) {
        int temp = str[j] - '0';
        num1[i][temp]++;
        num2[i][temp]++;
      }
    }
    for (int i = 0; i < len; ++i) {
      int temp = str[i] - '0';
      ansnum1[temp]++;
      ansnum2[temp]++;
      lastnum1[temp]++;
      lastnum2[temp]++;
    }
    int last_num = max_match();
    if (last_num == -1) {
      cout << str << endl << str << endl;
      continue;
    }
    string ans1, ans2;
    ans1.resize(len), ans2.resize(len);
    if (last_num == 0) {
      int cnt = len - 1;
      for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j < ansnum1[i]; j++) {
          ans1[cnt] = i + '0';
          ans2[cnt--] = i + '0';
        }
      }
      cout << ans1 << endl << ans2 << endl;
      continue;
    }
    ansnum1[last_num]--;
    ansnum2[10 - last_num]--;
    for (int i = 0; i <= 9; ++i) {
      if (!ansnum1[i] || !ansnum2[9 - i]) continue;
      int minn = min(ansnum1[i], ansnum2[9 - i]);
      ansnum1[i] -= minn;
      ansnum2[9 - i] -= minn;
    }
    int minn = min(ansnum1[0], ansnum2[0]);
    int cnt = len - 1;
    lastnum1[0] -= minn;
    lastnum2[0] -= minn;
    for (int i = 0; i < minn; ++i) {
      ans1[cnt] = 0 + '0';
      ans2[cnt--] = 0 + '0';
    }
    ans1[cnt] = last_num + '0';
    ans2[cnt--] = 10 - last_num + '0';
    lastnum1[last_num] -= 1;
    lastnum2[10 - last_num] -= 1;
    for (int i = 0; i <= 9; ++i) {
      if (!lastnum1[i] || !lastnum2[9 - i]) continue;
      int minn = min(lastnum1[i], lastnum2[9 - i]);
      for (int j = 0; j < minn; ++j) {
        ans1[cnt] = i + '0';
        ans2[cnt--] = 9 - i + '0';
      }
      lastnum1[i] -= minn;
      lastnum2[9 - i] -= minn;
    }
    int cnt1 = cnt;
    int cnt2 = cnt;
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j < lastnum1[i]; ++j) {
        ans1[cnt1--] = i + '0';
      }
    }
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j < lastnum2[i]; ++j) {
        ans2[cnt2--] = i + '0';
      }
    }
    cout << ans1 << endl << ans2 << endl;
  }
  return 0;
}
