PROGRAM ATCODER

implicit none
integer(8) :: n,i,a_sum,t_sum,j
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)

do i = 2,n
  do j = 2, 10**9
    if(a_sum>a(i) .or. t_sum>t(i))then
      a(i) = a(i)/(j-1)*j
      t(i) = t(i)/(j-1)*j
    else
      a_sum = a(i)
      t_sum = t(i)
      exit
    end if
  end do
end do

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

END PROGRAM ATCODER
