object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    in.next
    in.foldLeft(List[Array[Int]]())((qs, q) => q match {
        case Array(0, _*) => q.tail +: qs
        case Array(1, s, t) => {
            var x = qs
            var y = (s to t).toSet
            var res = 2147483647
            while (x.nonEmpty && y.nonEmpty) {
                y = y - x.head(0)
                res = res min x.head(1)
                x = x.tail
            }
            println(res)
            qs
        }
    })
}