#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using pii = pair<int,int>;
const ll mod = 1e9 + 7;
const int maxn = 1e5+5;

void go() { 
    ll n;
    cin >> n;
    ll p3 = 1;
    f1(37) {
        p3 *= 3;
        ll p5 = 1;
        fr(j,1,26) {
            //cout << (ll)pow(3,i) + (ll)pow(5,j) << endl;
            p5 *= 5;
            if (p3 + p5 == n) {
                cout << i <<' '<<j<<endl;
                exit(0);
            }
        }
    }
    cout << -1 << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int> vi;

const int limit = (int)1e18;

void build(vi &v, int f)
{
    int b = f;
    while (b <= limit)
        v.push_back(b), b *= f;
}

int32_t main()
{
    vi a, b;
    build(a, 3);
    build(b, 5);

    int n;
    cin >> n;

    bool flag = false;
    pair<int, int> ans;
    for (int i = 0; i < (int)a.size(); i++)
        for (int j = 0; j < (int)b.size(); j++)
            if (a[i] + b[j] == n)
            {
                flag = true, ans.first = i + 1, ans.second = j + 1;
                break;
            }

    if (flag)
        cout << ans.first << ' ' << ans.second;
    else
        cout << -1;
    return 0;
}