#include <stdio.h>

long long power(long long a, long long b) {
	long long result = 1, i;
	for (i = 0; i < b; i++) {
		result *= a;
	}
	return result;
}

int main() {
	long long i = 1, j = 1, n, turn = 1;;
	scanf("%lld", &n); getchar();
	while (1) {
		if (power(5, i) >= n) break;
		long long x = n - power(5, i);
		turn = 1; j = 1;
		while (1) {
			if (x % 10 == 3 && turn == 1) j = 1;
			else if (x % 10 == 9 && turn == 1) j = 2;
			else if (x % 10 == 7 && turn == 1) j = 3;
			else if (x % 10 == 1 && turn == 1) j = 4;
			else if (x % 10 != 3 && x % 10 != 9 && x % 10 != 7 && x % 10 != 1) break;
			if (power(3, j) > x) break;
			if (power(3, j) == x) {
				printf("%lld %lld\n", j, i);
				return 0;
			}
			j += 4;
			turn = 0;
		}
		i++;
	}
	printf("-1\n");
	return 0;
}
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
const int N = 20;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin >> n;
	
	for (ll i = 3, x = 1; i <= n; i *= 3, x++)
		for (ll j = 5, y = 1; i + j <= n; j *= 5, y++)
		{
			if (i + j == n){
				cout << x << " " << y;
				return 0;
			}
		}
		
	cout << -1;
}	


/*
1
25
8 2 8 9 2 9 8 10 13 11 1 11 1 6 10 6 1 3 5 3 7 11 10 7 2
*/
