program main
  implicit none

  integer :: ak, bk, mk
  integer, allocatable :: a(:), b(:), m(:,:), total(:)
  integer :: i, j

  read (*,*) ak, bk, mk

  allocate(a(ak))
  allocate(b(bk))
  allocate(m(3,mk))

  read(*,*) a
  read(*,*) b
  read(*,*) m

     allocate(total(mk+1))
     do i = 1, mk
        total(i) = a(m(1,i)) + b(m(2,i)) - m(3,i)
     end do

     total(mk + 1)=minval(a) + minval(b)

     write(*,*) minval(total)

     deallocate(total)
     
 deallocate(a,b,m)
 stop
 
end program main

