import sys import math input = sys.stdin.readline k = int(input()) N = [tuple(map(int, input().split())) for _ in range(k)] lgN = sum(math.log(p) * e for p, e in N) p = N[-1][0] lg_plus = 0.0 lg_minus = 0.0 err = math.inf r_ans = -1 for r in range(p // 2): lg_plus += math.log(p - r) lg_minus += math.log(r + 1) if err > abs(lg_minus + lgN - lg_plus): err = abs(lg_minus + lgN - lg_plus) r_ans = r + 1 if min(err, err / lgN) < 1e-8: print(p, r_ans) else: print(-1, -1)