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

    var min = a.min()!! + b.min()!!
    for (i in 0 until m) {
        val l = readLine()!!.split(' ').map { it.toInt() }
        min = Math.min(min, a[l[0]-1]+b[l[1]-1]-l[2])
    }

    println(min)
}
