#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
	ll n;
    while(cin>>n){
        ll ans=0, tmp1 = 3, tmp2 = 1, ans1 = -1, ans2 = -1;
        for(ll i = 1; tmp1<=n; tmp1*=3, ++i){
        	tmp2 = 5;
        	for(ll j = 1; tmp2<=n-tmp1; ++j, tmp2*=5){
        		if(tmp2+tmp1==n){
        			ans1 = i;
        			ans2 = j;
        			break;
        		}
        	}
        	if(ans1!=-1){
        		break;
        	}
        }
        if(ans1==-1){
        	printf("-1\n");
        }
        else{
        	printf("%lld %lld\n",ans1, ans2);
        }
    }
  return 0;
}



#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll N; cin >> N;
  for(ll i = 1; i <= 37; i++){
   for(ll j = 1; j <= 37; j++){
     if(powl(3,i)+powl(5,j)==N){cout<<i<<" "<<j<<endl;return 0;};
     if(powl(5,i)+powl(3,j)==N==N){cout<<j<<" "<<i<<endl;return 0;};
   }
  }
  cout << "-1" << endl;
  return 0;
}