fun main(arr:Array<String>) {
    val inputCount = readLine()!!.toInt()
    var (ansT, ansA) = listOf(1L, 1L)
    (1..inputCount).forEach {
        val (t, a) = readLine()!!.split(" ").map { it.toLong() }
        val start = Math.max(ansT/t, ansA/a)
        for (i in (start..(ansT+ansA))) {
            if(t*i>=ansT && a*i>=ansA) {
                ansT = t*i
                ansA = a*i
                break
            }
        }
    }
    println(ansA+ansT)
}

