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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9 + 7;
int inf = 1000000000; //10e9

ll power(int x, int n)
{

    ll xn = 1;

    rep(i, n)
    {
        xn *= x;
    }

    return xn;
}

int main()
{
    ll n;
    cin >> n;

    bool ans = false;
    ll tmp = 1;
    int a, b;

    for (int i = 1; tmp <= n; i++)
    {
        for (int j = 1; tmp <= n; j++)
        {
            tmp = power(5, i) + power(3, j);
            if (tmp == n)
            {
                ans = true;
                a = j;
                b = i;
                break;
            }
        }
        if (ans)
        {
            break;
        }
        tmp = power(5, i) + 3;
    }

    if (ans)
    {
        cout << a << ' ' << b << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}
#include <bits/stdc++.h>
#define pb push_back
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define per(i, a, n) for(int i = n-1; i >= a; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
using namespace std;
ll myPow(ll x, ll p){
	ll y = 1;
	while(p--){
		y *= x;
	}
	return y;
}

void test_case(){
	ll s;
	scanf("%lld", &s);
	for(ll a = 1; ; a++){
		ll x = myPow(3, a);
		if(x >= s) break;
		for(ll b = 1; ; ++b){
			ll y = myPow(5, b);
			if(y >= s) break;
			if(x+y == s){
				printf("%lld %lld", a, b);
				return;
			}
		}
	}
	printf("-1\n");
}
int main()
{
	test_case();
}


