#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
    ll n;
    cin >> n;

    int flag = 0;
    int ansa = 0, ansb = 0;
    ll a = 3;

    for(int i = 1; ; i++) {
        if(a < 0 || a > n) break;
        ll b = 5;
        for(int j = 1;;j++) {
            if(b < 0 || a + b > n) break;
            else if(a + b == n) {
                flag = 1;
                ansa = i;
                ansb = j;
                break;
            }
            b *= 5;
        }
        a *= 3;
    }

    if(flag == 0) cout << -1 << endl;
    else cout << ansa << " " << ansb << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
long long N,INF = 1e18;
int main() {
	scanf("%lld",&N);
	long long k = 1,d = 1,s = 1;
	int i=1,j=1;
	for(;k<=N;++i) {
		 k*=5;
		d = N-k,s = 3,j=2;
		for(;s<d;++j) {
			s*=3;
		}
		if(d == s) {
			return 0*printf("%d %d\n",j-1,i);
		}
	}
	puts("-1");
	return 0; 
}