n = int(input())
f = lambda : map(int, input().split())
a, b = f()
for _ in range(1, n):
    c, d = f()
    t = max(1, 0 - -a // c, 0 - -b // d)
    a, b = c * t, d * t
print(a + b)

b0db883889f8adca70abba153d7e69c7b98285b4
<mask token>

<mask token>
for _ in range(1, n):
    c, d = f()
    t = max(1, 0 - -a // c, 0 - -b // d)
    a, b = c * t, d * t
print(a + b)

n = int(input())
f = lambda : map(int, input().split())
a, b = f()
for _ in range(1, n):
    c, d = f()
    t = max(1, 0 - -a // c, 0 - -b // d)
    a, b = c * t, d * t
print(a + b)
