PROGRAM ATCODER

implicit none
integer(8) :: n,i,a_sum,t_sum,j,s
integer(8),allocatable :: a(:),t(:)

read(*,*) n    !ここが入力欄
allocate(a(n), t(n))

do i = 1, n
  read(*,*) t(i), a(i)
end do

t_sum = t(1)
a_sum = a(1)
s = 0

do i = 2,n
  if(a_sum>a(i) .or. t_sum>t(i))then
    s = max(ceiling(real(a_sum)/real(a(i))),ceiling(real(t_sum)/real(t(i))))
    a_sum = a(i)*s
    t_sum = t(I)*s
  else
    a_sum = a(i)
    t_sum = t(i)
  end if
end do

! ここに出力結果
write(*,'(i0)') t_sum+a_sum

contains
!!!!!! サブルーチンは↓

!!!!!!

END PROGRAM ATCODER
