n=int(eval(input()))

from fractions import Fraction

import math

t=[[int(i)for i in input().split()]for i in range(n)]

dp=[0]*n

dp[0]=1

for i in range(1,n):

    dp[i]=math.ceil((max(Fraction(t[i-1][0],t[i][0]),Fraction(t[i-1][1],t[i][1]))*dp[i-1]))

print((dp[-1]*(t[n-1][0]+t[n-1][1])))
n=int(eval(input()))

t=[[int(i)for i in input().split()]for i in range(n)]

import math

from fractions import Fraction

dp=[0]*n

dp[0]=1

for i in range(1,n):

    dp[i]=math.ceil(max(Fraction(t[i-1][0],t[i][0]),Fraction(t[i-1][1],t[i][1]))*dp[i-1])

print((dp[-1]*(t[n-1][0]+t[n-1][1])))
n = int(eval(input()))
from fractions import Fraction
import math

t = [[int(i) for i in input().split()] for i in range(n)]
dp = [0] * n
dp[0] = 1
for i in range(1, n):
    dp[i] = math.ceil(
        (
            max(Fraction(t[i - 1][0], t[i][0]), Fraction(t[i - 1][1], t[i][1]))
            * dp[i - 1]
        )
    )
print((dp[-1] * (t[n - 1][0] + t[n - 1][1])))

n = int(eval(input()))
t = [[int(i) for i in input().split()] for i in range(n)]
import math
from fractions import Fraction

dp = [0] * n
dp[0] = 1
for i in range(1, n):
    dp[i] = math.ceil(
        max(Fraction(t[i - 1][0], t[i][0]), Fraction(t[i - 1][1], t[i][1])) * dp[i - 1]
    )
print((dp[-1] * (t[n - 1][0] + t[n - 1][1])))

+t = [[int(i) for i in input().split()] for i in range(n)] +import math -import math -t = [[int(i) for i in input().split()] for i in range(n)] -        ( -            max(Fraction(t[i - 1][0], t[i][0]), Fraction(t[i - 1][1], t[i][1])) -            * dp[i - 1] -        ) +        max(Fraction(t[i - 1][0], t[i][0]), Fraction(t[i - 1][1], t[i][1])) * dp[i - 1]