program prob2
    implicit none

    integer(8)::i,ans,disc,AA,BB,M
    integer(8), allocatable::A(:),B(:), C(:,:)
    read(*,*) AA, BB, M
    allocate(A(AA))
    allocate(B(BB))
    allocate(C(3,M))
    read(*,*) A
    read(*,*) B
    read(*,*) C

    ans = minval(A) + minval(B)

    do i = 1, M
        disc = A(C(1,i)) + B(C(2,i)) - C(3,i)
        if(disc < ans) then
            ans = disc
        end if
    end do

    write(*,*) ans

    deallocate(A)
    deallocate(B)
    deallocate(C)

    stop
end program prob2