import java.lang.Math.max
import java.util.*

fun <T> T.also(func:T.() -> Unit):T {
    this.func()
    return this
}
fun main(args:Array<String>):Unit {
    val (_, _, n) = readLine()!!.split(' ').map(String::toInt)
    val enemies = Stack<Enemy>().also{
        push(Enemy(0, 0))
        repeat(n){
            val (x, y) = readLine()!!.split(' ').map(String::toInt)
            push(Enemy(x, y))
        }
    }.sortedBy(Enemy::x).toTypedArray()
    val maxY = Array(n + 1){0}
    for (i in (n - 1) downTo 0){
        maxY[i] = max(maxY[i + 1], enemies[i + 1].y)
    }
    println(enemies.mapIndexed{index, enemy -> enemy.x + maxY[index]}.min())
}
data class Enemy(val x:Int, val y:Int)
