#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << "\033[33;0m" << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <typename T>
void debug_out(T a[], int n) {
  cerr << "{" << to_string(a[0]);
  for (int i = 1; i < n; ++i) cerr << ", " << to_string(a[i]);
  cerr << "}";
  debug_out();
}
using LL = long long;
using PII = pair<int, int>;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
LL powmod(LL a, LL b, LL MOD) {
  LL ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % MOD;
    b >>= 1;
    a = a * a % MOD;
  }
  return ans % MOD;
}
const int N = 100005, MOD = 1e9 + 7, INF = 1e9;
string s, ansS, ansT;
int cnt1[10], cnt2[10], cnt[10];
void init() {
  cin >> s;
  for (int i = 0; i < ((int)(s.size())); ++i) cnt[s[i] - '0']++;
}
void work() {
  for (int i = 0; i < 10; ++i) cnt1[i] = cnt2[i] = cnt[i];
  int Sum = 0, S;
  for (int i = 0; i < 10; ++i) {
    while (cnt1[i]) --cnt1[i], ansS.push_back(i + '0');
    while (cnt2[i]) --cnt2[i], ansT.push_back(i + '0');
  }
  for (int ed = 1; ed <= 9; ++ed) {
    int p1 = ed, p2 = (10 - p1) % 10;
    S = 0;
    string nowS, nowT;
    for (int i = 0; i < 10; ++i) cnt1[i] = cnt2[i] = cnt[i];
    if (cnt1[p1] and cnt2[p2]) {
      nowS.push_back(p1 + '0');
      nowT.push_back(p2 + '0');
      cnt1[p1]--;
      cnt2[p2]--;
      ++S;
    } else {
      continue;
    }
    for (int d = 0; d <= 9; ++d) {
      p1 = d, p2 = (9 - d);
      while (cnt1[p1] and cnt2[p2]) {
        nowS.push_back(p1 + '0');
        nowT.push_back(p2 + '0');
        cnt1[p1]--;
        cnt2[p2]--;
        ++S;
      }
      swap(p1, p2);
      while (cnt1[p1] and cnt2[p2]) {
        nowS.push_back(p1 + '0');
        nowT.push_back(p2 + '0');
        cnt1[p1]--;
        cnt2[p2]--;
        ++S;
      }
    }
    for (int i = 0; i < 10; ++i) {
      while (cnt1[i]) --cnt1[i], nowS.push_back(i + '0');
      while (cnt2[i]) --cnt2[i], nowT.push_back(i + '0');
    }
    if (S > Sum) ansS = nowS, ansT = nowT, Sum = S;
  }
  S = 0;
  int qwq = -1, id = -1, Max = 0;
  cerr << "\033[33;1m"
       << "["
       << "cnt, 10"
       << "] : ",
      debug_out(cnt, 10);
  for (int i = 1; i <= 9; ++i) {
    S += min(cnt[i], cnt[9 - i]);
    if (cnt[i] > cnt[9 - i] and cnt[10 - i] > cnt[9 - (10 - i)] and i != 1)
      qwq = i;
    else if (cnt[9 - i] > cnt[i] and
             cnt[10 - (9 - i)] > cnt[9 - (10 - (9 - i))])
      qwq = 9 - i;
  }
  if (cnt[5] > cnt[4]) qwq = 5;
  if (qwq == -1) {
    for (int i = 1; i <= 4; ++i) {
      if (cnt[i] > cnt[9 - i] and cnt[10 - i])
        qwq = i;
      else if (cnt[9 - i] > cnt[i] and cnt[10 - (9 - i)])
        qwq = 9 - i;
    }
    if (qwq != -1) S--;
  }
  for (int p = 1; p <= cnt[0]; ++p) {
    int now = S;
    if (qwq != -1) {
      now = now + p + min(cnt[9], cnt[0] - p) + 1;
    } else {
      now = now + p + min(cnt[9], cnt[0] - p);
    }
    if (now > Max) Max = now, id = p;
  }
  cerr << "\033[33;1m"
       << "["
       << "S"
       << "] : ",
      debug_out(S);
  cerr << "\033[33;1m"
       << "["
       << "qwq"
       << "] : ",
      debug_out(qwq);
  if (Max > Sum and qwq != -1) {
    string nowS, nowT;
    for (int i = 0; i < 10; ++i) cnt1[i] = cnt2[i] = cnt[i];
    for (int d = 1; d <= id; ++d) {
      nowS.push_back('0');
      nowT.push_back('0');
      cnt1[0]--, cnt2[0]--;
    }
    if (qwq != -1) {
      assert(qwq != 0);
      assert(qwq != 9);
      assert(qwq != 10);
      nowS.push_back(qwq + '0');
      nowT.push_back(10 - qwq + '0');
      cnt1[qwq]--, cnt2[10 - qwq]--;
    }
    for (int d = 0; d <= 9; ++d) {
      int p1 = d, p2 = (9 - d);
      while (cnt1[p1] and cnt2[p2]) {
        nowS.push_back(p1 + '0');
        nowT.push_back(p2 + '0');
        cnt1[p1]--;
        cnt2[p2]--;
        ++S;
      }
      swap(p1, p2);
      while (cnt1[p1] and cnt2[p2]) {
        nowS.push_back(p1 + '0');
        nowT.push_back(p2 + '0');
        cnt1[p1]--;
        cnt2[p2]--;
        ++S;
      }
    }
    for (int i = 0; i < 10; ++i) {
      while (cnt1[i]) --cnt1[i], nowS.push_back(i + '0');
      while (cnt2[i]) --cnt2[i], nowT.push_back(i + '0');
    }
    ansS = nowS, ansT = nowT;
    Sum = Max;
  }
  cerr << "\033[33;1m"
       << "["
       << "Max"
       << "] : ",
      debug_out(Max);
  reverse(ansS.begin(), ansS.end());
  reverse(ansT.begin(), ansT.end());
  cout << ansS << "\n" << ansT << endl;
}
int main() {
  time_t tic = clock();
  int T = 1;
  while (T--) {
    init();
    work();
  }
  time_t toc = clock();
  cerr << "execute time = " << (toc - tic) / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
