#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

ll N;
ll i3[100];
ll i5[100];

bool res(ll r, ll &b) {
  while(i5[b] > r) b--;
  if (i5[b] == r) return true;
  b++;
  return false;
}

int main()
{

  int A,B;
  int max3, max5;

  i3[0] = 1;
  for (max3=1; i3[max3-1] < 1000000000000000000LL; max3++) {
    i3[max3] = i3[max3-1]*3;
  }
  max3--;
  i5[0] = 1;
  for (max5=1; i5[max5-1] < 1000000000000000000LL; max5++) {
    i5[max5] = i5[max5-1]*5;
  }
  max5--;

  B = max5;

  cin >> N;

  for (A=1; i3[A] < N; A++) {
    for (B=max5; B>0 ; B--) {
//printf("i3[%d](%lld) + i5[%d](%lld) = %lld\n", A, i3[A], B, i5[B], i3[A] + i5[B]);
      if (i3[A] + i5[B] == N) {
        printf("%d %d\n", A, B);
        return 0;
      }
      if (i3[A] + i5[B] < N) break;
    }
  }

  printf("-1\n");

  return 0;
}

#include<iostream>
#include<cmath>
using namespace std;

long long power(long long a,long long x){
    return x?x%2?power(a,x-1)*a:(long long)power(a,x/2)*power(a,x/2):1;
}


long long N,A,B;
int main(){
    cin>>N;
    for(B=1LL;power(5LL,B)<=N;B++){
        //cout<<B<<" : "<<power(5LL,B)<<endl;
        long long t=N-power(5LL,B);
        if(t==0LL)continue;
        //cout<<t<<endl;
        for(A=0LL;t%3LL==0LL;A++)t/=3LL;
        if(t==1LL&&A>0LL){cout<<A<<" "<<B<<endl;return 0;}
    }
    cout<<-1<<endl;
}