PROGRAM ATCODER

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

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

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

t_sum = 1
a_sum = 1
s = 0

do i = 1,n
  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
end do

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

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

!!!!!!

END PROGRAM ATCODER
