#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <cstring>
#include <bitset>
#include <array>

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll pot=3;
	int br1=1, br2=1;
	ll y;
	ll x;
	while(pot<n){
		y=n-pot;
		x=5;
		br2=1;
		while(y>x){
			br2++;
			x*=5;
		}
		if(pot+x==n){
			cout << br1 << ' ' << br2 << '\n';
			return 0;
		}
		br1++;
		pot*=3;
	}
	cout << -1 << '\n';
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool _DD = false;
#define _D(a)if(_DD)cout<<#a<<':'<<a<<" | ";
#define DBG(a){_D(a);if(_DD)cout<<'\n';}
#define DBG2(a,b){_D(a);_D(b);if(_DD)cout<<'\n';}
#define DBG3(a,b,c){_D(a);_D(b);_D(c);if(_DD)cout<<'\n';}
#define DBG4(a,b,c,d){_D(a);_D(b);_D(c);_D(d);if(_DD)cout<<'\n';}
#define DBG5(a,b,c,d,e){_D(a);_D(b);_D(c);_D(d);_D(e);if(_DD)cout<<'\n';}
#define DBG6(a,b,c,d,e,f){_D(a);_D(b);_D(c);_D(d);_D(e);_D(f);if(_DD)cout<<'\n';}
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<vb> vvb;typedef vector<string> vs;typedef vector<vector<string>> vvs; typedef vector<char> vc; typedef vector<vc> vvc;
#define unmp unordered_map

const lli PRIME = 1000000007ll;
const lli PRIME2 = 998244353ll;

inline void debugORfast(bool a=0,bool b=1){
    if(a) _DD=1;
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
}

//Question Link 

int main(int argc,char* argv[]) 
{
    if(argc>1 and strcmp(argv[1],"1")==0) debugORfast(1,1);
    else debugORfast(0,1);

	lli n; cin>>n;
	f(t,1,38){
		f(fv,1,26){
			lli val = powl(3,t)+powl(5,fv);
			if(val==n){
				cout<<t<<' '<<fv<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
    return 0;
}
