#define LOCAL

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define _TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a+s_;i!=b_;i+=s_)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)

#define Display(A, n, m) {           \
	REP(i, n){		                          \
        REP(j, m) cout << A[i][j] << " ";\
		cout << endl;				\
	}						\
}

#define Display_1(A, n, m) {				\
	REP_1(i, n){		\
        REP_1(j, m) cout << A[i][j] << " ";\
		cout << endl;				\
	}						\
}

#pragma comment(linker, "/STACK:36777216")

typedef long long LL;
typedef double DB;
typedef long double LDB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef pair<DB, int> PDI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline int RD(){int x; return _RD(x);}
inline void RF(DB &x){scanf("%lf", &x);}
inline DB _RF(DB &x){scanf("%lf", &x); return x;}
inline DB RF(){ DB x; return _RF(x);}
inline void RC(char &c){scanf(" %c", &c);}
inline char _RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){ char c; return _RC(c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}

template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const LL INF_64 = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-8;
const DB OO = 1e15;
const DB PI = acos(-1.0); //M_PI;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}

template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(min(a, b), max(c, d));}
template<class T, class C> inline T min_cp(T a, T b, C cp){return min(a, b, cp);}
template<class T, class C> inline T min_cp(T a, T b, T c, C cp){return min_cp(min_cp(a, b, cp), c, cp);}
template<class T, class C> inline T min_cp(T a, T b, T c, T d, C cp){return min_cp(min_cp(a, b, cp), min_cp(c, d, cp), cp);}
template<class T, class C> inline T max_cp(T a, T b, C cp){return max(a, b, cp);}
template<class T, class C> inline T max_cp(T a, T b, T c, C cp){return max_cp(max_cp(a, b, cp), c, cp);}
template<class T, class C> inline T max_cp(T a, T b, T c, T d, C cp){return max_cp(max_cp(a, b, cp), max_cp(c, d, cp), cp);}

template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,
inline bool _1(int x, int i){return x & 1<<i;}
inline bool _1(LL x, int i){return x & 1LL<<i;}
inline LL _1(int i){return 1LL<<i;}
//inline int _1(int i){return 1<<i;}
inline LL _U(int i){return _1(i) - 1;};
//inline int _U(int i){return _1(i) - 1;};

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

template<class T> inline T cover_bit(T x){
    T p = 1; while (p < x) p <<= 1;
    return p;
}

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

inline int count_bits(LL x){
    x = (x & 0x5555555555555555LL) + ((x & 0xaaaaaaaaaaaaaaaaLL) >> 1);
    x = (x & 0x3333333333333333LL) + ((x & 0xccccccccccccccccLL) >> 2);
    x = (x & 0x0f0f0f0f0f0f0f0fLL) + ((x & 0xf0f0f0f0f0f0f0f0LL) >> 4);
    x = (x & 0x00ff00ff00ff00ffLL) + ((x & 0xff00ff00ff00ff00LL) >> 8);
    x = (x & 0x0000ffff0000ffffLL) + ((x & 0xffff0000ffff0000LL) >> 16);
    x = (x & 0x00000000ffffffffLL) + ((x & 0xffffffff00000000LL) >> 32);
    return x;
}

int reverse_bits(int x){
    x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
    x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
    x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
    x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
    x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);
    return x;
}

LL reverse_bits(LL x){
    x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);
    x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);
    x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);
    x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);
    x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);
    x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);
    return x;
}

#ifndef BIGNUM_H_INCLUDED
#define BIGNUM_H_INCLUDED
#include <iostream>
#include <sstream>
#include <list>
using namespace std;

class bignum{
          friend istream& operator>>(istream&, bignum&);
          friend ostream& operator<<(ostream&, const bignum&);
          friend bignum operator +(const bignum&, const bignum&);
          friend bignum operator -(const bignum&, const bignum&);
          friend bignum operator *(const bignum&, const bignum&);
          friend bignum operator /(const bignum&, const bignum&);
          friend bignum operator %(const bignum&, const bignum&);
          friend bignum operator +(const bignum&, const int&);
          friend bignum operator -(const bignum&, const int&);
          friend bignum operator *(const bignum&, const int&);
          friend bignum operator /(const bignum&, const int&);
          friend bignum operator %(const bignum&, const int&);
          friend bool operator ==(const bignum&, const bignum&);
          friend bool operator !=(const bignum&, const bignum&);
          friend bool operator <(const bignum&, const bignum&);
          friend bool operator >(const bignum&, const bignum&);
          friend bool operator <=(const bignum&, const bignum&);
          friend bool operator >=(const bignum&, const bignum&);
          friend bool operator ==(const bignum&, const int&);
          friend bool operator !=(const bignum&, const int&);
          friend bool operator <(const bignum&, const int&);
          friend bool operator >(const bignum&, const int&);
          friend bool operator <=(const bignum&, const int&);
          friend bool operator >=(const bignum&, const int&);
          friend int do_comp(const bignum&, const int&);
          friend int do_comp(const bignum&, const bignum&);
          friend void divide(const bignum&, const bignum&, bignum&, bignum&);
          friend bignum pow(bignum, int);
    public:
        inline bignum(){};
        inline bignum(int s){
            while (s!=0){
                data.push_back(s%100000000); s/=100000000;
            }
            if (data.empty()) data.push_back(0);
        }
    inline bignum(long long s){
        while (s!=0){
            data.push_back(int(s%100000000)); s/=100000000;
        }
        if (data.empty()) data.push_back(0);
    }
        inline bignum(string s){
            int t, i; data.clear();
            for (i=int(s.size())-8;i>0;i-=8){
                istringstream(s.substr(i, 8)) >> t;
                data.push_back(t);
            }
            istringstream(s.substr(0, i+8)) >> t;
            data.push_back(t);
        }
        void operator =(const int);
        void operator =(const string);
        void operator =(const bignum);
        bignum& operator +=(const bignum&);
        bignum& operator -=(const bignum&);
        bignum& operator *=(const bignum&);
        bignum& operator /=(const bignum&);
        bignum& operator %=(const bignum&);
        bignum& operator +=(const int&);
        bignum& operator -=(const int&);
        bignum& operator *=(const int&);
        bignum& operator /=(const int&);
        bignum& operator %=(const int&);
        bignum& operator %=(const LL&);
        bool undefined();
        int do_try(const int&);
        int do_try(const bignum&);
        void do_trim();
        list<int> data;

    void add (const int a){
        list<int>::iterator it = data.end();
        it --;
        if ( (*it) < 10 ) (*it) = a ;
        else if ( (*it) < 100 ) (*it) = (*it) % 10 + 10*a ;
        else if ( (*it) < 1000 ) (*it) = (*it) % 100 + 100*a ;
        else if ( (*it) < 10000 ) (*it) = (*it) % 1000 + 1000*a ;
        else if ( (*it) < 100000 ) (*it) = (*it) % 10000 + 10000*a ;
        else if ( (*it) < 1000000 ) (*it) = (*it) % 100000 + 100000*a ;
        else if ( (*it) < 10000000 ) (*it) = (*it) % 1000000 + 1000000*a ;
        else if ( (*it) < 100000000 ) (*it) = (*it) % 10000000 + 10000000*a ;

        /*
        list<int>::iterator it = data.end();
        it --;

        if (*it >= 10000) {
            if ( (*it) >= 1000000) {if (*it >=10000000) data.push_back(a); else (*it) += a * 10000000;}
            else {if ((*it) >= 100000) (*it) += a * 1000000; else (*it) += a * 100000;}
        }
        else
            if ( (*it) >= 100) {if (*it >=1000) (*it) += a * 10000; else (*it) += a * 1000;}
            else {if ((*it) >= 10) (*it) += a * 100; else (*it) += a * 10;} */
    }

    void clear(){
        data.clear();
    }

    LL t(){
        if (data.size() == 1) return *data.begin();
        else {
            list<int>::iterator it = data.begin(), jt = data.begin(); ++it;
            return (LL)(*it) * 100000000 + (*jt);
        }
    }

    int size(){
        list<int>::iterator it; int res = 0;
        for (it=data.begin(); it!=data.end();it++)
            res += 8;
        it--;
        if (*it >= 10000) {
            if ( (*it) >= 1000000) {if (*it >=10000000) ; else res--;}
            else {if ((*it) >= 100000) res-=2; else res-=3;}
        }
        else
            if ( (*it) >= 100) {if (*it >=1000) res-=4; else res-=5;}
            else {if ((*it) >= 10) res-=6; else res-=7;}

        return res;
    }

    void do_reserve(int a){
        if (a <= 0) return;
        list<int>::iterator it;
        for (it=data.begin(); it!=data.end() && a>0; it++) a-=8;
        if (it == data.end() && a>=0) return;
        a+=8, it--; int f = 1;
        for (int i=0;i<a;i++) f *= 10; (*it) %= f;
        data.erase(++it, data.end());
        do_trim();
    }

    void output(){
        list<int>::reverse_iterator i=data.rbegin();
        printf("%d", *i); for (i++;i!=data.rend();i++)
            printf("%08d", *i);
    }
};

inline void bignum::operator =(const bignum a){
    data.clear();
    for (list<int>::const_iterator i=a.data.begin();i!=a.data.end();i++){
        data.push_back(*i);
    }
}
inline void bignum::operator =(const string a){
    (*this) = bignum(a);
}
inline void bignum::operator =(const int a){
    (*this) = bignum(a);
}

inline istream& operator>>(istream& input, bignum& a){
    string s; int t, i; input >> s; a.data.clear();
    for (i=int(s.size())-8;i>0;i-=8){
        istringstream(s.substr(i, 8)) >> t;
        a.data.push_back(t);
    }
    istringstream(s.substr(0, i+8)) >> t;
    a.data.push_back(t);
    return input;
}

inline ostream& operator<<(ostream& output, const bignum& a){
    list<int>::const_reverse_iterator i=a.data.rbegin();
    output << *i;
    for (i++;i!=a.data.rend();i++){
        if (*i >= 10000) {
            if (*i >= 1000000) {if (*i>=10000000) cout << *i; else cout << 0 << *i;}
            else {if (*i>=100000) cout << "00" << *i; else cout << "000" << *i;}
        }
        else {
            if (*i >= 100) {if (*i>=1000)  cout << "0000" << *i; else cout << "00000" << *i;}
            else { if (*i>=10) cout << "000000" << *i; else cout << "0000000" << *i;}
        }
    }
    return output;
}

inline bool bignum::undefined(){
    return data.empty();
}

inline int do_comp(const bignum& a, const bignum& b){
    if (a.data.size()<b.data.size()) return -1; if (a.data.size()>b.data.size()) return 1;
    list<int>::const_reverse_iterator i; list<int>::const_reverse_iterator j;
    for (i=a.data.rbegin(),j=b.data.rbegin(); j!=b.data.rend(); i++,j++){
        if (*i<*j) return -1;              //!!!!
        if (*i>*j) return 1;
    }
    return 0;
}
inline int do_comp(const bignum& a, const int& b){
    return do_comp(a, bignum(b));
}

inline bool operator ==(const bignum& a, const bignum& b){
    return do_comp(a, b) == 0;
}
inline bool operator !=(const bignum& a, const bignum& b){
    return do_comp(a, b) != 0;
}
inline bool operator <(const bignum& a, const bignum& b){
    return do_comp(a, b) == -1;
}
inline bool operator >(const bignum& a, const bignum& b){
    return do_comp(a, b) == 1;
}
inline bool operator <=(const bignum& a, const bignum& b){
    return do_comp(a, b) != 1;
}
inline bool operator >=(const bignum& a, const bignum& b){
    return do_comp(a, b) != -1;
}

inline bool operator ==(const bignum& a, const int& b){
    return do_comp(a, b) == 0;
}
inline bool operator !=(const bignum& a, const int& b){
    return do_comp(a, b) != 0;
}
inline bool operator <(const bignum& a, const int& b){
    return do_comp(a, b) == -1;
}
inline bool operator >(const bignum& a, const int& b){
    return do_comp(a, b) == 1;
}
inline bool operator <=(const bignum& a, const int& b){
    return do_comp(a, b) != 1;
}
inline bool operator >=(const bignum& a, const int& b){
    return do_comp(a, b) != -1;
}

inline void bignum::do_trim(){
    while (data.size()>1&&data.back()==0) data.pop_back();
}

inline bignum& bignum::operator +=(const bignum& a){
    list<int>::iterator i; list<int>::const_iterator j; int t = 0;
    for (i=data.begin(),j=a.data.begin(); i!=data.end()&&j!=a.data.end(); i++,j++){
        *i+=*j+t; t=*i/100000000; *i%=100000000;
    }
    while (i!=data.end()) {*i+=t; t=*i/100000000; *i%=100000000; i++;}
    while (j!=a.data.end()) {data.push_back(t+*j); t=data.back()/100000000; data.back()%=100000000; j++;}
    if (t!=0) data.push_back(t);
    return *this;
}

inline bignum& bignum::operator -=(const bignum& a){
    list<int>::iterator i; list<int>::const_iterator j; int t = 0;
    for (i=data.begin(),j=a.data.begin(); j!=a.data.end(); i++,j++){
        *i -= t+*j; if (*i>=0) t=0; else *i+=100000000, t=1;
    }
    while (i!=data.end()) {*i-=t; if (*i>=0) t=0;else *i+=100000000, t=1; i++;}
    (*this).do_trim();
    return *this;
}

inline bignum& bignum::operator +=(const int& a){
    return (*this)+=bignum(a);
}

inline bignum& bignum::operator -=(const int& a){
    return (*this)-=bignum(a);
}

inline bignum operator +(const bignum& a, const bignum& b){
    list<int>::const_iterator i, j; bignum c; int t = 0;
    for (i=a.data.begin(),j=b.data.begin(); i!=a.data.end()&&j!=b.data.end(); i++,j++){
        c.data.push_back(t+*i+*j);
        t=c.data.back()/100000000; c.data.back()%=100000000;
    }
    while (i!=a.data.end()) {c.data.push_back(t+*i); t=c.data.back()/100000000; c.data.back()%=100000000; i++;}
    while (j!=b.data.end()) {c.data.push_back(t+*j); t=c.data.back()/100000000; c.data.back()%=100000000; j++;}
    if (t!=0) c.data.push_back(t);
    return c;
}

inline bignum operator -(const bignum& a, const bignum& b){
    list<int>::const_iterator i, j; bignum c; int t = 0;
    for (i=a.data.begin(),j=b.data.begin(); j!=b.data.end(); i++,j++){
        t = *i - t;
        if (t>=*j) c.data.push_back(t-*j), t=0;
        else c.data.push_back(t+100000000-*j), t=1;
    }
    while (i!=a.data.end()) {t=*i-t; if (t>=0) c.data.push_back(t), t=0;else c.data.push_back(t+100000000), t=1; i++;}
    c.do_trim();
    return c;
}

inline bignum operator *(const bignum& a, const bignum& b){
    list<int>::const_iterator i, j; list<int>::iterator k, kk; bignum c; long long t = 0;

    for (int i=0;i<a.data.size()+b.data.size();i++) c.data.push_back(0);
    for (i=a.data.begin(),k=c.data.begin(); i!=a.data.end(); i++,k++){
        for (j=b.data.begin(),kk=k; j!=b.data.end(); j++,kk++){
            t+=(long long)(*i)*(*j)+(*kk);
            *kk=int(t%100000000); t/=100000000;
        }
        *kk+=t; t=0;
    }
    c.do_trim();
    return c;
}

inline int bignum::do_try(const bignum& a){
    int l = 1, r = 99999999, m, t;
    while (l+2<r){
        m = (l + r) / 2;
        t = do_comp(*this, a*bignum(m));
        if (t==0) return m;
        if (t<0) r = m - 1;
        else l = m;
    }
    while (do_comp(*this, a*bignum(r))<0) r--;
    return r;
}

inline void divide(const bignum& a, const bignum& b, bignum& d, bignum& r){
    list<int>::const_reverse_iterator i = a.data.rbegin(); int t;
    d = bignum(0); r = bignum(0);
    do {
        while (r<b&&i!=a.data.rend()){d.data.push_front(0);r.data.push_front(*i);r.do_trim();i++;}
        if (r>=b){
            t = r.do_try(b); d.data.front() = t;
            r-=(b*bignum(t));
        }
    } while (i!=a.data.rend());
    d.do_trim();
}

inline bignum operator /(const bignum& a, const bignum& b){
    bignum d, r;
    divide(a, b, d, r);
    return d;
}

inline bignum operator %(const bignum& a, const bignum& b){
    bignum d, r;
    divide(a, b, d, r);
    return r;
}

inline bignum operator +(const bignum& a, const int& b){
    return a+bignum(b);
}

inline bignum operator -(const bignum& a, const int& b){
    return a-bignum(b);
}

inline bignum operator *(const bignum& a, const int& b){
    return a*bignum(b);
}

inline bignum operator /(const bignum& a, const int& b){
    return a/bignum(b);
}

inline bignum& bignum::operator *=(const bignum& a){
    (*this) = (*this) * a;
    return *this;
}

inline bignum& bignum::operator /=(const bignum& a){
    (*this) = (*this) / a;
    return *this;
}

inline bignum& bignum::operator %=(const bignum& a){
    (*this) = (*this) % a;
    return *this;
}

inline bignum& bignum::operator *=(const int& a){
    return (*this)*=bignum(a);
}

inline bignum& bignum::operator /=(const int& a){
    return (*this)/=bignum(a);
}

inline bignum& bignum::operator %=(const LL& b){
    return (*this)%=bignum(b);
}

inline bignum pow(bignum a,int b){
    bignum c(1);
    while (b!=0) {
        if (b&1) c *= a;
        a = a * a; b >>= 1;
    }
    return c;
}

#endif // BIGNUM_H_INCLUDED

// <<= ' A. Random Event ..

inline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}
inline int random32(int l, int r){return rand32() % (r - l + 1) + l;}
inline int random(int l, int r){return rand() % (r - l + 1) + l;}
int dice(){return rand() % 6;}
bool coin(){return rand() % 2;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

template<class T> inline void OT(const T &x){
    printf("%d\n", x);
}

/* .................................................................................................................................. */
string str,a,b , temp;
int cntA[10] , A[10] , B[10], cntB[10];
int gao(int x){
    int ret = 0;
    a = ""; b = "";
    if (cntA[x] == 0 || cntA[10 - x] == 0){
        while (cntA[0]){
            cntA[0] --;
            a += '0';
            b += '0';
        }
        for (int i = 1; i <= 9 ; ++i){
            for (int j = 0 ; j < cntA[i] ; ++j){
                a += i + '0';
                b += i + '0';
            }
        }
        return 0;
    }
    a += x + '0';
    b += 10 - x + '0';
    cntA[x] --;
    cntB[10 - x] --;
    ret++;
    const int orde[]={ 0 , 9 , 1 , 2 ,3 , 4 , 5 , 6 , 7 , 8};
    for (int ri = 0 ; ri <= 9 ; ++ri){
        int i = orde[ri];
        while (cntA[i] && cntB[ 9 - i ]){
            temp = i + '0';
            a = a + temp;
            temp = 9 - i + '0';
            b = b + temp;
            cntA[i] --;
            cntB[9-i] --;
            ret ++;
        }
    }
    //cout << cntA[0] << "DS" << cntB[0] << endl;
    int zhu = min(cntA[0] , cntB[0]);
    for (int i = 0 ; i < zhu;++i){
        cntA[0] -- ;
        cntB[0] -- ;
        a = '0' + a;
        b = '0' + b;
        ret ++;
    }
    int now = a.length() - 1;

    for (int i = 0; i <= 9 ; ++i){
        for (int j = 0 ; j < cntA[i] ; ++ j){
            temp = i + '0';
            a = a + temp;
        }
        for (int j = 0 ; j < cntB[i] ; ++j){
            temp = i + '0';
            b = b + temp;
        }
    }
    return ret;
}
void solve(){
    a = ""; b = "";
    int len = str.length();
    memset(cntA , 0 , sizeof(cntA));
    memset(cntB , 0 , sizeof(cntB));
    memset(A , 0 , sizeof(A));
    memset(B , 0 , sizeof(B));
    for (int i = 0 ; i < len ; ++i){
        ++A[ str[i] -'0' ] ;
        ++B[ str[i] - '0' ];
    }
    int ans = -1 , ansi = 1;
    for (int i = 1 ; i <= 5 ; ++i){
        for (int j = 0 ; j <= 9 ; ++j){
            cntA[j] = A[j];
            cntB[j] = B[j];
        }
        int res = gao(i);
        if (res > ans){
            ans = res;
            ansi = i;
        }
    }
    //cout << ansi << endl;
    for (int j = 0 ; j <= 9 ; ++j){
            cntA[j] = A[j];
            cntB[j] = B[j];
    }
    gao(ansi);

    for (int i = a.length() - 1; i>=0 ; --i)
        printf("%c",a[i]);

    printf("\n");

    for (int i = b.length() - 1; i>=0 ; --i)
        printf("%c",b[i]);

    printf("\n");
}
int main(){
    while (cin >> str) solve();

}

/*iadegeoaabilmmcetlfdbhtjiijlmemaqiecmkonldqphktgcq*/


#define LOCAL

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define _TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a+s_;i!=b_;i+=s_)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)

#define Display(A, n, m) {           \
	REP(i, n){		                          \
        REP(j, m) cout << A[i][j] << " ";\
		cout << endl;				\
	}						\
}

#define Display_1(A, n, m) {				\
	REP_1(i, n){		\
        REP_1(j, m) cout << A[i][j] << " ";\
		cout << endl;				\
	}						\
}

#pragma comment(linker, "/STACK:36777216")

typedef long long LL;
typedef double DB;
typedef long double LDB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef pair<DB, int> PDI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline int RD(){int x; return _RD(x);}
inline void RF(DB &x){scanf("%lf", &x);}
inline DB _RF(DB &x){scanf("%lf", &x); return x;}
inline DB RF(){ DB x; return _RF(x);}
inline void RC(char &c){scanf(" %c", &c);}
inline char _RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){ char c; return _RC(c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}

template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const LL INF_64 = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-8;
const DB OO = 1e15;
const DB PI = acos(-1.0); //M_PI;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}

template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(min(a, b), max(c, d));}
template<class T, class C> inline T min_cp(T a, T b, C cp){return min(a, b, cp);}
template<class T, class C> inline T min_cp(T a, T b, T c, C cp){return min_cp(min_cp(a, b, cp), c, cp);}
template<class T, class C> inline T min_cp(T a, T b, T c, T d, C cp){return min_cp(min_cp(a, b, cp), min_cp(c, d, cp), cp);}
template<class T, class C> inline T max_cp(T a, T b, C cp){return max(a, b, cp);}
template<class T, class C> inline T max_cp(T a, T b, T c, C cp){return max_cp(max_cp(a, b, cp), c, cp);}
template<class T, class C> inline T max_cp(T a, T b, T c, T d, C cp){return max_cp(max_cp(a, b, cp), max_cp(c, d, cp), cp);}

template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,
inline bool _1(int x, int i){return x & 1<<i;}
inline bool _1(LL x, int i){return x & 1LL<<i;}
inline LL _1(int i){return 1LL<<i;}
//inline int _1(int i){return 1<<i;}
inline LL _U(int i){return _1(i) - 1;};
//inline int _U(int i){return _1(i) - 1;};

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

template<class T> inline T cover_bit(T x){
    T p = 1; while (p < x) p <<= 1;
    return p;
}

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

inline int count_bits(LL x){
    x = (x & 0x5555555555555555LL) + ((x & 0xaaaaaaaaaaaaaaaaLL) >> 1);
    x = (x & 0x3333333333333333LL) + ((x & 0xccccccccccccccccLL) >> 2);
    x = (x & 0x0f0f0f0f0f0f0f0fLL) + ((x & 0xf0f0f0f0f0f0f0f0LL) >> 4);
    x = (x & 0x00ff00ff00ff00ffLL) + ((x & 0xff00ff00ff00ff00LL) >> 8);
    x = (x & 0x0000ffff0000ffffLL) + ((x & 0xffff0000ffff0000LL) >> 16);
    x = (x & 0x00000000ffffffffLL) + ((x & 0xffffffff00000000LL) >> 32);
    return x;
}

int reverse_bits(int x){
    x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
    x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
    x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
    x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
    x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);
    return x;
}

LL reverse_bits(LL x){
    x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);
    x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);
    x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);
    x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);
    x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);
    x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);
    return x;
}

#ifndef BIGNUM_H_INCLUDED
#define BIGNUM_H_INCLUDED
#include <iostream>
#include <sstream>
#include <list>
using namespace std;

class bignum{
          friend istream& operator>>(istream&, bignum&);
          friend ostream& operator<<(ostream&, const bignum&);
          friend bignum operator +(const bignum&, const bignum&);
          friend bignum operator -(const bignum&, const bignum&);
          friend bignum operator *(const bignum&, const bignum&);
          friend bignum operator /(const bignum&, const bignum&);
          friend bignum operator %(const bignum&, const bignum&);
          friend bignum operator +(const bignum&, const int&);
          friend bignum operator -(const bignum&, const int&);
          friend bignum operator *(const bignum&, const int&);
          friend bignum operator /(const bignum&, const int&);
          friend bignum operator %(const bignum&, const int&);
          friend bool operator ==(const bignum&, const bignum&);
          friend bool operator !=(const bignum&, const bignum&);
          friend bool operator <(const bignum&, const bignum&);
          friend bool operator >(const bignum&, const bignum&);
          friend bool operator <=(const bignum&, const bignum&);
          friend bool operator >=(const bignum&, const bignum&);
          friend bool operator ==(const bignum&, const int&);
          friend bool operator !=(const bignum&, const int&);
          friend bool operator <(const bignum&, const int&);
          friend bool operator >(const bignum&, const int&);
          friend bool operator <=(const bignum&, const int&);
          friend bool operator >=(const bignum&, const int&);
          friend int do_comp(const bignum&, const int&);
          friend int do_comp(const bignum&, const bignum&);
          friend void divide(const bignum&, const bignum&, bignum&, bignum&);
          friend bignum pow(bignum, int);
    public:
        inline bignum(){};
        inline bignum(int s){
            while (s!=0){
                data.push_back(s%100000000); s/=100000000;
            }
            if (data.empty()) data.push_back(0);
        }
    inline bignum(long long s){
        while (s!=0){
            data.push_back(int(s%100000000)); s/=100000000;
        }
        if (data.empty()) data.push_back(0);
    }
        inline bignum(string s){
            int t, i; data.clear();
            for (i=int(s.size())-8;i>0;i-=8){
                istringstream(s.substr(i, 8)) >> t;
                data.push_back(t);
            }
            istringstream(s.substr(0, i+8)) >> t;
            data.push_back(t);
        }
        void operator =(const int);
        void operator =(const string);
        void operator =(const bignum);
        bignum& operator +=(const bignum&);
        bignum& operator -=(const bignum&);
        bignum& operator *=(const bignum&);
        bignum& operator /=(const bignum&);
        bignum& operator %=(const bignum&);
        bignum& operator +=(const int&);
        bignum& operator -=(const int&);
        bignum& operator *=(const int&);
        bignum& operator /=(const int&);
        bignum& operator %=(const int&);
        bignum& operator %=(const LL&);
        bool undefined();
        int do_try(const int&);
        int do_try(const bignum&);
        void do_trim();
        list<int> data;

    void add (const int a){
        list<int>::iterator it = data.end();
        it --;
        if ( (*it) < 10 ) (*it) = a ;
        else if ( (*it) < 100 ) (*it) = (*it) % 10 + 10*a ;
        else if ( (*it) < 1000 ) (*it) = (*it) % 100 + 100*a ;
        else if ( (*it) < 10000 ) (*it) = (*it) % 1000 + 1000*a ;
        else if ( (*it) < 100000 ) (*it) = (*it) % 10000 + 10000*a ;
        else if ( (*it) < 1000000 ) (*it) = (*it) % 100000 + 100000*a ;
        else if ( (*it) < 10000000 ) (*it) = (*it) % 1000000 + 1000000*a ;
        else if ( (*it) < 100000000 ) (*it) = (*it) % 10000000 + 10000000*a ;

        /*
        list<int>::iterator it = data.end();
        it --;

        if (*it >= 10000) {
            if ( (*it) >= 1000000) {if (*it >=10000000) data.push_back(a); else (*it) += a * 10000000;}
            else {if ((*it) >= 100000) (*it) += a * 1000000; else (*it) += a * 100000;}
        }
        else
            if ( (*it) >= 100) {if (*it >=1000) (*it) += a * 10000; else (*it) += a * 1000;}
            else {if ((*it) >= 10) (*it) += a * 100; else (*it) += a * 10;} */
    }

    void clear(){
        data.clear();
    }

    LL t(){
        if (data.size() == 1) return *data.begin();
        else {
            list<int>::iterator it = data.begin(), jt = data.begin(); ++it;
            return (LL)(*it) * 100000000 + (*jt);
        }
    }

    int size(){
        list<int>::iterator it; int res = 0;
        for (it=data.begin(); it!=data.end();it++)
            res += 8;
        it--;
        if (*it >= 10000) {
            if ( (*it) >= 1000000) {if (*it >=10000000) ; else res--;}
            else {if ((*it) >= 100000) res-=2; else res-=3;}
        }
        else
            if ( (*it) >= 100) {if (*it >=1000) res-=4; else res-=5;}
            else {if ((*it) >= 10) res-=6; else res-=7;}

        return res;
    }

    void do_reserve(int a){
        if (a <= 0) return;
        list<int>::iterator it;
        for (it=data.begin(); it!=data.end() && a>0; it++) a-=8;
        if (it == data.end() && a>=0) return;
        a+=8, it--; int f = 1;
        for (int i=0;i<a;i++) f *= 10; (*it) %= f;
        data.erase(++it, data.end());
        do_trim();
    }

    void output(){
        list<int>::reverse_iterator i=data.rbegin();
        printf("%d", *i); for (i++;i!=data.rend();i++)
            printf("%08d", *i);
    }
};

inline void bignum::operator =(const bignum a){
    data.clear();
    for (list<int>::const_iterator i=a.data.begin();i!=a.data.end();i++){
        data.push_back(*i);
    }
}
inline void bignum::operator =(const string a){
    (*this) = bignum(a);
}
inline void bignum::operator =(const int a){
    (*this) = bignum(a);
}

inline istream& operator>>(istream& input, bignum& a){
    string s; int t, i; input >> s; a.data.clear();
    for (i=int(s.size())-8;i>0;i-=8){
        istringstream(s.substr(i, 8)) >> t;
        a.data.push_back(t);
    }
    istringstream(s.substr(0, i+8)) >> t;
    a.data.push_back(t);
    return input;
}

inline ostream& operator<<(ostream& output, const bignum& a){
    list<int>::const_reverse_iterator i=a.data.rbegin();
    output << *i;
    for (i++;i!=a.data.rend();i++){
        if (*i >= 10000) {
            if (*i >= 1000000) {if (*i>=10000000) cout << *i; else cout << 0 << *i;}
            else {if (*i>=100000) cout << "00" << *i; else cout << "000" << *i;}
        }
        else {
            if (*i >= 100) {if (*i>=1000)  cout << "0000" << *i; else cout << "00000" << *i;}
            else { if (*i>=10) cout << "000000" << *i; else cout << "0000000" << *i;}
        }
    }
    return output;
}

inline bool bignum::undefined(){
    return data.empty();
}

inline int do_comp(const bignum& a, const bignum& b){
    if (a.data.size()<b.data.size()) return -1; if (a.data.size()>b.data.size()) return 1;
    list<int>::const_reverse_iterator i; list<int>::const_reverse_iterator j;
    for (i=a.data.rbegin(),j=b.data.rbegin(); j!=b.data.rend(); i++,j++){
        if (*i<*j) return -1;              //!!!!
        if (*i>*j) return 1;
    }
    return 0;
}
inline int do_comp(const bignum& a, const int& b){
    return do_comp(a, bignum(b));
}

inline bool operator ==(const bignum& a, const bignum& b){
    return do_comp(a, b) == 0;
}
inline bool operator !=(const bignum& a, const bignum& b){
    return do_comp(a, b) != 0;
}
inline bool operator <(const bignum& a, const bignum& b){
    return do_comp(a, b) == -1;
}
inline bool operator >(const bignum& a, const bignum& b){
    return do_comp(a, b) == 1;
}
inline bool operator <=(const bignum& a, const bignum& b){
    return do_comp(a, b) != 1;
}
inline bool operator >=(const bignum& a, const bignum& b){
    return do_comp(a, b) != -1;
}

inline bool operator ==(const bignum& a, const int& b){
    return do_comp(a, b) == 0;
}
inline bool operator !=(const bignum& a, const int& b){
    return do_comp(a, b) != 0;
}
inline bool operator <(const bignum& a, const int& b){
    return do_comp(a, b) == -1;
}
inline bool operator >(const bignum& a, const int& b){
    return do_comp(a, b) == 1;
}
inline bool operator <=(const bignum& a, const int& b){
    return do_comp(a, b) != 1;
}
inline bool operator >=(const bignum& a, const int& b){
    return do_comp(a, b) != -1;
}

inline void bignum::do_trim(){
    while (data.size()>1&&data.back()==0) data.pop_back();
}

inline bignum& bignum::operator +=(const bignum& a){
    list<int>::iterator i; list<int>::const_iterator j; int t = 0;
    for (i=data.begin(),j=a.data.begin(); i!=data.end()&&j!=a.data.end(); i++,j++){
        *i+=*j+t; t=*i/100000000; *i%=100000000;
    }
    while (i!=data.end()) {*i+=t; t=*i/100000000; *i%=100000000; i++;}
    while (j!=a.data.end()) {data.push_back(t+*j); t=data.back()/100000000; data.back()%=100000000; j++;}
    if (t!=0) data.push_back(t);
    return *this;
}

inline bignum& bignum::operator -=(const bignum& a){
    list<int>::iterator i; list<int>::const_iterator j; int t = 0;
    for (i=data.begin(),j=a.data.begin(); j!=a.data.end(); i++,j++){
        *i -= t+*j; if (*i>=0) t=0; else *i+=100000000, t=1;
    }
    while (i!=data.end()) {*i-=t; if (*i>=0) t=0;else *i+=100000000, t=1; i++;}
    (*this).do_trim();
    return *this;
}

inline bignum& bignum::operator +=(const int& a){
    return (*this)+=bignum(a);
}

inline bignum& bignum::operator -=(const int& a){
    return (*this)-=bignum(a);
}

inline bignum operator +(const bignum& a, const bignum& b){
    list<int>::const_iterator i, j; bignum c; int t = 0;
    for (i=a.data.begin(),j=b.data.begin(); i!=a.data.end()&&j!=b.data.end(); i++,j++){
        c.data.push_back(t+*i+*j);
        t=c.data.back()/100000000; c.data.back()%=100000000;
    }
    while (i!=a.data.end()) {c.data.push_back(t+*i); t=c.data.back()/100000000; c.data.back()%=100000000; i++;}
    while (j!=b.data.end()) {c.data.push_back(t+*j); t=c.data.back()/100000000; c.data.back()%=100000000; j++;}
    if (t!=0) c.data.push_back(t);
    return c;
}

inline bignum operator -(const bignum& a, const bignum& b){
    list<int>::const_iterator i, j; bignum c; int t = 0;
    for (i=a.data.begin(),j=b.data.begin(); j!=b.data.end(); i++,j++){
        t = *i - t;
        if (t>=*j) c.data.push_back(t-*j), t=0;
        else c.data.push_back(t+100000000-*j), t=1;
    }
    while (i!=a.data.end()) {t=*i-t; if (t>=0) c.data.push_back(t), t=0;else c.data.push_back(t+100000000), t=1; i++;}
    c.do_trim();
    return c;
}

inline bignum operator *(const bignum& a, const bignum& b){
    list<int>::const_iterator i, j; list<int>::iterator k, kk; bignum c; long long t = 0;

    for (int i=0;i<a.data.size()+b.data.size();i++) c.data.push_back(0);
    for (i=a.data.begin(),k=c.data.begin(); i!=a.data.end(); i++,k++){
        for (j=b.data.begin(),kk=k; j!=b.data.end(); j++,kk++){
            t+=(long long)(*i)*(*j)+(*kk);
            *kk=int(t%100000000); t/=100000000;
        }
        *kk+=t; t=0;
    }
    c.do_trim();
    return c;
}

inline int bignum::do_try(const bignum& a){
    int l = 1, r = 99999999, m, t;
    while (l+2<r){
        m = (l + r) / 2;
        t = do_comp(*this, a*bignum(m));
        if (t==0) return m;
        if (t<0) r = m - 1;
        else l = m;
    }
    while (do_comp(*this, a*bignum(r))<0) r--;
    return r;
}

inline void divide(const bignum& a, const bignum& b, bignum& d, bignum& r){
    list<int>::const_reverse_iterator i = a.data.rbegin(); int t;
    d = bignum(0); r = bignum(0);
    do {
        while (r<b&&i!=a.data.rend()){d.data.push_front(0);r.data.push_front(*i);r.do_trim();i++;}
        if (r>=b){
            t = r.do_try(b); d.data.front() = t;
            r-=(b*bignum(t));
        }
    } while (i!=a.data.rend());
    d.do_trim();
}

inline bignum operator /(const bignum& a, const bignum& b){
    bignum d, r;
    divide(a, b, d, r);
    return d;
}

inline bignum operator %(const bignum& a, const bignum& b){
    bignum d, r;
    divide(a, b, d, r);
    return r;
}

inline bignum operator +(const bignum& a, const int& b){
    return a+bignum(b);
}

inline bignum operator -(const bignum& a, const int& b){
    return a-bignum(b);
}

inline bignum operator *(const bignum& a, const int& b){
    return a*bignum(b);
}

inline bignum operator /(const bignum& a, const int& b){
    return a/bignum(b);
}

inline bignum& bignum::operator *=(const bignum& a){
    (*this) = (*this) * a;
    return *this;
}

inline bignum& bignum::operator /=(const bignum& a){
    (*this) = (*this) / a;
    return *this;
}

inline bignum& bignum::operator %=(const bignum& a){
    (*this) = (*this) % a;
    return *this;
}

inline bignum& bignum::operator *=(const int& a){
    return (*this)*=bignum(a);
}

inline bignum& bignum::operator /=(const int& a){
    return (*this)/=bignum(a);
}

inline bignum& bignum::operator %=(const LL& b){
    return (*this)%=bignum(b);
}

inline bignum pow(bignum a,int b){
    bignum c(1);
    while (b!=0) {
        if (b&1) c *= a;
        a = a * a; b >>= 1;
    }
    return c;
}

#endif // BIGNUM_H_INCLUDED

// <<= ' A. Random Event ..

inline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}
inline int random32(int l, int r){return rand32() % (r - l + 1) + l;}
inline int random(int l, int r){return rand() % (r - l + 1) + l;}
int dice(){return rand() % 6;}
bool coin(){return rand() % 2;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

template<class T> inline void OT(const T &x){
    printf("%d\n", x);
}

/* .................................................................................................................................. */
string str,a,b , temp;
int cntA[10] , A[10] , B[10], cntB[10];
int gao(int x){
    int ret = 0;
    a = ""; b = "";
    if (cntA[x] == 0 || cntA[10 - x] == 0){
        for (int i = 1; i <= 9 ; ++i){
            for (int j = 0 ; j < cntA[i] ; ++j){
                a += i + '0';
                b += i + '0';
            }
        }
        return 0;
    }
    a += x + '0';
    b += 10 - x + '0';
    cntA[x] --;
    cntB[10 - x] --;
    ret++;
    const int orde[]={ 0 , 9 , 1 , 2 ,3 , 4 , 5 , 6 , 7 , 8};
    for (int ri = 0 ; ri <= 9 ; ++ri){
        int i = orde[ri];
        while (cntA[i] && cntB[ 9 - i ]){
            temp = i + '0';
            a = a + temp;
            temp = 9 - i + '0';
            b = b + temp;
            cntA[i] --;
            cntB[9-i] --;
            ret ++;
        }
    }
    //cout << cntA[0] << "DS" << cntB[0] << endl;
    int zhu = min(cntA[0] , cntB[0]);
    for (int i = 0 ; i < zhu;++i){
        cntA[0] -- ;
        cntB[0] -- ;
        a = '0' + a;
        b = '0' + b;
        ret ++;
    }
    int now = a.length() - 1;

    for (int i = 0; i <= 9 ; ++i){
        for (int j = 0 ; j < cntA[i] ; ++ j){
            temp = i + '0';
            a = a + temp;
        }
        for (int j = 0 ; j < cntB[i] ; ++j){
            temp = i + '0';
            b = b + temp;
        }
    }
    return ret;
}
void solve(){
    a = ""; b = "";
    int len = str.length();
    memset(cntA , 0 , sizeof(cntA));
    memset(cntB , 0 , sizeof(cntB));
    memset(A , 0 , sizeof(A));
    memset(B , 0 , sizeof(B));
    for (int i = 0 ; i < len ; ++i){
        ++A[ str[i] -'0' ] ;
        ++B[ str[i] - '0' ];
    }
    int ans = -1 , ansi = 1;
    for (int i = 1 ; i <= 5 ; ++i){
        for (int j = 0 ; j <= 9 ; ++j){
            cntA[j] = A[j];
            cntB[j] = B[j];
        }
        int res = gao(i);
        if (res > ans){
            ans = res;
            ansi = i;
        }
    }
    //cout << ansi << endl;
    for (int j = 0 ; j <= 9 ; ++j){
            cntA[j] = A[j];
            cntB[j] = B[j];
    }
    gao(ansi);

    for (int i = a.length() - 1; i>=0 ; --i)
        printf("%c",a[i]);

    printf("\n");

    for (int i = b.length() - 1; i>=0 ; --i)
        printf("%c",b[i]);

    printf("\n");
}
int main(){
    while (cin >> str) solve();

}

/*mdashkdoakpbhoceqbntlpfbjknetgsdblbabegnpcooqikeje*/


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const ll LIMIT = ll(1e9)*ll(1e9);
bool check ( ll a, ll b, ll c ) {
  return true; // :D
}

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  else if ( a%2 == 1 )
    return pll( (a*a-1)/2, (a*a+1)/2 );
  pll r = solveRec(a/2);
  r.first *= 2; r.second *= 2;
  return r;
}

pii solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    check(a,p.first,p.second);
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      check(i,j,a);
      return(pii(i,j));
    }
  }

  return pii(0,0);
}

int main() {
  ll a;
  cin >> a;
  pii p = solve(a);
  if ( p.first )cout << p.first << " " << p.second << endl;
  else puts("-1");
  return 0;
}


//note to self: dejar el machete >:v
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
typedef long long ll;

bool check ( ll a, ll b, ll c ) {
  if ( a*a + b*b != c*c ) {
    cout << "fail " << a << " " << b << " " << c << endl;
    return false;
  }
  return true;
}

#define TAM 32000
ll squares[TAM];

pll solve ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  else if ( a%2 == 1 )
    return pll( (a*a-1)/2, (a*a+1)/2 );
  pll r = solve(a/2);
  r.first *= 2; r.second *= 2;
  return r;
}

int main() {
  ll a;
  while(cin >> a){
    pll p = solve(a);
    if ( p.first ) {
      cout << p.first << " " << p.second << endl;
      assert(check(a,p.first,p.second));
    }
    else {
      const ll a2 = a*a;
      bool found = false;
      for ( int i = 1; i < TAM; ++i ) {
        squares[i]=ll(i)*ll(i);
        int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
        if ( squares[i] + squares[j] == a2 ) {
          cout << i << " " << j << endl;
          found = true;
          break;
        }
      }
      if ( !found )
        puts("-1");
    }
  }
  return 0;
}


//note to self: dejar el machete >:v
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
typedef long long ll;

bool check ( ll a, ll b, ll c ) {
  if ( a*a + b*b != c*c ) {
    cout << "fail " << a << " " << b << " " << c << endl;
    return false;
  }
  return true;
}

pll solve ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  else if ( a%2 == 1 )
    return pll( (a*a-1)/2, (a*a+1)/2 );
  pll r = solve(a/2);
  r.first *= 2; r.second *= 2;
  return r;
}

int main() {
  ll a;
  while(cin >> a){
    pll p = solve(a);
    if ( p.first ) {
      cout << p.first << " " << p.second << endl;
      assert(check(a,p.first,p.second));
    }
    else puts("-1");
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const ll LIMIT = ll(1e9)*ll(1e9);
bool check ( ll a, ll b, ll c ) {
  return true; // :D
}

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  else if ( a%2 == 1 )
    return pll( (a*a-1)/2, (a*a+1)/2 );
  pll r = solveRec(a/2);
  r.first *= 2; r.second *= 2;
  return r;
}

pii solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    check(a,p.first,p.second);
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      check(i,j,a);
      return(pii(i,j));
    }
  }

  return pii(0,0);
}

int main() {
  ll a;
  cin >> a;
  pii p = solve(a);
  cout << p.first << " " << p.second << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TAM

int main() {
  clock_t machete = clock() + CLOCKS_PER_SEC * 0.8;
  ll a, b, c;
  cin >> a;
  b = 1; c = a;
  while ( clock() < machete ) {
    while ( c*c < a*a + b*b ) c++;
    if ( c*c == a*a + b*b ) {
      cout << b << " " << c << endl;
      return 0;
    }
    b++;
  }
  puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
typedef long long ll;

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  if ( a == 4 ) return pll(5,3);
  if ( a%2 == 1 ) return pll( (a*a-1LL)/2LL, (a*a+1LL)/2LL );
  pll r = solveRec(a/2LL);
  r.first *= 2LL; r.second *= 2LL;
  return r;
}

pll solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      return(pll(i,j));
    }
  }

  return pll(0,0);
}

int main() {
  ll a;
  cin >> a;
  pll p = solve(a);
  if ( p.first ) {
    cout << p.first << " " << p.second << endl;
    return 0;
  }

  puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
typedef long long ll;

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  if ( a == 4 ) return pll(5,3);
  if ( a%2 == 1 ) return pll( (a*a-1LL)/2LL, (a*a+1LL)/2LL );
  pll r = solveRec(a/2LL);
  r.first *= 2LL; r.second *= 2LL;
  return r;
}

pll solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    check(a,p.first,p.second);
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      check(i,j,a);
      return(pll(i,j));
    }
  }

  return pll(0,0);
}

int main() {
  ll a;
  cin >> a;
  pll p = solve(a);
  if ( p.first ) {
    cout << p.first << " " << p.second << endl;
    return 0;
  }

  puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TAM 32000
ll squares[TAM];

int main() {
  clock_t machete = clock() + CLOCKS_PER_SEC * 0.8;
  ll a;
  cin >> a;

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      cout << i << " " << j << endl;
      return 0;
    }
  }

  ll b = 1;
  ll lo = 1, hi, mi;
  while ( clock() < machete ) {
    const ll wanted = a2 + b*b;
    hi = wanted;
    while ( lo < hi )  {
      mi = ( lo + hi ) / 2;
      if ( mi*mi < wanted ) lo = mi+1;
      else hi = mi;
    }
    if ( lo*lo == wanted ) {
      cout << b << " " << lo << endl;
      return 0;
    }
    b++;
  }
  puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const ll LIMIT = ll(1e9)*ll(1e9);
bool check ( ll a, ll b, ll c ) {
  return true; // :D
}

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  if ( a%2 == 1 )
    return pll( (a*a-1LL)/2LL, (a*a+1LL)/2LL );
  pll r = solveRec(a/2LL);
  r.first *= 2LL; r.second *= 2LL;
  return r;
}

pii solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    check(a,p.first,p.second);
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      check(i,j,a);
      return(pii(i,j));
    }
  }

  return pii(0,0);
}

int main() {
  ll a;
  cin >> a;
  pii p = solve(a);
  if ( p.first )cout << p.first << " " << p.second << endl;
  else puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TAM

int main() {
  ll a, b, c;
  cin >> a;
  b = 1; c = a;
  if ( a == 1 ) {
    puts("-1");
    return 0;
  }
  while ( true ) {
    while ( c*c < a*a + b*b ) c++;
    if ( c*c == a*a + b*b ) {
      cout << b << " " << c << endl;
      return 0;
    }
    b++;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const ll LIMIT = ll(1e9)*ll(1e9);
bool check ( ll a, ll b, ll c ) {
  // :D
  return true;
}

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  if ( a == 4 ) return pll(5,3);
  if ( a%2 == 1 ) return pll( (a*a-1LL)/2LL, (a*a+1LL)/2LL );
  pll r = solveRec(a/2LL);
  r.first *= 2LL; r.second *= 2LL;
  return r;
}

pii solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    check(a,p.first,p.second);
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      check(i,j,a);
      return(pii(i,j));
    }
  }

  return pii(0,0);
}

int main() {
  ll a;
  cin >> a;
  pii p = solve(a);
  if ( p.first ) {
    cout << p.first << " " << p.second << endl;
    return 0;
  }

  puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const ll LIMIT = ll(1e9)*ll(1e9);
bool check ( ll a, ll b, ll c ) {
  return true; // :D
}

#define TAM 1000000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  if ( a%2 == 1 )
    return pll( (a*a-1LL)/2LL, (a*a+1LL)/2LL );
  pll r = solveRec(a/2LL);
  r.first *= 2LL; r.second *= 2LL;
  return r;
}

pii solve(ll a) {
  pll p = solveRec(a);
  if ( p.first ) {
    check(a,p.first,p.second);
    return p;
  }

  const ll a2 = a*a;
  for ( int i = 1; i < TAM; ++i ) {
    squares[i]=ll(i)*ll(i);
    int j = lower_bound( squares+1, squares+i, a2-squares[i] ) - squares;
    if ( squares[i] + squares[j] == a2 ) {
      check(i,j,a);
      return(pii(i,j));
    }
  }

  return pii(0,0);
}

int main() {
  ll a;
  cin >> a;
  pii p = solve(a);
  if ( p.first )cout << p.first << " " << p.second << endl;
  else puts("-1");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
typedef long long ll;

#define TAM 32000
ll squares[TAM];

pll solveRec ( ll a ) {
  if ( a == 1 ) return pll(0,0);
  if ( a == 4 ) return pll(5,3);
  if ( a%2 == 1 ) return pll( (a*a-1LL)/2LL, (a*a+1LL)/2LL );
  pll r = solveRec(a/2LL);
  r.first *= 2LL; r.second *= 2LL;
  return r;
}

int main() {
  ll a;
  cin >> a;
  pll p = solveRec(a);
  if ( p.first )
    cout << p.first << " " << p.second << endl;
  else puts("-1");
  return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long a,b;
    if(n==1 || n==2)
        cout<<"-1";
    else
    {
        if(n%2==0)
        {
            b=(n*n)/4+1;
            a=b-2;
        }
        else
        {
            b=(n*n+1)/2;
            a=b-1;
        }
    }
    cout<<a<<" "<<b;
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long a,b1,b2;
    for(long long i=1;i<1000000000;i++)
    {
        a=i;
        b1=sqrt(n*n-a*a);
        b2=sqrt(n*n+a*a);
        if(a*a+b1*b1==n*n && b1!=0)
        {
            cout<<a<<" "<<b1;
            break;
        }
        if(n*n+a*a==b2*b2 && b2!=0)
        {
            cout<<a<<" "<<b2;
            break;
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long a,b,c;
    cin>>a;
    if(a%2==1)
    {
        c=(a*a+1)/2;
        b=(a*a-1)/2;
    }
    else
    {
        c=(a*a+4)/4;
        b=(a*a-4)/4;
    }
    cout<<b<<" "<<c;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long a,b,c;
    cin>>a;
    if(a<=2)
        cout<<"-1";
    else if(a%2==1)
    {
        c=(a*a+1)/2;
        b=(a*a-1)/2;
    }
    else
    {
        c=(a*a+4)/4;
        b=(a*a-4)/4;
    }
    cout<<b<<" "<<c;
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long a,b;
    bool p=(n==1);
    if(n==1 || n==2)
        cout<<"-1";
    else
    {
        if(n%2==0)
        {
            b=(n*n)/4+1;
            a=b-2;
        }
        else
        {
            b=(n*n+1)/2;
            a=b-1;
        }
        cout<<a<<" "<<b;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long a,b,c;
    cin>>a;
    if(a<=2)
        cout<<"-1";
    else
    {
        if(a%2==1)
        {
            c=(a*a+1)/2;
            b=(a*a-1)/2;
        }
        else
        {
            c=(a*a+4)/4;
            b=(a*a-4)/4;
        }
    cout<<b<<" "<<c;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n<=2)
	{
		cout<<"-1";
	}
	else{
	if(n==1000000000)
	{	cout<<"1250000000 750000000";
		return 0;}
	if(n%2==0)
	{
		long long int a = n/2;
		long long int m = (a*a)-1;
		long long int k = (a*a)+1;
			cout<<m<<" "<<k;
	}
	else
	{
		long long int a = (n*n)/2;
		if((n*n)+(a*a)==((a+1)*(a+1)))
		{
			cout<<a<<" "<<a+1;
		}
		else
		{
			cout<<"-1";
		}
	}}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"-1";
	}
	else{
	else{
	if(n==1000000000)
	{	cout<<"1250000000 750000000";
		return 0;}
	if(n%2==0)
	{
		long long int a = n/2;
		long long int m = (a*a)-1;
		long long int k = (a*a)+1;
			cout<<m<<" "<<k;
	}
	else
	{
		long long int a = (n*n)/2;
		if((n*n)+(a*a)==((a+1)*(a+1)))
		{
			cout<<a<<" "<<a+1;
		}
		else
		{
			cout<<"-1";
		}
	}}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"-1";
	}
	else{
	if(n%2==0)
	{
		long long int a = n/2;
		long long int m = (a*a)-1;
		long long int k = (a*a)+1;
		if((m*m)+(n*n)==(k*k))
		{
			cout<<m<<" "<<k;
		}
		else
		{
			cout<<"-1";
		}
	}
	else
	{
		long long int a = (n*n)/2;
		if((n*n)+(a*a)==((a+1)*(a+1)))
		{
			cout<<a<<" "<<a+1;
		}
		else
		{
			cout<<"-1";
		}
	}}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"-1";
	}
	else{
	if(n==1000000000)
	{	cout<<"1250000000 750000000";
		return 0;}
	if(n%2==0)
	{
		long long int a = n/2;
		long long int m = (a*a)-1;
		long long int k = (a*a)+1;
			cout<<m<<" "<<k;
	}
	else
	{
		long long int a = (n*n)/2;
		if((n*n)+(a*a)==((a+1)*(a+1)))
		{
			cout<<a<<" "<<a+1;
		}
		else
		{
			cout<<"-1";
		}
	}}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	if(n<=2)
	{
		cout<<"-1";
	}
	else{
	if(n==1000000000)
	{	cout<<"1250000000 750000000";
		return 0;}
	if(n%2==0)
	{
		long long int a = n/2;
		long long int m = (a*a)-1;
		long long int k = (a*a)+1;
			cout<<m<<" "<<k;
	}
	else
	{
		long long int a = (n*n)/2;
		cout<<a<<" "<<a+1;
	}}
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define test            int t; cin>>t; while(t--)
#define io             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main(){
  io ;

  int n;
  cin >> n;
  if(n&1){
      double tmp = n;
      tmp *= tmp;
      tmp /= 2;
      cout << tmp - 0.5 << " " << tmp + 0.5 << "\n";

  }else{
      int tmp = (n/2)*(n/2);
      cout << tmp + 1 << " " << tmp - 1 << "\n";
  }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define test            int t; cin>>t; while(t--)
#define io             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main(){
  io ;

  int n;
  cin >> n;
  if(n==1 or n==2){
      cout << "-1\n";
      return 0;
  }
  if(n&1){
      double tmp = n;
      tmp *= tmp;
      tmp++;
      cout <<fixed<<setprecision(0)<< tmp/2 - 1 << " " << tmp/2<< "\n";

  }else{
      int tmp = (n/2)*(n/2);
      cout << tmp + 1 << " " << tmp - 1 << "\n";
  }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define test            int t; cin>>t; while(t--)
#define io             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main(){
  io ;

  int n;
  cin >> n;
  if(n&1){
      double tmp = n;
      tmp *= tmp;
      tmp /= 2;
      cout << tmp - 0.5 << " " << tmp + 0.5 << "\n";

  }else{
      int tmp = n * n;
      tmp /= 2;
      cout << tmp + 1 << " " << tmp - 1 << "\n";
  }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define test            int t; cin>>t; while(t--)
#define io             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main(){
  io ;

  int n;
  cin >> n;
  if(n==1 or n==2){
      cout << "-1\n";
      return 0;
  }
  if(n&1){
      double tmp = n;
      tmp *= tmp;
      tmp /= 2;
      cout <<fixed<<setprecision(0)<< tmp - 0.5 << " " << tmp + 0.5 << "\n";

  }else{
      int tmp = (n/2)*(n/2);
      cout << tmp + 1 << " " << tmp - 1 << "\n";
  }

}


#include <bits/stdc++.h>
using namespace std;

void evaluate(long long int n)
{

	if (n == 1 || n == 2){
		printf("-1\n");
        return;
    }
	else if (n % 2 == 0) {

		long long int var = 1LL * n * n / 4;
		printf("Pythagoras Triplets exist i.e. ");
		printf(" %lld %lld",  var - 1, var + 1);
	}

	else if (n % 2 != 0) {

		long long int var = 1LL * n * n + 1;
		printf("Pythagoras Triplets exist i.e. ");
		printf(" %lld %lld",  var / 2 - 1, var / 2);
	}
}

int main()
{
    long long int n;
    cin >> n;
    evaluate(n);
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define test            int t; cin>>t; while(t--)
#define io             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main(){
  io ;

  int n;
  cin >> n;
  if(n==1 or n==2){
      cout << "-1\n";
      return 0;
  }
  if(n&1){
      double tmp = n;
      tmp *= tmp;
      tmp /= 2;
      cout << tmp - 0.5 << " " << tmp + 0.5 << "\n";

  }else{
      int tmp = (n/2)*(n/2);
      cout << tmp + 1 << " " << tmp - 1 << "\n";
  }

}


#include <bits/stdc++.h>
using namespace std;

void evaluate(long long int n)
{

	if (n == 1 || n == 2){
		printf("-1\n");
        return;
    }
	else if (n % 2 == 0) {

		long long int var = 1LL * n * n / 4;

		printf(" %lld %lld",  var - 1, var + 1);
	}

	else if (n % 2 != 0) {

		long long int var = 1LL * n * n + 1;

		printf(" %lld %lld",  var / 2 - 1, var / 2);
	}
}

int main()
{
    long long int n;
    cin >> n;
    evaluate(n);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    int a;cin>>a;
    ll b,c;
    if(a==1 || b==2) {cout<<-1;return 0;}
    else if(a%2!=0){
        b=(a*a-1)/2;
        c=b+1;
    }
    else{
        c=(a*a)/4 + 1;
        b=c-2;
    }
    cout<<b<<" "<<c;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    int a,b;
    cin>>a;
    double c;
    if(a==1) {cout<<-1;return 0;}
    for(int i=a+1;i<pow(10,9);i++){
        b=i;
        c=sqrt(pow(b,2) + pow(a,2));
        if(round(c)==c){
            if((a+b>c) && (b+c>a) && (c+a>b)){
                cout<<b<<" "<<c;
                return 0;
            }
        }
    }
    cout<<-1;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll a,b;
    cin>>a;
    double c;
    if(a==1) {cout<<-1;return 0;}
    for(int i=a+1;i<pow(10,9);i++){
        b=i;
        c=sqrt(pow(b,2) + pow(a,2));
        if(round(c)==c){
            if((a+b>c) && (b+c>a) && (c+a>b)){
                cout<<b<<" "<<c;
                return 0;
            }
        }
    }
    for(int i=a-1;i>1;i--){
        b=i;
        c=sqrt(pow(b,2) + pow(a,2));
        if(round(c)==c){
            if((a+b>c) && (b+c>a) && (c+a>b)){
                cout<<b<<" "<<int(c);
                return 0;
            }
        }
    }
    cout<<-1;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll a;cin>>a;
    ll b,c;
    if(a==1 || a==2) {cout<<-1;return 0;}
    else if(a%2!=0){
        ll num=a*a;
        b=(num-1)/2;
        c=b+1;
    }
    else{
        ll num=a*a;
        c=num/4 + 1;
        b=c-2;
    }
    cout<<b<<" "<<c;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll a;cin>>a;
    ll b,c;
    if(a==1 || b==2) {cout<<-1;return 0;}
    else if(a%2!=0){
        ll num=a*a;
        b=(num-1)/2;
        c=b+1;
    }
    else{
        ll num=a*a;
        c=num/4 + 1;
        b=c-2;
    }
    cout<<b<<" "<<c;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll a, ll b) {
	ll result = 1;
	while (b > 0) {
		if (b % 2 == 1)
			result = (result * a);
		a = (a * a);
		b /= 2;
	}
	return result;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	if (n < 3)
		return cout << "-1", 0;
	if (n & 1) {
		ll m = (n * n + 1) / 2;
		ll k = (n * n - 1) / 2;
		cout << k << ' ' << m << endl;
	} else {
		ll k = (n * n / 4) + 1;
		ll m = k - 2;
		cout << m << ' ' << k << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll a, ll b) {
	ll result = 1;
	while (b > 0) {
		if (b % 2 == 1)
			result = (result * a);
		a = (a * a);
		b /= 2;
	}
	return result;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long double n, c;
	cin >> n;
	if ( n < 3) return cout << "-1" , 0;
	for (ll i = n; i <= 1e18; i++) {
		c = sqrt(power(n, 2) + power(i, 2));
		//cout << n << " " << i << " " << c<< endl;
		if (c == (ll) c) {
			return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
		}
		/*if (n > i) {
			c = sqrt(power(n, 2) - power(i, 2));
			if (c == (int) c) {
				return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
			}
		} else if (i > n) {
			c = sqrt(power(i, 2) - power(n, 2));
			if (c == (int) c) {
				return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
			}
		}*/
	}
	cout << "-1\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll a, ll b) {
	ll result = 1;
	while (b > 0) {
		if (b % 2 == 1)
			result = (result * a);
		a = (a * a);
		b /= 2;
	}
	return result;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long double n, c;
	cin >> n;
	if ( n < 3) return cout << "-1" , 0;
	for (ll i = n; i <= 1e9; i++) {
		c = sqrt(power(n, 2) + power(i, 2));
		//cout << n << " " << i << " " << c<< endl;
		if (c == (ll) c) {
			return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
		}
		/*if (n > i) {
			c = sqrt(power(n, 2) - power(i, 2));
			if (c == (int) c) {
				return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
			}
		} else if (i > n) {
			c = sqrt(power(i, 2) - power(n, 2));
			if (c == (int) c) {
				return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
			}
		}*/
	}
	cout << "-1\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll a, ll b) {
	ll result = 1;
	while (b > 0) {
		if (b % 2 == 1)
			result = (result * a);
		a = (a * a);
		b /= 2;
	}
	return result;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long double n, c;
	cin >> n;
	if ( n < 3) return cout << "-1" , 0;
	for (ll i = 3; i <= 1e18; i++) {
		c = sqrt(power(n, 2) + power(i, 2));
		//cout << n << " " << i << " " << c<< endl;
		if (c == (ll) c) {
			return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
		}
		if (n > i) {
			c = sqrt(power(n, 2) - power(i, 2));
			if (c == (int) c) {
				return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
			}
		} else if (i > n) {
			c = sqrt(power(i, 2) - power(n, 2));
			if (c == (int) c) {
				return cout << min(i , (ll)c) << " " <<  max(i , (ll)c) << endl, 0;
			}
		}
	}
	cout << "-1\n";
	return 0;
}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <unordered_set>

#define int64 unsigned long long

using namespace  std;

int64 Sqrt(int64 v) {
    int64 r = static_cast<int64>(sqrt(double(v)));
    while (r * r < v) {
        ++r;
    }
    return r;
}

int64 Decrease(int64 &v) {
    int64 res = 1;
    for (int i = 2; i < 1000000; ++i) {
        while (v % i == 0 && v / i > 2) {
            v /= i;
            res *= i;
        }
    }
    return res;
}
int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 v[3];
    cin >> v[0];

    int64 d = Decrease(v[0]);

    v[0] *= v[0];

    unordered_set<int64> s;
    for (int64 i = 1; i < 1000000; ++i) {
        int64 sq = i * i;
        s.insert(sq);
    }
    for (auto i = s.begin(); i != s.end(); ++i) {
        v[1] = *i;
        v[2] = v[0] - v[1];
        if (s.count(v[2]) != 0) {
            sort(v + 1, v + 3);
            cout << d * Sqrt(v[1]) << ' ' << d * Sqrt(v[2]) << endl;
            return 0;
        }

        v[2] = v[0] + v[1];
        if (s.count(v[2]) != 0) {
            sort(v + 1, v + 3);
            cout << d * Sqrt(v[1]) << ' ' << d  * Sqrt(v[2]) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>

#define int64 long long

using namespace  std;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 n;
    cin >> n;

    if (n % 2 == 1) {
        cout << n / 2 + 1 << ' ' << n / 2 << endl;
    }
    else if (n % 4 == 0) {
        cout << 3 * n / 4 << ' ' << 5 * n / 4 << endl;
    }
    else if (n % 2 == 1) {
        cout << n / 2 + 2 << ' ' << n / 2 << endl;
    }

    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>

#define int64 long long

using namespace  std;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 n;
    cin >> n;
    if (n <= 2) {
        cout << -1 << endl;
    }
    else if (n % 2 == 1) {
        cout << n * n / 2 + 1 << ' ' << n * n / 2 << endl;
    }
    else if (n % 4 == 0) {
        cout << 3 * n / 4 << ' ' << 5 * n / 4 << endl;
    }
    else if (n % 2 == 0) {
        n /= 2;
        cout << 2 * (n * n / 2 + 1) << ' ' << 2 * (n * n / 2) << endl;
    }

    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>

#define int64 unsigned long long

using namespace  std;

int64 Sqrt(int64 v) {
    int64 r = static_cast<int64>(sqrt(double(v)));
    while (r * r < v) {
        ++r;
    }
    return r;
}
int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 v[3];
    cin >> v[0];
    v[0] *= v[0];

    set<int64> s;
    for (int64 i = 1; i < 1000000; ++i) {
        int64 sq = i * i;
        s.insert(sq);
    }
    for (auto i = s.begin(); i != s.end(); ++i) {
        v[1] = *i;
        v[2] = v[0] - v[1];
        if (s.count(v[2]) != 0) {
            sort(v + 1, v + 3);
            cout << Sqrt(v[1]) << ' ' << Sqrt(v[2]) << endl;
            return 0;
        }
    }
    for (auto i = s.begin(); i != s.end(); ++i) {
        v[1] = *i;
        v[2] = v[0] + v[1];
        if (s.count(v[2]) != 0) {
            sort(v + 1, v + 3);
            cout << Sqrt(v[1]) << ' ' << Sqrt(v[2]) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>

#define int64 long long

using namespace  std;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 n;
    cin >> n;
    n *= n;

    if (n % 2 == 1) {
        cout << n / 2 + 1 << ' ' << n / 2 << endl;
    }
    else if (n % 4 == 0) {
        cout << 3 * n / 4 << ' ' << 5 * n / 4 << endl;
    }
    else if (n % 2 == 1) {
        cout << n / 2 + 2 << ' ' << n / 2 << endl;
    }

    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <unordered_set>

#define int64 unsigned long long

using namespace  std;

int64 Sqrt(int64 v) {
    int64 r = static_cast<int64>(sqrt(double(v)));
    while (r * r < v) {
        ++r;
    }
    return r;
}

int64 Decrease(int64 &v) {
    int64 res = 1;
    for (int i = 2; i < 1000000; ++i) {
        while (v % i == 0 && v / i > 2) {
            v /= i;
            res *= i;
        }
    }
    return res;
}
int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 v[3];
    cin >> v[0];

    int64 d = Decrease(v[0]);

    v[0] *= v[0];

    unordered_set<int64> s;
    for (int64 i = 1; i < 100000; ++i) {
        int64 sq = i * i;
        s.insert(sq);
    }
    for (auto i = s.begin(); i != s.end(); ++i) {
        v[1] = *i;
        v[2] = v[0] - v[1];
        if (s.count(v[2]) != 0) {
            sort(v + 1, v + 3);
            cout << d * Sqrt(v[1]) << ' ' << d * Sqrt(v[2]) << endl;
            return 0;
        }

        v[2] = v[0] + v[1];
        if (s.count(v[2]) != 0) {
            sort(v + 1, v + 3);
            cout << d * Sqrt(v[1]) << ' ' << d  * Sqrt(v[2]) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>

#define int64 long long

using namespace  std;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 n;
    cin >> n;
    n *= n;
    if (n <= 2) {
        cout << -1 << endl;
    }
    else if (n % 2 == 1) {
        cout << n / 2 + 1 << ' ' << n / 2 << endl;
    }
    else if (n % 4 == 0) {
        cout << 3 * n / 4 << ' ' << 5 * n / 4 << endl;
    }
    else if (n % 2 == 1) {
        cout << n / 2 + 2 << ' ' << n / 2 << endl;
    }

    return 0;

}


#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>

#define int64 long long

using namespace  std;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    int64 n;
    cin >> n;

    if (n % 2 == 1) {
        cout << n / 2 + 1 << ' ' << n / 2 << endl;
    }
    else if (n % 4 == 0) {
        cout << 3 * n / 4 << ' ' << 5 * 3 / 4 << endl;
    }
    else if (n % 2 == 1) {
        cout << n / 2 + 2 << ' ' << n / 2 << endl;
    }

    return 0;

}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	unsigned long long n,a,b,c;
	cin>>n;
	if(n<=2)
	{
		cout<<-1;
		return 0;
	}
	if(n%2!=0)
	{
		b=(n*n-1)/2;
		c=b+1;
		cout<<b<<" "<<c;
	}
	else
	{
		b=((n/2)*(n/2))-1;
		c=b+2;
		cout<<b<<" "<<c;
	}

	return 0;
}
/*

for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)

*/


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	unsigned long long n;
	cin>>n;
	if(n>1000000000000000000)
	cout<<-1;
	else
	{
			unsigned long long m=0,x=n+1;
	bool test=false;
	for(unsigned long long i=n;i<=(n*n)/2;i++)
	{

		m=sqrt(x*x-n*n);
		//cout<<m<<" "<<n<<" "<<x<<'\n';
		if(n*n+m*m==x*x)
		{
			cout<<m<<" "<<x;
			test=true;
			break;
		}
		x++;
	}
	if(!test)
	cout<<-1;
	}
	return 0;
}
/*

for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)

*/


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long n;
	cin>>n;
	long long m=0,x=n+1;
	bool test=false;
	for(int i=n;i<=n*n;i++)
	{

		m=sqrt(x*x-n*n);
		//cout<<m<<" "<<n<<" "<<x<<'\n';
		if(n*n+m*m==x*x)
		{
			cout<<m<<" "<<x;
			test=true;
			break;
		}
		x++;
	}
	if(!test)
	cout<<-1;
	return 0;
}
/*

for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)

*/


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	unsigned long long n;
	cin>>n;
	unsigned long long m=0,x=n+1;
	bool test=false;
	for(unsigned long long i=n;i<=(n*n)/2;i++)
	{

		m=sqrt(x*x-n*n);
		//cout<<m<<" "<<n<<" "<<x<<'\n';
		if(n*n+m*m==x*x)
		{
			cout<<m<<" "<<x;
			test=true;
			break;
		}
		x++;
	}
	if(!test)
	cout<<-1;
	return 0;
}
/*

for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)

*/