#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
char s[N];
int a[N];
vector<int> v;
int cnt[20], cnt2[20];
int solve(int x) {
  if (!cnt[x] || !cnt2[10 - x]) return 0;
  cnt[x]--;
  cnt2[10 - x]--;
  int res = 1;
  for (int i = 0; i <= 9; ++i) {
    res += min(cnt[i], cnt2[9 - i]);
  }
  res += min(cnt[0], cnt2[0]);
  cnt2[10 - x]++;
  cnt[x]++;
  return res;
}
void go(int x) {
  deque<int> q1, q2;
  if (cnt[x] > 0 && cnt2[10 - x] > 0) {
    cnt[x]--;
    cnt2[10 - x]--;
    q1.push_back(x);
    q2.push_back(10 - x);
    for (int i = 0; i <= 9; ++i) {
      int mn = min(cnt[i], cnt2[9 - i]);
      for (int j = 0; j < mn; ++j) {
        q1.push_front(i);
        q2.push_front(9 - i);
      }
      cnt[i] -= mn;
      cnt2[9 - i] -= mn;
    }
  }
  int mn = min(cnt[0], cnt2[0]);
  for (int j = 0; j < mn; ++j) {
    q1.push_back(0);
    q2.push_back(0);
  }
  cnt[0] -= mn;
  cnt2[0] -= mn;
  for (int i = 0; i <= 9; ++i) {
    while (cnt[i]--) {
      q1.push_front(i);
    }
    while (cnt2[i]--) {
      q2.push_front(i);
    }
  }
  for (auto d : q1) {
    printf("%d", d);
  }
  puts("");
  for (auto d : q2) {
    printf("%d", d);
  }
  puts("");
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
  }
  for (int i = 0; i < n; ++i) {
    cnt[a[i]]++;
  }
  for (int i = 0; i < 10; ++i) {
    cnt2[i] = cnt[i];
  }
  int ans = -1;
  int who = -1;
  for (int i = 1; i <= 9; ++i) {
    int tmp = solve(i);
    if (ans < tmp) {
      who = i;
      ans = tmp;
    }
  }
  go(who);
  return 0;
}
