    /*

      (                                 _
       )                               /=>
      (  +____________________/\/\___ / /|
       .''._____________'._____      / /|/\
      : () :              :\ ----\|    \ )
       '..'______________.'0|----|      \
                        0_0/____/        \
                            |----    /----\
                           || -\\ --|      \
                           ||   || ||\      \
                            \\____// '|      \
    Bang! Bang!                     .'/       |
                                   .:/        |
                                   :/_________|

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     BALJOT SINGH
     EVERYONE HAS THEIR OWN TIME
     DEBUG->COMMENT FAST
    ~~~~~~~~~~~~~~~~~~~~~~
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    #include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #define fi first
    #define se second
    #define loop(i,a,b)               for(int i = a; i<=b ; i++)
    #define rep(i,a,b)              for(int i = a; i>=b ; i--)
    #define pb push_back
    #define mp make_pair
    #define setbits(x)      __builtin_popcountll(x)
    #define zerobits(x)      __builtin_ctzll(x)
    #define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL) ;cout.tie(NULL);
    using namespace std;
    using namespace __gnu_pbds;
    using ll =long long ;

    template<class T> using pbds =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;




    const ll M = 1e9 + 7;
    const ll iM = 1e5 + 5;
    const ll inf = 2e18;


    //modular arithmetic worst part-----------------------------------
    ll mod(ll x){  return (x%M+M)%M;}
    ll mod_min(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
    ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
    ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
    ll power(ll x,ll y)  {  ll res = 1;if (x == 0) return 0;while (y > 0){if (y & 1) res=mod_mul(res,x); y = y>>1; x=mod_mul(x,x);} return res;}
    ll gcd_extend(ll a, ll b, ll& x, ll& y) {if (b == 0) {x = 1;y = 0;return a;}ll x1, y1;ll d = gcd_extend(b, a % b, x1, y1);x = y1;y = x1 - y1 * (a / b);return d;}
    ll modinverse(ll value) {ll x, y;ll res=gcd_extend(value,M,x,y);if(res!=1)return -1;return mod(x);}
    //----------------------------------------------------------------------------------------------------------------------------------



    int main()
    {
        FAST;

        ll n;
        cin>>n;
        if(n<=7)
        {
            cout<<"-1";
            return 0;
        }

       for(ll i=1;i<log(inf)/log(5);i++)
        for(ll j=1;j<log(inf)/log(3);j++)
            if(((ll)powl(5,i)+(ll) powl(3,j))==n)
       {
           cout<<j<<" "<<i;
           return 0;
       }

        cout<<"-1";



    }








//
//  main.cpp
//  atcoder
//
//  Created by 荣恒嬉 on 2020/10/24.
//

#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main() {
	ll a;
	cin>>a;
	ll x=1,y=1;
	for(int i=1;i<38;i++){
		x*=3;
		ll y=1;
		for(int j=1;j<28;j++){
			y*=5;
			if(x+y==a)
			{
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	cout<<-1;
	return 0;
}
