fun main(args: Array<String>) {
    val (a,b,m) =  readLine()!!.split(' ').map { it.toInt() }

    val aArr =  readLine()!!.split(' ').map { it.toInt() }
    val bArr =  readLine()!!.split(' ').map { it.toInt() }

    val aMin = aArr.min()!!
    val bMin = bArr.min()!!
    var min = aMin + bMin
    repeat(m) {
        val (x,y,c) =  readLine()!!.split(' ').map { it.toInt() }
        val tmp = aArr[x-1] +  bArr[y-1] - c
        if (tmp < min) min = tmp
    }
    println(min)
}
