#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e18;

int main(){
    ll n;
    cin >> n;
    
    vector<ll> a, b;
    ll x = 1, y = 1;
    while (1){
        if (x > INF / 3) break;
        if (x > n) break;
        x *= 3;
        a.push_back(x);
    }
    while (1){
        if (y > INF / 5) break;
        if (y > n) break;
        y *= 5;
        b.push_back(y);
    }

    // for (auto ele : a){
    //     printf("%lld ", ele);
    // }
    // cout << endl;
    // for (auto ele : b){
    //     printf("%lld ", ele);
    // }
    // cout << endl;


    rep(i,(int)a.size()){
        rep(j,(int)b.size()){
            if (a[i] + b[j] == n){
                printf("%lld %lld\n", i+1, j+1);
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

//
//  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;
}
