import java.util.Scanner

fun main(args: Array<String>){
    val scanner = Scanner(System.`in`)
    val numberOfLook = scanner.nextInt()
    val votesPairs = Array(numberOfLook){ D1015C.VotesRatioPair(scanner.nextInt(), scanner.nextInt()) }
    val result = D1015C(votesPairs).judge()
    println(result)
}

class D1015C(
  private val votesRatioArray: Array<VotesRatioPair>
){
    fun judge(): Long{
        return votesRatioArray.reduce { interimResult, currentRatio ->
            currentRatio * currentRatio.getMultiplierThatCanExceedTarget(interimResult)
        }.getSum()
    }

    data class VotesRatioPair(
      val takahashi: Long
     ,val aoki:      Long
    ){
        constructor(takahashi: Int, aoki: Int): this(takahashi.toLong(), aoki.toLong())

        operator fun times(value: Long): VotesRatioPair
                = VotesRatioPair(takahashi * value, aoki * value)
        operator fun div(value: VotesRatioPair): VotesRatioPair
                = VotesRatioPair(takahashi = takahashi / value.takahashi
                                ,aoki      = aoki      / value.aoki     )

        fun getMultiplierThatCanExceedTarget(target: VotesRatioPair): Long
            = VotesRatioPair(takahashi = (target.takahashi + takahashi -1) /takahashi
                            ,aoki      = (target.aoki      + aoki      -1) /aoki     )
                .getMax()

        fun getMax() = Math.max(takahashi, aoki)
        fun getSum() = takahashi + aoki
    }
}